org.hackystat.sensorshell
Class OfflineManager

java.lang.Object
  extended by org.hackystat.sensorshell.OfflineManager

public class OfflineManager
extends java.lang.Object

Provides a facility for: (a) persisting buffered SensorData instances locally when the SensorBase host is not available and (b) recovering them during a subsequent invocation of SensorShell.

Author:
Philip Johnson

Field Summary
(package private)  boolean hasOfflineData
          Whether or not data has been stored offline.
 
Constructor Summary
OfflineManager(SingleSensorShell shell, java.lang.String tool)
          Creates an OfflineManager given the parent shell and the tool.
 
Method Summary
 boolean hasOfflineData()
          Returns true if this offline manager has successfully stored any data offline.
 void recover()
          Attempts to resend any previously stored SensorDatas instances from their serialized files.
 void store(org.hackystat.sensorbase.resource.sensordata.jaxb.SensorDatas sensorDatas)
          Stores a SensorDatas instance to a serialized file in the offline directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasOfflineData

boolean hasOfflineData
Whether or not data has been stored offline.

Constructor Detail

OfflineManager

public OfflineManager(SingleSensorShell shell,
                      java.lang.String tool)
Creates an OfflineManager given the parent shell and the tool.

Parameters:
shell - The parent shell.
tool - The tool.
Method Detail

store

public void store(org.hackystat.sensorbase.resource.sensordata.jaxb.SensorDatas sensorDatas)
Stores a SensorDatas instance to a serialized file in the offline directory. Does nothing if there are no sensordata instances in the SensorDatas instance.

Parameters:
sensorDatas - The SensorDatas instance to be stored.

hasOfflineData

public boolean hasOfflineData()
Returns true if this offline manager has successfully stored any data offline.

Returns:
True if offline data has been stored.

recover

public void recover()
             throws SensorShellException
Attempts to resend any previously stored SensorDatas instances from their serialized files. Creates a new sensorshell instance to do the sending. Each SensorDatas instance is deserialized, then each SensorData instance inside is sent to the SensorShell. This gives the SensorShell an opportunity to send batches off at whatever interval it chooses. All serialized files are deleted after being processed if successful.

Throws:
SensorShellException - If problems occur sending the recovered data.