|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hackystat.sensorshell.SensorShellProperties
public class SensorShellProperties
Provides Hackystat sensors with access to standard Hackystat sensorshell properties. These properties are generally stored in ~/.hackystat/sensorshell/sensorshell.properties. This class manages access to those files for sensors, performs type conversions on the String-based properties when appropriate, and sets default values when the properties are missing or incorrectly specified.
See the public static final Strings for descriptions of the "standard" Hackystat sensorshell properties.
Field Summary | |
---|---|
static java.lang.String |
SENSORSHELL_AUTOSEND_MAXBUFFER_KEY
The property key retrieving an integer indicating the maximum number of sensor instances to buffer locally between autosends of sensor data. |
static java.lang.String |
SENSORSHELL_AUTOSEND_TIMEINTERVAL_KEY
The property key retrieving a double indicating how many minutes between autosends of sensor data when not in MultiShell mode. |
static java.lang.String |
SENSORSHELL_LOGGING_LEVEL_KEY
The property key retrieving a string indicating the logging level for the SensorShell(s). |
static java.lang.String |
SENSORSHELL_MULTISHELL_AUTOSEND_TIMEINTERVAL_KEY
The property key retrieving a double indicating how many minutes between autosends of sensor data for each shell in a MultiShell. |
static java.lang.String |
SENSORSHELL_MULTISHELL_BATCHSIZE_KEY
The property key retrieving an integer indicating the number of instances to send to a single shell in the MultiSensorShell at once. |
static java.lang.String |
SENSORSHELL_MULTISHELL_ENABLED_KEY
The property key retrieving a boolean indicating whether the MultiSensorShell is enabled. |
static java.lang.String |
SENSORSHELL_MULTISHELL_MAXBUFFER_KEY
The property key retrieving an integer indicating the maximum number of instances to buffer in each shell in the MultiSensorShell before a blocking send() is invoked. |
static java.lang.String |
SENSORSHELL_MULTISHELL_NUMSHELLS_KEY
The property key retrieving an integer indicating the number of shells to instantiate when the MultiSensorShell is enabled. |
static java.lang.String |
SENSORSHELL_OFFLINE_CACHE_ENABLED_KEY
The property key retrieving a boolean indicating if data will be cached locally if the SensorBase cannot be contacted. |
static java.lang.String |
SENSORSHELL_OFFLINE_RECOVERY_ENABLED_KEY
The property key retrieving a boolean indicating if offline data will be recovered at startup if the SensorBase can be contacted. |
static java.lang.String |
SENSORSHELL_PING_TIMEOUT_KEY
The property key retrieving the timeout value (in seconds) for SensorShell 'PING' requests. |
static java.lang.String |
SENSORSHELL_SENSORBASE_HOST_KEY
The property key retrieving an URL indicating the location of the SensorBase host. |
static java.lang.String |
SENSORSHELL_SENSORBASE_PASSWORD_KEY
The property key retrieving the password associated with the user. |
static java.lang.String |
SENSORSHELL_SENSORBASE_USER_KEY
The property key retrieving the user account associated with the SensorBase. |
static java.lang.String |
SENSORSHELL_STATECHANGE_INTERVAL_KEY
The property key retrieving an integer indicating the number of seconds between "wakeups" of tool subprocesses that check for state changes. |
static java.lang.String |
SENSORSHELL_TIMEOUT_KEY
The property key retrieving the timeout value (in seconds) for SensorShell HTTP requests. |
Constructor Summary | |
---|---|
SensorShellProperties()
Initializes SensorShell properties using the default sensorshell.properties file. |
|
SensorShellProperties(java.io.File sensorFile)
Creates a SensorShellProperties instance using the specified properties file. |
|
SensorShellProperties(java.util.Properties properties,
boolean overrideFile)
Creates a SensorShell properties instance, initializing it using the passed properties as well as any settings found in the sensorshell.properties file. |
|
SensorShellProperties(SensorShellProperties orig,
java.util.Properties newProps)
Creates and returns a new SensorShellProperties instance which is initialized to the contents of the passed SensorProperties instance, with additional new properties overriding the previous selection. |
|
SensorShellProperties(java.lang.String host,
java.lang.String email,
java.lang.String password)
Constructs a "basic" instance with the supplied three required properties. |
|
SensorShellProperties(java.lang.String host,
java.lang.String email,
java.lang.String password,
java.util.Properties properties,
boolean overrideFile)
Constructs an instance with the supplied three required properties and any other properties provided in the properties argument. |
Method Summary | |
---|---|
int |
getAutoSendMaxBuffer()
Returns the AutoSend batch size, such as 250. |
double |
getAutoSendTimeInterval()
Returns the AutoSend time interval, such as 1.0. |
java.util.logging.Level |
getLoggingLevel()
Returns the logging level specified for SensorShells. |
double |
getMultiShellAutoSendTimeInterval()
Returns the MultiShell AutoSend time interval, such as 0.10. |
int |
getMultiShellBatchSize()
Returns the number of instances to send to one shell in a row if multishell processing. |
int |
getMultiShellMaxBuffer()
Returns the maximum number of instances to buffer before a blocking send is invoked in multishell mode. |
int |
getMultiShellNumShells()
Returns the number of shells to instantiate if multishell processing is enabled. |
static SensorShellProperties |
getOfflineMode(SensorShellProperties properties)
Returns a new SensorShellProperties instance customized for offline data recovery. |
int |
getPingTimeout()
Returns the current timeout setting for Ping requests. |
java.lang.String |
getProperty(java.lang.String key)
Returns the trimmed property value associated with the property key. |
java.lang.String |
getSensorBaseHost()
Returns the sensorbase host, such as "http://dasha.ics.hawaii.edu:9876/sensorbase". |
java.lang.String |
getSensorBasePassword()
Returns the password for this user, such as "xu876csld". |
java.lang.String |
getSensorBaseUser()
Returns the account for this user, such as "johnson@hawaii.edu". |
int |
getStateChangeInterval()
Returns the StateChange interval. |
static SensorShellProperties |
getTestInstance(java.lang.String host,
java.lang.String email,
java.lang.String password)
Constructs a "test" instance with the supplied three required properties. |
int |
getTimeout()
Returns the current timeout setting for non-Ping requests. |
boolean |
isMultiShellEnabled()
Returns true if multishell processing is enabled. |
boolean |
isOfflineCacheEnabled()
Returns true if offline cache data saving is enabled. |
boolean |
isOfflineRecoveryEnabled()
Returns true if offline data recovery is enabled. |
void |
switchToMultiShellMode()
Sets the autosend time interval and autosend max buffer size to the multishell versions. |
java.lang.String |
toString()
Returns the set of SensorProperties as a multi-line string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SENSORSHELL_SENSORBASE_HOST_KEY
public static final java.lang.String SENSORSHELL_SENSORBASE_USER_KEY
public static final java.lang.String SENSORSHELL_SENSORBASE_PASSWORD_KEY
public static final java.lang.String SENSORSHELL_TIMEOUT_KEY
public static final java.lang.String SENSORSHELL_PING_TIMEOUT_KEY
public static final java.lang.String SENSORSHELL_MULTISHELL_ENABLED_KEY
public static final java.lang.String SENSORSHELL_MULTISHELL_NUMSHELLS_KEY
public static final java.lang.String SENSORSHELL_MULTISHELL_BATCHSIZE_KEY
public static final java.lang.String SENSORSHELL_MULTISHELL_MAXBUFFER_KEY
public static final java.lang.String SENSORSHELL_MULTISHELL_AUTOSEND_TIMEINTERVAL_KEY
public static final java.lang.String SENSORSHELL_OFFLINE_CACHE_ENABLED_KEY
public static final java.lang.String SENSORSHELL_OFFLINE_RECOVERY_ENABLED_KEY
public static final java.lang.String SENSORSHELL_STATECHANGE_INTERVAL_KEY
public static final java.lang.String SENSORSHELL_AUTOSEND_TIMEINTERVAL_KEY
public static final java.lang.String SENSORSHELL_AUTOSEND_MAXBUFFER_KEY
public static final java.lang.String SENSORSHELL_LOGGING_LEVEL_KEY
Constructor Detail |
---|
public SensorShellProperties() throws SensorShellException
SensorShellException
- If the SensorProperties instance cannot be
instantiated due to a missing host, user, and/or password properties.public SensorShellProperties(java.io.File sensorFile) throws SensorShellException
sensorFile
- The sensorshell properties file to read.
SensorShellException
- If the SensorProperties instance cannot be
instantiated due to a missing host, user, and/or password properties.public SensorShellProperties(java.lang.String host, java.lang.String email, java.lang.String password) throws SensorShellException
Use SensorShellProperties.getTestInstance to create an instance for testing purposes, since it will override certain properties that may be present in the sensorshell.properties file.
host
- The hackystat host.email
- The user's email.password
- The user's password.
SensorShellException
- If the SensorProperties instance cannot be
instantiated due to a missing host, user, and/or password properties.public SensorShellProperties(java.lang.String host, java.lang.String email, java.lang.String password, java.util.Properties properties, boolean overrideFile) throws SensorShellException
host
- The hackystat host.email
- The user's email.password
- The user's password.properties
- A properties instance with other properties.overrideFile
- If true, then the passed properties override sensorshell.properties.
SensorShellException
- If the SensorProperties instance cannot be
instantiated due to a missing host, user, and/or password properties.public SensorShellProperties(SensorShellProperties orig, java.util.Properties newProps) throws SensorShellException
orig
- The original properties.newProps
- The replacing properties.
SensorShellException
- If the SensorProperties instance cannot be instantiated due to
invalid or missing properties.public SensorShellProperties(java.util.Properties properties, boolean overrideFile) throws SensorShellException
This constructor enables the user to provide default settings in sensorshell.properties for things like MultiSensorShell, but enable a tool to provide command line args that could override these defaults. The tool could do this by processing its command line args, then creating a Properties instance containing the overridding values, then passing that in to this constructor.
If overrideFile is false, then these properties will only take effect if the user has not specified them in their sensorshell.properties file.
Standard properties not specified by either the sensorshell.properties file or the passed properties instance will be given default values.
properties
- The properties.overrideFile
- If true, then the passed properties will override any matching
sensorshell.properties properties.
SensorShellException
- if problems occur.Method Detail |
---|
public static SensorShellProperties getTestInstance(java.lang.String host, java.lang.String email, java.lang.String password) throws SensorShellException
This testing-only factory class sets the three required properties, and overrides the following properties for testing purposes:
host
- The hackystat host.email
- The user's email.password
- The user's password.
SensorShellException
- If the SensorProperties instance cannot be
instantiated due to a missing host, user, and/or password properties.public final java.lang.String getProperty(java.lang.String key)
key
- The parameter key.
public java.lang.String getSensorBaseHost()
public java.lang.String getSensorBasePassword()
public java.lang.String getSensorBaseUser()
public double getAutoSendTimeInterval()
public int getAutoSendMaxBuffer()
public int getStateChangeInterval()
public int getTimeout()
public int getPingTimeout()
public java.util.logging.Level getLoggingLevel()
public boolean isMultiShellEnabled()
public int getMultiShellNumShells()
public int getMultiShellBatchSize()
public int getMultiShellMaxBuffer()
public double getMultiShellAutoSendTimeInterval()
public boolean isOfflineCacheEnabled()
public boolean isOfflineRecoveryEnabled()
public java.lang.String toString()
toString
in class java.lang.Object
public void switchToMultiShellMode()
public static SensorShellProperties getOfflineMode(SensorShellProperties properties) throws SensorShellException
properties
- The original properties.
SensorShellException
- If something goes wrong.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |