|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hackystat.sensorshell.SensorShell
public class SensorShell
Provides "middleware" for accumulating and sending notification (sensor) data to Hackystat. SensorShell has two modes of interaction: command line and programmatic.
Command line mode is entered by invoking the main() method, and is intended to be used as a kind of subshell to which commands to add and send notification data of various types can be sent. The SensorShell can be invoked without any additional arguments as follows:
java -jar sensorshell.jarOr you can invoke it with one, two, or three additional arguments:
java -jar sensorshell.jar [tool] [sensorshell.properties] [command file]
Programmatic mode involves creating an instance of SensorShell, retrieving the appropriate command instance (Ping, Add, etc.) and invoking the appropriate method.
Constructor Summary | |
---|---|
SensorShell(SensorShellProperties properties,
boolean isInteractive)
Constructs a new SensorShell instance that can be provided with notification data to be sent eventually to a specific user key and host. |
|
SensorShell(SensorShellProperties properties,
boolean isInteractive,
java.lang.String tool)
Constructs a new SensorShell instance that can be provided with notification data to be sent eventually to a specific user key and host. |
|
SensorShell(SensorShellProperties properties,
boolean isInteractive,
java.lang.String toolName,
java.io.File commandFile)
Constructs a new SensorShell instance that can be provided with notification data to be sent eventually to a specific user key and host. |
Method Summary | |
---|---|
void |
add(java.util.Map<java.lang.String,java.lang.String> keyValMap)
Converts the values in the KeyValMap to a SensorData instance and adds it to the Shell. |
void |
add(org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData sensorData)
Adds the passed SensorData instance to the Shell. |
SensorShellProperties |
getProperties()
Returns the SensorShell properties instance used to create this SensorShell. |
boolean |
hasOfflineData()
Returns true if any of shells in this interface have stored data offline. |
static void |
main(java.lang.String[] args)
The command line shell interface for invoking a single sensor shell interactively. |
boolean |
ping()
Returns true if the host can be pinged and the email/password combination is valid. |
void |
quit()
Invokes quit() on this Shell, which invokes a final send() and closes any logging files. |
int |
send()
Immediately invokes send() on this Shell. |
void |
statechange(long resourceCheckSum,
java.util.Map<java.lang.String,java.lang.String> keyValMap)
Implements the "StateChange" algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SensorShell(SensorShellProperties properties, boolean isInteractive)
properties
- The sensor properties instance for this run.isInteractive
- Whether this SensorShell is being interactively invoked or not.public SensorShell(SensorShellProperties properties, boolean isInteractive, java.lang.String tool)
properties
- The sensor properties instance for this run.isInteractive
- Whether this SensorShell is being interactively invoked or not.tool
- Indicates the invoking tool that is added to the log file name.public SensorShell(SensorShellProperties properties, boolean isInteractive, java.lang.String toolName, java.io.File commandFile)
properties
- The sensor properties instance for this run.isInteractive
- Whether this SensorShell is being interactively invoked or not.toolName
- The invoking tool that is added to the log file name.commandFile
- A file containing shell commands, or null if none provided.Method Detail |
---|
public void add(java.util.Map<java.lang.String,java.lang.String> keyValMap) throws SensorShellException
add
in interface Shell
keyValMap
- The map of key-value pairs.
SensorShellException
- If the Map cannot be translated into SensorData,
typically because a value
was passed for Timestamp or Runtime that could not be parsed into XMLGregorianCalendar.
Or if problems occur sending the data.public void add(org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData sensorData) throws SensorShellException
add
in interface Shell
sensorData
- The SensorData instance to be queued for transmission.
SensorShellException
- If problems occur sending the data.public int send() throws SensorShellException
send
in interface Shell
SensorShellException
- If problems occur sending the data.public void quit() throws SensorShellException
quit
in interface Shell
SensorShellException
- If an exception occurred during any autosend.public boolean hasOfflineData()
hasOfflineData
in interface Shell
public boolean ping()
ping
in interface Shell
public SensorShellProperties getProperties()
getProperties
in interface Shell
public void statechange(long resourceCheckSum, java.util.Map<java.lang.String,java.lang.String> keyValMap) throws java.lang.Exception
Thus, if an editor is running but the user is out at lunch, repeated invocations of the StateChange method will not result in any new data being sent to the server.
statechange
in interface Shell
resourceCheckSum
- An integer representing the state of the Resource.keyValMap
- A map of key-value pairs representing sensor data fields and properties.
java.lang.Exception
- If problems occur during the Add (if the Add actually occurs.)public static void main(java.lang.String[] args) throws SensorShellException
args
- The command line parameters. See above for details.
SensorShellException
- If problems occur sending data.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |