org.knowhowlab.osgi.monitoradmin.job
Class AbstractMonitoringJob

java.lang.Object
  extended by org.knowhowlab.osgi.monitoradmin.job.AbstractMonitoringJob
All Implemented Interfaces:
MonitoringJob
Direct Known Subclasses:
ScheduledMonitoringJob, SubscriptionMonitoringJob

public abstract class AbstractMonitoringJob
extends java.lang.Object
implements MonitoringJob

Abstract MonitoringJob

Author:
dmytro.pishchukhin

Field Summary
protected  int count
           
protected  boolean isRunning
           
protected  LogVisitor logVisitor
           
protected  int schedule
           
protected  java.util.Set<java.lang.String> statusVariablePaths
           
protected  MonitoringJobVisitor visitor
           
 
Constructor Summary
protected AbstractMonitoringJob(MonitoringJobVisitor visitor, LogVisitor logVisitor, java.lang.String initiator, java.lang.String[] statusVariablePaths, int count)
           
protected AbstractMonitoringJob(MonitoringJobVisitor visitor, LogVisitor logVisitor, java.lang.String initiator, java.lang.String[] statusVariablePaths, int schedule, int count)
           
 
Method Summary
abstract  void cancel()
          Cancel job internaly
 java.lang.String getInitiator()
          Returns the identifier of the principal who initiated the job.
 int getReportCount()
          Returns the number of times MonitorAdmin will query the StatusVariables (for time based jobs), or the number of changes of a StatusVariable between notifications (for change based jobs).
 int getSchedule()
          Returns the delay (in seconds) between two samples.
 java.lang.String[] getStatusVariableNames()
          Returns the list of StatusVariable names that are the targets of this measurement job.
abstract  void handleUpdateEvent(java.lang.String monitorableId, StatusVariable statusVariable)
          Handle StatusVariable update event
abstract  boolean isHandleUpdateEvent(java.lang.String path)
          Does job handle StatusVariable update event
 boolean isLocal()
          Returns whether the job was started locally or remotely.
 boolean isRunning()
          Returns whether the job is running.
 void stop()
          Stops a Monitoring Job.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

visitor

protected MonitoringJobVisitor visitor

logVisitor

protected LogVisitor logVisitor

statusVariablePaths

protected java.util.Set<java.lang.String> statusVariablePaths

isRunning

protected boolean isRunning

schedule

protected int schedule

count

protected int count
Constructor Detail

AbstractMonitoringJob

protected AbstractMonitoringJob(MonitoringJobVisitor visitor,
                                LogVisitor logVisitor,
                                java.lang.String initiator,
                                java.lang.String[] statusVariablePaths,
                                int schedule,
                                int count)

AbstractMonitoringJob

protected AbstractMonitoringJob(MonitoringJobVisitor visitor,
                                LogVisitor logVisitor,
                                java.lang.String initiator,
                                java.lang.String[] statusVariablePaths,
                                int count)
Method Detail

stop

public void stop()
Description copied from interface: MonitoringJob
Stops a Monitoring Job. Note that a time based job can also stop automatically if the specified number of samples have been taken.

Specified by:
stop in interface MonitoringJob

getInitiator

public java.lang.String getInitiator()
Description copied from interface: MonitoringJob
Returns the identifier of the principal who initiated the job. This is set at the time when MonitorAdmin.startJob() method is called. This string holds the ServerID if the operation was initiated from a remote manager, or an arbitrary ID of the initiator entity in the local case (used for addressing notification events).

Specified by:
getInitiator in interface MonitoringJob
Returns:
the ID of the initiator, cannot be null

getStatusVariableNames

public java.lang.String[] getStatusVariableNames()
Description copied from interface: MonitoringJob
Returns the list of StatusVariable names that are the targets of this measurement job. For time based jobs, the MonitorAdmin will iterate through this list and query all StatusVariables when its timer set by the job's frequency rate expires.

Specified by:
getStatusVariableNames in interface MonitoringJob
Returns:
the target list of the measurement job in [Monitorable_ID]/[StatusVariable_ID] format, cannot be null

getSchedule

public int getSchedule()
Description copied from interface: MonitoringJob
Returns the delay (in seconds) between two samples. If this call returns N (greater than 0) then the MonitorAdmin queries each StatusVariable that belongs to this job every N seconds. The value 0 means that the job is not scheduled but event based: in this case instant notification on changes is requested (at every n-th change of the value, as specified by the report count parameter).

Specified by:
getSchedule in interface MonitoringJob
Returns:
the delay (in seconds) between samples, or 0 for change based jobs

getReportCount

public int getReportCount()
Description copied from interface: MonitoringJob
Returns the number of times MonitorAdmin will query the StatusVariables (for time based jobs), or the number of changes of a StatusVariable between notifications (for change based jobs). Time based jobs with non-zero report count will take getReportCount()*getSchedule() time to finish. Time based jobs with 0 report count and change based jobs do not stop automatically, but all jobs can be stopped with the MonitoringJob.stop() method.

Specified by:
getReportCount in interface MonitoringJob
Returns:
the number of measurements to be taken, or the number of changes between notifications

isLocal

public boolean isLocal()
Description copied from interface: MonitoringJob
Returns whether the job was started locally or remotely. Jobs started by the clients of this API are always local, remote jobs can only be started using the Device Management Tree.

Specified by:
isLocal in interface MonitoringJob
Returns:
true if the job was started from the local device, false if the job was initiated from a management server through the device management tree

isRunning

public boolean isRunning()
Description copied from interface: MonitoringJob
Returns whether the job is running. A job is running until it is explicitly stopped, or, in case of time based jobs with a finite report count, until the given number of measurements have been made.

Specified by:
isRunning in interface MonitoringJob
Returns:
true if the job is still running, false if it has finished

cancel

public abstract void cancel()
Cancel job internaly


isHandleUpdateEvent

public abstract boolean isHandleUpdateEvent(java.lang.String path)
Does job handle StatusVariable update event

Parameters:
path - StatusVariable path
Returns:
true - handles, otherwise - false

handleUpdateEvent

public abstract void handleUpdateEvent(java.lang.String monitorableId,
                                       StatusVariable statusVariable)
Handle StatusVariable update event

Parameters:
monitorableId - monitorableId
statusVariable - statusVariable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2010 Know-How Lab. All Rights Reserved.