Class TimeSlot

java.lang.Object
overit.geocall.da.TimeSlot

public class TimeSlot extends Object
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 Details

    • _name

      protected String _name
      TimeSlot name
    • _uid

      protected String _uid
      Instance identifier
  • Method Details

    • getUID

      public String getUID()
      Retrieves the instance identifier
      Returns:
      The string that represent the instance identifier
    • getName

      public String getName()
      Retrieves the name of the TimeSlot
      Returns:
      The string that represent the name of the TimeSlot
    • lockTimeSlot

      public static TimeSlot lockTimeSlot(String name, long secs) throws DAException
      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 technique
      secs - 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

      public static TimeSlot lockTimeSlot(String name, long secs, boolean autoHold) throws DAException
      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 technique
      secs - The length, in seconds, of the validity of the requested timeslot
      autoHold - 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

      public void hold(long secs) throws DAException
      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

      public String toString()
      Returns a String representation of the TimeSlot
      Overrides:
      toString in class Object
      Returns:
      A string representation of the TimeSlot formatted as 'TimeSlot[name / id]';