Package overit.geocall.da
Class TimeSlot
java.lang.Object
overit.geocall.da.TimeSlot
The class defines the TimeSlot object, the one used to manage jobs on multiple nodes with shared resources.
The concept of TimeSlot is to allocate a certain amount of time for a given activity.
To take advantage of the TimeSots, you need to write concurrent and collaborative tasks to make sure that the workload is divided.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidfree()Frees the TimeSlot that can be obtained by other tasksgetName()Retrieves the name of the TimeSlotgetUID()Retrieves the instance identifiervoidhold(long secs) Allows to prolong or reduce the duration of the TimeSlot that we have in charge.static TimeSlotlockTimeSlot(String name, long secs) Requests an instance of the TimeSlot.static TimeSlotlockTimeSlot(String name, long secs, boolean autoHold) Requests an instance of the TimeSlot.toString()Returns a String representation of the TimeSlot
-
Field Details
-
_name
TimeSlot name -
_uid
Instance identifier
-
-
Method Details
-
getUID
Retrieves the instance identifier- Returns:
- The string that represent the instance identifier
-
getName
Retrieves the name of the TimeSlot- Returns:
- The string that represent the name of the TimeSlot
-
lockTimeSlot
Requests an instance of the TimeSlot. The instance remain valid from the moment it is obtained for the duration specified in the second parameter.- Parameters:
name- The name of the TimeSlot. Tasks that uses the same TimeSlot name must implement a collision management techniquesecs- The length, in seconds, of the validity of the requested timeslot- Returns:
- The requested TimeSlot, or null if the specific TimeSlot is already occupied
- Throws:
DAException- The exception is raised if there is a database access error
-
lockTimeSlot
Requests an instance of the TimeSlot. The instance remain valid from the moment it is obtained for the duration specified in the second parameter.- Parameters:
name- The name of the TimeSlot. Tasks that uses the same TimeSlot name must implement a collision management techniquesecs- The length, in seconds, of the validity of the requested timeslotautoHold- true to set the renew value (equals to the validity value), false to set it to 0- Returns:
- The requested TimeSlot, or null if the specific TimeSlot is already occupied
- Throws:
DAException- The exception is raised if there is a database access error
-
hold
Allows to prolong or reduce the duration of the TimeSlot that we have in charge. If the TimeSlot is not loaded (for example because another parallel task has taken over it), it will be raised an exception that interrupts the task.- Parameters:
secs- The new duration of the TimeSlot, in second, from the current moment- Throws:
DAException- The exception is raised if there is a database access error or in case that another Task has the possession of the TimeSlot
-
free
public void free()Frees the TimeSlot that can be obtained by other tasks -
toString
Returns a String representation of the TimeSlot
-