stella.sensor
Class DailyDumpRepository

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiListener
                      extended by stella.sensor.DailyDumpRepository
All Implemented Interfaces:
Cloneable, Remote, EventListener, RmiDataListener, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiEventListener, RmiListener, RmiPropertyBearing

public class DailyDumpRepository
extends AbstractRmiListener
implements RmiDataListener

This class dumps all incomming data from the sensors to data files. To avoid massive data-build up in a single file, the data is split up into daily peaces. Note that the KEY_LIST property and the KEY_ASCIIFILE property should point to a comma-separated list of equal dimension.


Nested Class Summary
private static class DailyDumpRepository.Parser
          A command line parser class to allow direct parameter hand-over.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFBAD
          The default good-weather indicator.
private static String DEFEXTENSION
          The default dump file name.
private static String DEFGOOD
          The default good-weather indicator.
private static double DEFNAN
          The default nan replacement.
static String KEY_ASCIIFILE
          The key linked to the dump files.
static String KEY_BAD
          The key pointing to the string added for good weather.
static String KEY_GOOD
          The key pointing to the string added for good weather.
static String KEY_LIST
          The key linked to the sensor binds.
static String KEY_NAN
          The key pointing to the replacement of NaN's.
static String KEY_PATH
          The key pointing to the output dir.
private  Map lastmap
          The hash map used for linking sensor names to last data receives.
private  Map namemap
          The hash map used for linking sensor names to sensor files.
private  List sensorbind
          The list of sensor bind names.
private  List sensordump
          The list of sensor dump files.
private  Map streammap
          The hash map used for linking sensor names to file streams.
 
Fields inherited from class util.rmi.AbstractRmiListener
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAY
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
DailyDumpRepository(Map prop)
          Constructs a new short-average repository.
 
Method Summary
protected  boolean deregisterAtCaster(RmiCaster rmi, Class single)
          Registers at the given caster.
private  String getFileHeader(String name)
          Some header information.
protected  void initDailyDumpRepository()
          Initializes the short average repository.
static void main(String[] arg)
          Starts the daily dump.
private  String openStream(String sensor, int mjd)
          Opens the file as a stream for writing.
protected  boolean registerAtCaster(RmiCaster rmi, Class single)
          Registers at the given caster.
 void rmiDataAvailable(DataEvent de)
          The data receiving edge of the repository.
 
Methods inherited from class util.rmi.AbstractRmiListener
allBound, blockBinding, blockBinding, disconnect, exit, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, rescanned, startBinding, startBinding
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, init, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.rmi.RmiEventListener
getListenerName
 
Methods inherited from interface util.rmi.RmiListener
disconnect, isConnected
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 

Field Detail

KEY_LIST

public static final String KEY_LIST
The key linked to the sensor binds. Given as a comma-separated list.

See Also:
Constant Field Values

KEY_PATH

public static final String KEY_PATH
The key pointing to the output dir.

See Also:
Constant Field Values

KEY_ASCIIFILE

public static final String KEY_ASCIIFILE
The key linked to the dump files. Given as a comma-separated list.

See Also:
Constant Field Values

KEY_NAN

public static final String KEY_NAN
The key pointing to the replacement of NaN's.

See Also:
Constant Field Values

KEY_GOOD

public static final String KEY_GOOD
The key pointing to the string added for good weather.

See Also:
Constant Field Values

KEY_BAD

public static final String KEY_BAD
The key pointing to the string added for good weather.

See Also:
Constant Field Values

DEFNAN

private static final double DEFNAN
The default nan replacement.

See Also:
Constant Field Values

DEFGOOD

private static final String DEFGOOD
The default good-weather indicator.

See Also:
Constant Field Values

DEFBAD

private static final String DEFBAD
The default good-weather indicator.

See Also:
Constant Field Values

DEFEXTENSION

private static final String DEFEXTENSION
The default dump file name.

See Also:
Constant Field Values

lastmap

private Map lastmap
The hash map used for linking sensor names to last data receives.


streammap

private Map streammap
The hash map used for linking sensor names to file streams.


namemap

private Map namemap
The hash map used for linking sensor names to sensor files.


sensorbind

private List sensorbind
The list of sensor bind names.


sensordump

private List sensordump
The list of sensor dump files.

Constructor Detail

DailyDumpRepository

public DailyDumpRepository(Map prop)
                    throws RemoteException
Constructs a new short-average repository. The KEY_NAN, the KEY_BAD, and the KEY_GOOD are assigned with their default values, if not present in the properties.

Throws:
RemoteException
Method Detail

initDailyDumpRepository

protected void initDailyDumpRepository()
Initializes the short average repository. This includes binding of the rmi-data depositing ability along with construction of the local and remote data collectors.


rmiDataAvailable

public void rmiDataAvailable(DataEvent de)
                      throws RemoteException
The data receiving edge of the repository. Additionally to updating the actual data table, the incoming data event is stored in a list of events. This lists should be used in the data collector to calculate the averages and should then be cleared.

Specified by:
rmiDataAvailable in interface RmiDataListener
Throws:
RemoteException

registerAtCaster

protected boolean registerAtCaster(RmiCaster rmi,
                                   Class single)
Registers at the given caster. Only if the given caster is an instance of a RmiDataCaster, the repository registers at it.

Specified by:
registerAtCaster in class AbstractRmiListener
Returns:
True, if registering at the caster was successful.

deregisterAtCaster

protected boolean deregisterAtCaster(RmiCaster rmi,
                                     Class single)
Registers at the given caster. Only if the given caster is an instance of a RmiDataCaster, the repository registers at it.

Specified by:
deregisterAtCaster in class AbstractRmiListener
Returns:
True, if registering at the caster was successful.

openStream

private String openStream(String sensor,
                          int mjd)
                   throws IOException
Opens the file as a stream for writing. If the file exists it is opened in append mode. For newly created dump files the method getFileHeader(java.lang.String) is called and writtn as a file header.

To ensure proper closing of the file, a shutdown-hook is added to the system.

Returns:
True if the file was just created.
Throws:
IOException

getFileHeader

private String getFileHeader(String name)
Some header information.


main

public static void main(String[] arg)
                 throws ParseException,
                        RemoteException
Starts the daily dump. Sensor names and file may be added on the command line. Run the daily dump repositroy without arguments to see the options.

Throws:
ParseException
RemoteException