nl.astron.lofar.odtb.mom2otdbadapter.otdblistener
Class Queue

java.lang.Object
  extended by nl.astron.lofar.odtb.mom2otdbadapter.otdblistener.Queue

public class Queue
extends java.lang.Object

Queue of tasks

Author:
Bastiaan Verhoef

Nested Class Summary
(package private)  class Queue.TasksFilter
          Filters task files
 
Field Summary
private static java.lang.String DATE_TIME_FORMAT
           
private  java.util.Date endTime
           
private static java.lang.String FILE_DATE_TIME_FORMAT
           
private  boolean isTaskLocked
           
private  org.apache.commons.logging.Log log
           
private static java.lang.String OTDB_TIME_FORMAT
           
private  java.util.Date startTime
           
private  java.lang.String taskDir
           
private  java.util.List tasks
           
 
Constructor Summary
Queue()
          Constructor that looks for tasks (*.xml) in the .
 
Method Summary
 void add(Task task)
          Add the task to the task list and store it as a xml file
 Task get()
          Retrieve a task, if there are tasks, if there are no tasks, wait until a task is in the queue
protected  java.lang.String getFile(java.lang.String fileName)
          Retrieve file by file name
 TimePeriod getTimePeriod()
          Retrieves the new time period, from the last time period to now
 void moveToEndOfTaskList(Task task)
          If a task can not be executed, move it to the end of the tasks list, so other tasks can be executed.
 void remove(Task task)
          Remove a task
 void saveTimePeriod()
          Save the time period
protected  void storeTask(Task task)
          Store a task
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log

tasks

private java.util.List tasks

taskDir

private java.lang.String taskDir

FILE_DATE_TIME_FORMAT

private static final java.lang.String FILE_DATE_TIME_FORMAT
See Also:
Constant Field Values

DATE_TIME_FORMAT

private static final java.lang.String DATE_TIME_FORMAT
See Also:
Constant Field Values

OTDB_TIME_FORMAT

private static final java.lang.String OTDB_TIME_FORMAT
See Also:
Constant Field Values

startTime

private java.util.Date startTime

endTime

private java.util.Date endTime

isTaskLocked

private boolean isTaskLocked
Constructor Detail

Queue

public Queue()
      throws java.io.IOException
Constructor that looks for tasks (*.xml) in the ./tasks directory and load them.

Throws:
java.io.IOException
Method Detail

get

public Task get()
Retrieve a task, if there are tasks, if there are no tasks, wait until a task is in the queue

Returns:
Task

remove

public void remove(Task task)
Remove a task

Parameters:
task - task to be removed

moveToEndOfTaskList

public void moveToEndOfTaskList(Task task)
If a task can not be executed, move it to the end of the tasks list, so other tasks can be executed.

Parameters:
task - task to be moved to the end of the tasks list.

getTimePeriod

public TimePeriod getTimePeriod()
                         throws java.io.IOException
Retrieves the new time period, from the last time period to now

Returns:
Time period
Throws:
java.io.IOException

saveTimePeriod

public void saveTimePeriod()
                    throws java.io.IOException
Save the time period

Throws:
java.io.IOException

add

public void add(Task task)
         throws java.io.IOException
Add the task to the task list and store it as a xml file

Parameters:
task - Task to be stored
Throws:
java.io.IOException

getFile

protected java.lang.String getFile(java.lang.String fileName)
                            throws java.io.IOException
Retrieve file by file name

Parameters:
fileName - name of the file to be read
Returns:
file as string
Throws:
java.io.IOException

storeTask

protected void storeTask(Task task)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Store a task

Parameters:
task - task to be stored
Throws:
java.io.FileNotFoundException
java.io.IOException