org.optimizationservices.oscommon.localinterface
Class OSProcess

java.lang.Object
  extended by org.optimizationservices.oscommon.localinterface.OSProcess

public class OSProcess
extends java.lang.Object

The OSProcess class is a local interface for storing Optimization Services process. Its design follows the Optimization Services process Language (OSpL). All the data structures in this class are standards specified in OSbL.

Since:
OS 1.0
Version:
1.0, 03/14/2005
Author:
Robert Fourer, Jun Ma, Kipp Martin

Field Summary
 ProcessData processData
          processData holds the second child of the OSProcess specified by the OSpL Schema.
 ProcessHeader processHeader
          processHeader holds the first child of the OSProcess specified by the OSpL Schema.
 
Constructor Summary
OSProcess()
          Default constructor.
 
Method Summary
 double getAvailableDiskSpace()
          Get the available disk space (in bytes).
 double getAvailableMemory()
          Get the available memory (in bytes).
 int getCurrentJobCount()
          Get the current job count.
 java.lang.String getCurrentState()
          Get the current state, , which can be: "busy", "busyButAccepting", "idle", "idleButNotAccepting" and "noResponse".
 JobStatistics[] getJobStatistics()
          Get the statistics of all the jobs.
 JobOptimization[] getOptimizationProcess()
          Get the optimization process of all the jobs, which are in effect intermediate (or occasionally final) optimization results.
 java.util.Hashtable<java.lang.String,java.lang.String> getOtherProcessDescriptions()
          get a hashmap of other process descriptions.
 java.lang.String[] getOtherProcessNames()
          get a string array of names of other processes.
 java.util.Hashtable<java.lang.String,java.lang.String> getOtherProcessValues()
          get a hashmap of other process values.
 java.lang.String getProcessMessage()
          Get the process message.
 ProcessStatistics getProcessStatistics()
          Get the process statistics.
 java.util.GregorianCalendar getProcessTime()
          Get time of the last process update.
 java.lang.String getRequestAction()
          Get the request action, which can be: ping, notifyJobCompletion, requestJob, getServiceStatistics, setServiceStatistics, getJobStatistics, setJobStatistics, getOptimization, setOptimization, getAll, setAll.
 java.lang.String getRequestDescription()
          Get the request description.
 java.lang.String getResponseDescription()
          Get the response description.
 java.lang.String getResponseStatus()
          Get the response status, which can be: success, error, warning.
 java.lang.String getServiceName()
          Get service name.
 java.lang.String getServiceURI()
          Get service uri.
 double getServiceUtilization()
          Get the service utilization ([0, 1]).
 java.util.GregorianCalendar getTimeLastJobEnded()
          Get the time last job ended.
 double getTimeLastJobTook()
          Get the time last job took (in seconds).
 java.util.GregorianCalendar getTimeServiceStarted()
          Get the time the service started.
 int getTotalJobsSoFar()
          Get the total jobs received so far.
static void main(java.lang.String[] args)
          main for test purposes.
 OSProcess readOSpL(java.lang.String ospl, boolean isFile, boolean validate)
          read an OSpL instance and return and OSProcess object.
 boolean setAvailableDiskSpace(double availableDiskSpace)
          Set the available disk space.
 boolean setAvailableMemory(double availableMemory)
          Set the available memory (in bytes).
 boolean setCurrentJobCount(int currentJobCount)
          Set the current job count.
 boolean setCurrentState(java.lang.String currentState)
          Set the current state.
 boolean setJobStatistics(JobStatistics[] jobStatistics)
          Set the statistics of all jobs.
 boolean setOptimizationProcess(JobOptimization[] optimizationProcess)
          Set the optimization process of all the jobs, which are in effect intermediate (or occasionally final) optimization results.
 boolean setOtherProcesses(java.lang.String[] names, java.lang.String[] descriptions, java.lang.String[] values)
          set other processes, with their names (required), descriptions (optional) and values (optional).
 boolean setProcessMessage(java.lang.String message)
          Set the process message.
 boolean setProcessStatistics(ProcessStatistics processStatistics)
          Set the process statistics.
 boolean setProcessTime(java.util.GregorianCalendar time)
          Set time of the last process update.
 boolean setRequestAction(java.lang.String action)
          Set the request action.
 boolean setRequestDescription(java.lang.String description)
          Set the request description.
 boolean setResponseDescription(java.lang.String description)
          Set the response description.
 boolean setResponseStatus(java.lang.String status)
          Set the response status.
 boolean setServiceName(java.lang.String serviceName)
          Set service name.
 boolean setServiceURI(java.lang.String serviceURI)
          Set service uri.
 boolean setServiceUtilization(double serviceUtilization)
          Set the service utilization.
 boolean setTimeLastJobEnded(java.util.GregorianCalendar timeLastJobEnded)
          Set the time last job ended.
 boolean setTimeLastJobTook(double timeLastJobTook)
          Set the time last job took.
 boolean setTimeServiceStarted(java.util.GregorianCalendar timeServiceStarted)
          Set the time the service started.
 boolean setTotalJobsSoFar(int totalJobsSoFar)
          Set the total jobs received so far.
 java.lang.String writeOSpL()
          write the OSProcess to an ospl xml string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processHeader

public ProcessHeader processHeader
processHeader holds the first child of the OSProcess specified by the OSpL Schema.


processData

public ProcessData processData
processData holds the second child of the OSProcess specified by the OSpL Schema.

Constructor Detail

OSProcess

public OSProcess()
Default constructor.

Method Detail

readOSpL

public OSProcess readOSpL(java.lang.String ospl,
                          boolean isFile,
                          boolean validate)
                   throws java.lang.Exception
read an OSpL instance and return and OSProcess object.

Parameters:
ospl - holds the optimization process in a string which format follows the Optimization Services process Language (OSpL) schema.
isFile - holds whether the ospl string is a file name or a string that literally holds the ospl contents.
validate - holds whether the reader should be validating against the schema or not.
Returns:
the OSProcess object constructed from the OSpL String.
Throws:
java.lang.Exception - if there are errors in reading the string or setting the OSProcess.

writeOSpL

public java.lang.String writeOSpL()
                           throws java.lang.Exception
write the OSProcess to an ospl xml string.

Returns:
the ospl xml string.
Throws:
java.lang.Exception - if there are errors in writing the ospl string.

getRequestAction

public java.lang.String getRequestAction()
Get the request action, which can be: ping, notifyJobCompletion, requestJob, getServiceStatistics, setServiceStatistics, getJobStatistics, setJobStatistics, getOptimization, setOptimization, getAll, setAll.

Returns:
the request action, null or empty string if none.

setRequestAction

public boolean setRequestAction(java.lang.String action)
Set the request action.

Parameters:
action - holds the request action, which can be: ping, notifyJobCompletion, requestJob, getServiceStatistics, setServiceStatistics, getJobStatistics, setJobStatistics, getOptimization, setOptimization, getAll, setAll.
Returns:
whether the requestion action is set successfully.

getRequestDescription

public java.lang.String getRequestDescription()
Get the request description.

Returns:
the request description, null or empty string if none.

setRequestDescription

public boolean setRequestDescription(java.lang.String description)
Set the request description.

Parameters:
description - holds the request description
Returns:
whether the requestion description is set successfully.

getResponseStatus

public java.lang.String getResponseStatus()
Get the response status, which can be: success, error, warning.

Returns:
the response status, null or empty string if none.

setResponseStatus

public boolean setResponseStatus(java.lang.String status)
Set the response status.

Parameters:
status - holds the response status, which can be: success, error, warning.
Returns:
whether the response status is set successfully.

getResponseDescription

public java.lang.String getResponseDescription()
Get the response description.

Returns:
the response description, null or empty string if none.

setResponseDescription

public boolean setResponseDescription(java.lang.String description)
Set the response description.

Parameters:
description - holds the response description
Returns:
whether the response description is set successfully.

getServiceName

public java.lang.String getServiceName()
Get service name.

Returns:
the service name.

setServiceName

public boolean setServiceName(java.lang.String serviceName)
Set service name.

Parameters:
serviceName - holds the name of the service.
Returns:
whether the service name is set successfully.

getServiceURI

public java.lang.String getServiceURI()
Get service uri.

Returns:
the service uri.

setServiceURI

public boolean setServiceURI(java.lang.String serviceURI)
Set service uri.

Parameters:
serviceURI - holds the uri of the service.
Returns:
whether the service uri is set successfully.

getProcessTime

public java.util.GregorianCalendar getProcessTime()
Get time of the last process update.

Returns:
the time of the last process update.

setProcessTime

public boolean setProcessTime(java.util.GregorianCalendar time)
Set time of the last process update.

Parameters:
time - holds the time of the last process update.
Returns:
whether process time is set successfully.

getProcessMessage

public java.lang.String getProcessMessage()
Get the process message.

Returns:
the process message.

setProcessMessage

public boolean setProcessMessage(java.lang.String message)
Set the process message.

Parameters:
message - holds the process message.
Returns:
whether process message is set successfully.

getProcessStatistics

public ProcessStatistics getProcessStatistics()
Get the process statistics.

Returns:
the process statistics.

setProcessStatistics

public boolean setProcessStatistics(ProcessStatistics processStatistics)
Set the process statistics.

Parameters:
processStatistics - holds the process statistics.
Returns:
whether the process statistics is set successfully.

getCurrentState

public java.lang.String getCurrentState()
Get the current state, , which can be: "busy", "busyButAccepting", "idle", "idleButNotAccepting" and "noResponse".

Returns:
the current status, "noResponse" if none.

setCurrentState

public boolean setCurrentState(java.lang.String currentState)
Set the current state.

Parameters:
currentState - holds the current state, which can be: "busy", "busyButAccepting", "idle", "idleButNotAccepting" or "noResponse".
Returns:
whether the current state is set successfully.

getAvailableDiskSpace

public double getAvailableDiskSpace()
Get the available disk space (in bytes).

Returns:
the available disk space, Double.NaN if none.

setAvailableDiskSpace

public boolean setAvailableDiskSpace(double availableDiskSpace)
Set the available disk space.

Parameters:
availableDiskSpace - holds the available disk space (in bytes).
Returns:
whether the available disk space is set successfully.

getAvailableMemory

public double getAvailableMemory()
Get the available memory (in bytes).

Returns:
the available memory, Double.NaN if none.

setAvailableMemory

public boolean setAvailableMemory(double availableMemory)
Set the available memory (in bytes).

Parameters:
availableMemory - holds the available memory.
Returns:
whether the available memory is set successfully.

getCurrentJobCount

public int getCurrentJobCount()
Get the current job count.

Returns:
the current job count, -1 if none.

setCurrentJobCount

public boolean setCurrentJobCount(int currentJobCount)
Set the current job count.

Parameters:
currentJobCount - holds the current job count.
Returns:
whether the current job count is set successfully.

getTotalJobsSoFar

public int getTotalJobsSoFar()
Get the total jobs received so far.

Returns:
the total jobs received so far, -1 if none.

setTotalJobsSoFar

public boolean setTotalJobsSoFar(int totalJobsSoFar)
Set the total jobs received so far.

Parameters:
totalJobsSoFar - holds the total jobs received so far.
Returns:
whether the total jobs so far is set successfully.

getTimeLastJobEnded

public java.util.GregorianCalendar getTimeLastJobEnded()
Get the time last job ended.

Returns:
the time last job ended. If none, it returns unix creation time: GregorianCalendar(1970, 0, 1, 0, 0, 0).

setTimeLastJobEnded

public boolean setTimeLastJobEnded(java.util.GregorianCalendar timeLastJobEnded)
Set the time last job ended.

Parameters:
timeLastJobEnded - holds the time last job ended.
Returns:
whether the time last job ended is set successfully.

getTimeLastJobTook

public double getTimeLastJobTook()
Get the time last job took (in seconds).

Returns:
the the time last job took, Double.NaN if none.

setTimeLastJobTook

public boolean setTimeLastJobTook(double timeLastJobTook)
Set the time last job took.

Parameters:
timeLastJobTook - holds the time last job took (in seconds).
Returns:
whether the time last job took is set successfully.

getTimeServiceStarted

public java.util.GregorianCalendar getTimeServiceStarted()
Get the time the service started.

Returns:
the time last job ended. If none, it returns unix creation time: GregorianCalendar(1970, 0, 1, 0, 0, 0).

setTimeServiceStarted

public boolean setTimeServiceStarted(java.util.GregorianCalendar timeServiceStarted)
Set the time the service started.

Parameters:
timeServiceStarted - holds the time the service started.
Returns:
whether the time the service started is set successfully.

getServiceUtilization

public double getServiceUtilization()
Get the service utilization ([0, 1]).

Returns:
the the time last job took, Double.NaN if none.

setServiceUtilization

public boolean setServiceUtilization(double serviceUtilization)
Set the service utilization.

Parameters:
serviceUtilization - holds the service utilization ([0, 1]).
Returns:
whether the time last job took is set successfully.

getJobStatistics

public JobStatistics[] getJobStatistics()
Get the statistics of all the jobs.

Returns:
the statistics of all the jobs, which is an array of jobStatistics with each member corresponding to one job; null if none.

setJobStatistics

public boolean setJobStatistics(JobStatistics[] jobStatistics)
Set the statistics of all jobs.

Parameters:
jobStatistics - holds an array of jobStatistics with each member corresponding to one job.
Returns:
whether the job statistics are set successfully.

getOptimizationProcess

public JobOptimization[] getOptimizationProcess()
Get the optimization process of all the jobs, which are in effect intermediate (or occasionally final) optimization results. The results follow the standard OSrL (Optimization Services result Language).

Returns:
the optimization process, null if none. It is an array, with each member corresponding to an optimization job. Each optimization job contains a job id string and an optimization result, which data structure follow the OSrL schema.

setOptimizationProcess

public boolean setOptimizationProcess(JobOptimization[] optimizationProcess)
Set the optimization process of all the jobs, which are in effect intermediate (or occasionally final) optimization results. The results follow the standard OSrL (Optimization Services result Language).

Parameters:
optimizationProcess - holds an array, with each member corresponding to an optimization job. Each optimization job contains a job id string and an optimization result, which data structure follow the OSrL schema.
Returns:
whether the optimization process is set successfully.

getOtherProcessNames

public java.lang.String[] getOtherProcessNames()
get a string array of names of other processes.

Returns:
a string array of names of other processes, null if no other processes.

getOtherProcessDescriptions

public java.util.Hashtable<java.lang.String,java.lang.String> getOtherProcessDescriptions()
get a hashmap of other process descriptions. The keys of the hashmap are the process names, and the values of the hashmap are the process descriptions.

Returns:
a hashmap of other process descriptions, null if no other processes.

getOtherProcessValues

public java.util.Hashtable<java.lang.String,java.lang.String> getOtherProcessValues()
get a hashmap of other process values. The keys of the hashmap are the process names, and the values of the hashmap are the process values.

Returns:
a hashmap of other process values, null if no other processes.

setOtherProcesses

public boolean setOtherProcesses(java.lang.String[] names,
                                 java.lang.String[] descriptions,
                                 java.lang.String[] values)
set other processes, with their names (required), descriptions (optional) and values (optional).

Parameters:
names - holds the names of the other processes; it is required.
descriptions - holds the descriptions of the other processes; null if none.
values - holds the values of the other processes; null if none.
Returns:
whether the other anlysis information is set successfully.

main

public static void main(java.lang.String[] args)
main for test purposes.

Parameters:
argv - command line arguments.