stella.util
Class TransferListener.TransferThread

java.lang.Object
  extended by java.lang.Thread
      extended by stella.util.TransferListener.TransferThread
All Implemented Interfaces:
Runnable
Enclosing class:
TransferListener

private final class TransferListener.TransferThread
extends Thread

This is the main transfer thread. It has two (blocking) queues, the high-priority fits queue and the lower priority copy queue. Copy-queue files are simply copied, while fits file are first compressed before they are copied using the imcopy program. The destination directory is determined by scanning for the dateobs key in fits files or (for copy files or if the dateobs is not successful) using the file creation time. This time is used to calculate a jd, round that and calculating a date from that rounded jd, formatting with yyyyMMdd. If the file header is compatible to one of the TransferListener.KEY_FITSDB entries, also the obs db is updated. If the file has been successfully transferred, it is moved into the transfer directory and (if a db-relavant file), the db is updated again.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean cancel
          If true, we cancel.
private  BlockingDeque<File> copyqueue
          The que of the low-priority copy files.
private  BlockingDeque<File> fitsqueue
          The queue of the fits files.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private TransferListener.TransferThread()
          Constructs a new transfer thread and starts it.
 
Method Summary
private  BlockingDeque<File> getCopyQueue()
          Retunrs the blocking queue used for a simple copy of files.
private  BlockingDeque<File> getFitsQueue()
          Return the blocking queue used for the fits files.
 void run()
          We run forever until canceled.
private  void transferCopy()
          Transfer the first file in the copy queue to the target host.
private  void transferFits()
          Transfers the first file in the fitsqueue or waits at most TransferListener.KEY_POLLTIME for a file to get available.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fitsqueue

private BlockingDeque<File> fitsqueue
The queue of the fits files.


copyqueue

private BlockingDeque<File> copyqueue
The que of the low-priority copy files.


cancel

private boolean cancel
If true, we cancel.

Constructor Detail

TransferListener.TransferThread

private TransferListener.TransferThread()
Constructs a new transfer thread and starts it. The queues are initialized in the stnchronized run method.

Method Detail

getFitsQueue

private BlockingDeque<File> getFitsQueue()
Return the blocking queue used for the fits files. Fits files are always imcompressed before transferring and transferred with higher priority than to-copy files.


getCopyQueue

private BlockingDeque<File> getCopyQueue()
Retunrs the blocking queue used for a simple copy of files.


run

public void run()
We run forever until canceled. Whenever there are file in the fits queue, they are compressed and transferred to the target host. In the remainder time (i.e. fits queue is empty), the copy files are transferred.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

transferFits

private void transferFits()
Transfers the first file in the fitsqueue or waits at most TransferListener.KEY_POLLTIME for a file to get available. Once a file has been found, the first action is to enter it into the obs database, marking it as not-transferred, if the fits name is compliant with the db-requesting #KEY_DBFITS. It is than compressed using the rice loss-less image compression algorithm and transferred to the home host. If all that was successful, it is marked in the db as transferred and moved to the transfer dir.


transferCopy

private void transferCopy()
Transfer the first file in the copy queue to the target host. On success, it is moved to the transferred subdir.