JXTA

net.jxta.impl.meter
Class GenericServiceMonitor

java.lang.Object
  extended by net.jxta.impl.meter.GenericServiceMonitor
All Implemented Interfaces:
ServiceMonitorImpl, ServiceMonitor, Module
Direct Known Subclasses:
EndpointServiceMonitor, RendezvousServiceMonitor, ResolverServiceMonitor, TransportServiceMonitor

public abstract class GenericServiceMonitor
extends Object
implements ServiceMonitorImpl, Module


Field Summary
protected  ServiceMetric cumulativeServiceMetric
           
protected  ServiceMetric[] deltaServiceMetrics
           
protected  ModuleImplAdvertisement implAdvertisement
           
protected  MonitorManager monitorManager
           
protected  long reportRate
           
protected  int reportRateIndex
           
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK
 
Constructor Summary
GenericServiceMonitor()
           
 
Method Summary
 void beginCumulativeReport()
          A request for a cumulative Report(s) are coming, prepare to receive them
 void beginPulse(ServiceMonitorPulseInfo pulseInfo)
           
protected abstract  ServiceMetric collectServiceMetrics()
          Get the service metrics accrued since the last pulse
protected  ServiceMetric createServiceMetric()
           
 ServiceMonitorFilter createSupportedCumulativeServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter)
          Transform the provided ServiceMonitorFilter into one that is supported for cumulative reporting
 ServiceMonitorFilter createSupportedServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter, long reportRate)
          Transform the provided ServiceMonitorFilter into one that is supported for periodic reporting at the specified rate
 void destroy()
          Clean up.
 void endCumulativeReport()
          Indication that the flurry of requests for cumulative Report is over
 void endPulse(ServiceMonitorPulseInfo pulseInfo)
           
protected  ServiceMetric getCumulativeServiceMetric()
           
 ServiceMetric getCumulativeServiceMetric(ServiceMonitorFilter serviceMonitorFilter, long fromTime, long toTime)
          Get ServiceMetrics since the start (or last reset time) of this ServiceMonitor.
 ModuleClassID getModuleClassID()
          Get ModuleClassID of this ServiceMonitor
 PeerGroup getPeerGroup()
           
 ServiceMetric getServiceMetric(ServiceMonitorFilter serviceMonitorFilter, long fromTime, long toTime, int reportIndex, long reportRate)
          Get ServiceMetrics accrued in during this pulse interval
protected  void init()
           
 void init(MonitorManager monitorManager)
           
 void init(PeerGroup group, ID assignedID, Advertisement advertisement)
          Initialize the module, passing it its peer group and advertisement.
 void resetPulseRate(ServiceMonitorPulseInfo pulseInfo, int oldPulseRateIndex)
           
 void serviceMonitorFilterDeregistered(ServiceMonitorFilter serviceMonitorFilter, int reportRateIndex, long reportRate, boolean retiredRate)
          Information that the Monitor Manager is deregistering the Monitoring for this filter at this rate
 void serviceMonitorFilterRegistered(ServiceMonitorFilter serviceMonitorFilter, int reportRateIndex, long reportRate, boolean newRate)
          Information that the Monitor Manager has accepted a Monitoring for this filter at this rate
 int startApp(String[] args)
          Complete any remaining initialization of the module.
 void stopApp()
          Stop a module.
 void validateCumulativeServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter)
          Validate ServiceMonitorFilter for a cumulative Report
 void validateServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter, long reportRate)
          Validate ServiceMonitorFilter for a periodic Reporting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

monitorManager

protected MonitorManager monitorManager

reportRate

protected long reportRate

reportRateIndex

protected int reportRateIndex

cumulativeServiceMetric

protected ServiceMetric cumulativeServiceMetric

deltaServiceMetrics

protected ServiceMetric[] deltaServiceMetrics

implAdvertisement

protected ModuleImplAdvertisement implAdvertisement
Constructor Detail

GenericServiceMonitor

public GenericServiceMonitor()
Method Detail

init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement advertisement)
Description copied from interface: net.jxta.platform.Module
Initialize the module, passing it its peer group and advertisement.

Note: when subclassing one of the existing PeerGroup implementations (which implement Module), it may not be recommended to overload the init method. See the documentation of the PeerGroup class being subclassed.

Specified by:
init in interface Module
Parameters:
group - The PeerGroup from which this Module can obtain services. If this module is a Service, this is also the PeerGroup of which this module is a service.
assignedID - Identity of Module within group. modules can use it as a the root of their namespace to create names that are unique within the group but predictable by the same module on another peer. This is normally the ModuleClassID which is also the name under which the module is known by other modules. For a group it is the PeerGroupID itself. The parameters of a service, in the Peer configuration, are indexed by the assignedID of that service, and a Service must publish its run-time parameters in the Peer Advertisement under its assigned ID.
advertisement - The implementation advertisement for this Module. It is permissible to pass null if no implementation advertisement is available. This may happen if the implementation was selected by explicit class name rather than by following an implementation advertisement. Modules are not required to support that style of loading, but if they do, then their documentation should mention it.

init

public void init(MonitorManager monitorManager)
Specified by:
init in interface ServiceMonitorImpl

startApp

public int startApp(String[] args)
Description copied from interface: net.jxta.platform.Module
Complete any remaining initialization of the module. The module should be fully functional after startApp() is completed. That is also the opportunity to supply arbitrary arguments (mostly to applications).

If this module is a PeerGroup service, it may be invoked several times depending on its return value.

Specified by:
startApp in interface Module
Parameters:
args - An array of Strings forming the parameters for this Module.
Returns:
int A status indication which may be one of Module.START_OK, Module.START_AGAIN_PROGRESS, Module.START_AGAIN_STALLED, which indicates partial or complete success, or any other value (negative values are recommended for future compatibility), which indicates failure.

stopApp

public void stopApp()
Description copied from interface: net.jxta.platform.Module
Stop a module. This may be called any time after init() completes and should not assume that startApp() has been called or completed.

The Module cannot be forced to comply, but in the future we might be able to deny it access to anything after some timeout.

Specified by:
stopApp in interface Module

init

protected void init()

getModuleClassID

public ModuleClassID getModuleClassID()
Description copied from interface: net.jxta.meter.ServiceMonitor
Get ModuleClassID of this ServiceMonitor

Specified by:
getModuleClassID in interface ServiceMonitor

getPeerGroup

public PeerGroup getPeerGroup()

getCumulativeServiceMetric

protected ServiceMetric getCumulativeServiceMetric()

resetPulseRate

public void resetPulseRate(ServiceMonitorPulseInfo pulseInfo,
                           int oldPulseRateIndex)
Specified by:
resetPulseRate in interface ServiceMonitorImpl

validateCumulativeServiceMonitorFilter

public void validateCumulativeServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter)
Description copied from interface: net.jxta.meter.ServiceMonitor
Validate ServiceMonitorFilter for a cumulative Report

Specified by:
validateCumulativeServiceMonitorFilter in interface ServiceMonitor

createSupportedCumulativeServiceMonitorFilter

public ServiceMonitorFilter createSupportedCumulativeServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter)
Description copied from interface: net.jxta.meter.ServiceMonitor
Transform the provided ServiceMonitorFilter into one that is supported for cumulative reporting

Specified by:
createSupportedCumulativeServiceMonitorFilter in interface ServiceMonitor

validateServiceMonitorFilter

public void validateServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter,
                                         long reportRate)
Description copied from interface: net.jxta.meter.ServiceMonitor
Validate ServiceMonitorFilter for a periodic Reporting

Specified by:
validateServiceMonitorFilter in interface ServiceMonitor

createSupportedServiceMonitorFilter

public ServiceMonitorFilter createSupportedServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter,
                                                                long reportRate)
Description copied from interface: net.jxta.meter.ServiceMonitor
Transform the provided ServiceMonitorFilter into one that is supported for periodic reporting at the specified rate

Specified by:
createSupportedServiceMonitorFilter in interface ServiceMonitor

createServiceMetric

protected ServiceMetric createServiceMetric()

collectServiceMetrics

protected abstract ServiceMetric collectServiceMetrics()
Get the service metrics accrued since the last pulse

Returns:
null if there were no metrices since the last call

beginPulse

public void beginPulse(ServiceMonitorPulseInfo pulseInfo)
Specified by:
beginPulse in interface ServiceMonitorImpl

endPulse

public void endPulse(ServiceMonitorPulseInfo pulseInfo)
Specified by:
endPulse in interface ServiceMonitorImpl

beginCumulativeReport

public void beginCumulativeReport()
Description copied from interface: net.jxta.meter.ServiceMonitor
A request for a cumulative Report(s) are coming, prepare to receive them

Specified by:
beginCumulativeReport in interface ServiceMonitor
See Also:
ServiceMonitor.endCumulativeReport()

endCumulativeReport

public void endCumulativeReport()
Description copied from interface: net.jxta.meter.ServiceMonitor
Indication that the flurry of requests for cumulative Report is over

Specified by:
endCumulativeReport in interface ServiceMonitor
See Also:
ServiceMonitor.beginCumulativeReport()

getServiceMetric

public ServiceMetric getServiceMetric(ServiceMonitorFilter serviceMonitorFilter,
                                      long fromTime,
                                      long toTime,
                                      int reportIndex,
                                      long reportRate)
Description copied from interface: net.jxta.meter.ServiceMonitor
Get ServiceMetrics accrued in during this pulse interval

Specified by:
getServiceMetric in interface ServiceMonitor
Parameters:
serviceMonitorFilter - Filter Metrics based upon this MonitorFilter
fromTime - Beginning time as determined by the MonitorManager
toTime - Ending time as determined by the MonitorManager
reportIndex - Pulse Index of the reporting rate Pyramid
reportRate - Reporting Rate (corresponding to the PulseNumber's index)

getCumulativeServiceMetric

public ServiceMetric getCumulativeServiceMetric(ServiceMonitorFilter serviceMonitorFilter,
                                                long fromTime,
                                                long toTime)
Description copied from interface: net.jxta.meter.ServiceMonitor
Get ServiceMetrics since the start (or last reset time) of this ServiceMonitor. Calls to this will only occurr between calls to beginCumulativeReport() and endCumulativeReport()

Specified by:
getCumulativeServiceMetric in interface ServiceMonitor
Parameters:
serviceMonitorFilter - Filter Metrics based upon this MonitorFilter
fromTime - Beginning time as determined by the MonitorManager
toTime - Ending time as determined by the MonitorManager
See Also:
ServiceMonitor.beginCumulativeReport(), ServiceMonitor.endCumulativeReport()

serviceMonitorFilterRegistered

public void serviceMonitorFilterRegistered(ServiceMonitorFilter serviceMonitorFilter,
                                           int reportRateIndex,
                                           long reportRate,
                                           boolean newRate)
Description copied from interface: net.jxta.meter.ServiceMonitor
Information that the Monitor Manager has accepted a Monitoring for this filter at this rate

Specified by:
serviceMonitorFilterRegistered in interface ServiceMonitor
Parameters:
serviceMonitorFilter - Accepted Filter
reportRateIndex - Pulse Index into pyramid of accepted rate
reportRate - Accepted reporting rate
newRate - Is this a new reporting rate (ie you don't have any currently registered at this rate)

serviceMonitorFilterDeregistered

public void serviceMonitorFilterDeregistered(ServiceMonitorFilter serviceMonitorFilter,
                                             int reportRateIndex,
                                             long reportRate,
                                             boolean retiredRate)
Description copied from interface: net.jxta.meter.ServiceMonitor
Information that the Monitor Manager is deregistering the Monitoring for this filter at this rate

Specified by:
serviceMonitorFilterDeregistered in interface ServiceMonitor
Parameters:
serviceMonitorFilter - Deregistered Filter
reportRateIndex - Pulse Index into pyramid of deregistered filter
reportRate - Reporting rate of deregistered filter
retiredRate - Is this a retired filter the last one registered at this rate (ie you don't have to keep metrics for this rate any longer)

destroy

public void destroy()
Description copied from interface: net.jxta.meter.ServiceMonitor
Clean up. The PeerGroup is probably about to be destroyed

Specified by:
destroy in interface ServiceMonitor

JXSE