org.globus.mds.aggregator.impl
Class PollingAggregatorSource

java.lang.Object
  extended byorg.globus.mds.aggregator.impl.PollingAggregatorSource
All Implemented Interfaces:
AggregatorSource
Direct Known Subclasses:
ExecutionAggregatorSource, QueryAggregatorSource

public abstract class PollingAggregatorSource
extends java.lang.Object
implements AggregatorSource

An AggregatorSource which generates data using synchronous polling in a background thread. The class is abstract, and requires subclassing to provide the implementation of the poll action.


Nested Class Summary
 class PollingAggregatorSource.QueryTimerListener
          One instance of this class will be created for each aggregation
 
Field Summary
static int DEFAULT_POLL_INTERVAL
           
private  boolean initialized
           
private static org.apache.commons.logging.Log logger
           
private  java.util.Hashtable sessions
          This Map maps from session keys (String instances) to session context (QueryTimerListener instances)
private  AggregatorSink sink
           
private  java.lang.Object sinkParameters
           
private  TimerManagerImpl timerManager
           
 
Constructor Summary
PollingAggregatorSource(AggregatorSink sink)
           
PollingAggregatorSource(AggregatorSink sink, java.lang.Object sinkParameters)
          Creates a new instance of PollingAggregatorSource
 
Method Summary
 java.lang.String addAggregation(java.lang.Object parameters, AggregatorServiceGroupEntryResource entry)
          Establishes an implementation-specific data aggregation session.
abstract  AggregatorPollType deserializeParameter(org.apache.axis.message.MessageElement m)
          If the supplied message element is a supported parameter block, the deserialised form should be returned; otherwise null should be returned.
 AggregatorSink getAggregatorSink()
          Gets the AggregatorSink instance where data from the underlying AggregatorSource will be routed, or NULL if not set.
 AggregatorServiceGroupEntryResource getSessionContext(java.lang.String sessionKey)
          Retrieve AggregatorServiceGroupEntryResource entry context.
 java.lang.String getSessionKey(AggregatorServiceGroupEntryResource entry)
          Get a sessionKey from a given entry context.
 void initialize(java.lang.Object parameters)
          Called to initialize any necessary state.
 boolean isValidSession(java.lang.String sessionKey)
          Determines if a specified sessionKey is valid (active).
abstract  org.apache.axis.encoding.AnyContentType poll(AggregatorPollType parameters, org.apache.axis.message.addressing.EndpointReferenceType epr, AggregatorConfig config)
          This method must be implemented by subclasses to provide the specific specialised poll implementation.
 void removeAggregation(java.lang.String sessionKey)
          Terminates the data aggregation represented by sessionKey.
 void setAggregatorSink(AggregatorSink sink, java.lang.Object sinkParameters)
          Sets the AggregatorSink instance where data from the Aggregator Source will be routed.
 void terminate()
          Called to free resources used by the source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POLL_INTERVAL

public static final int DEFAULT_POLL_INTERVAL
See Also:
Constant Field Values

sink

private AggregatorSink sink

sinkParameters

private java.lang.Object sinkParameters

sessions

private java.util.Hashtable sessions
This Map maps from session keys (String instances) to session context (QueryTimerListener instances)


timerManager

private TimerManagerImpl timerManager

initialized

private boolean initialized

logger

private static org.apache.commons.logging.Log logger
Constructor Detail

PollingAggregatorSource

public PollingAggregatorSource(AggregatorSink sink,
                               java.lang.Object sinkParameters)
Creates a new instance of PollingAggregatorSource


PollingAggregatorSource

public PollingAggregatorSource(AggregatorSink sink)
Method Detail

initialize

public void initialize(java.lang.Object parameters)
                throws AggregatorException,
                       java.lang.Exception
Description copied from interface: AggregatorSource
Called to initialize any necessary state. This method should also attempt to initialize the specified sink and should always throw an exception if the sink is not set. The underlying implementation should throw an AggregatorSinkTypeNotSupportedException if it is not compatible with the supplied AggregationSink. The implementation may use the optional parameters Object to read implementation specific data from or just ignore the processing of it altogether.

Specified by:
initialize in interface AggregatorSource
Throws:
AggregatorException
java.lang.Exception

getSessionContext

public AggregatorServiceGroupEntryResource getSessionContext(java.lang.String sessionKey)
Description copied from interface: AggregatorSource
Retrieve AggregatorServiceGroupEntryResource entry context.

Specified by:
getSessionContext in interface AggregatorSource
Parameters:
sessionKey - The session key of the aggregation.
Returns:
A valid object, or NULL. The type of object returned is dependent on the underlying implementation.

getSessionKey

public java.lang.String getSessionKey(AggregatorServiceGroupEntryResource entry)
                               throws AggregatorException
Description copied from interface: AggregatorSource
Get a sessionKey from a given entry context.

Specified by:
getSessionKey in interface AggregatorSource
Returns:
A string representing the sessionKey for the given entry.
Throws:
AggregatorException

isValidSession

public boolean isValidSession(java.lang.String sessionKey)
                       throws AggregatorException
Description copied from interface: AggregatorSource
Determines if a specified sessionKey is valid (active).

Specified by:
isValidSession in interface AggregatorSource
Returns:
A boolean value indicating whether the specified sessionKey is valid.
Throws:
AggregatorException

getAggregatorSink

public AggregatorSink getAggregatorSink()
Description copied from interface: AggregatorSource
Gets the AggregatorSink instance where data from the underlying AggregatorSource will be routed, or NULL if not set.

Specified by:
getAggregatorSink in interface AggregatorSource

setAggregatorSink

public void setAggregatorSink(AggregatorSink sink,
                              java.lang.Object sinkParameters)
Description copied from interface: AggregatorSource
Sets the AggregatorSink instance where data from the Aggregator Source will be routed.

Specified by:
setAggregatorSink in interface AggregatorSource

addAggregation

public java.lang.String addAggregation(java.lang.Object parameters,
                                       AggregatorServiceGroupEntryResource entry)
                                throws AggregatorParamTypeNotSupportedException,
                                       AggregatorException,
                                       java.lang.Exception
Description copied from interface: AggregatorSource
Establishes an implementation-specific data aggregation session. The method of data collection and consumption is defined by the implementation; the contract of the interface is that any data generated should be capable of being consumed by a class implementing the AggregationSink interface, which will in turn be bound an AggregationSource.

Specified by:
addAggregation in interface AggregatorSource
Parameters:
parameters - Implementation-specific parameters of the data to be collected.
entry - The AggregatorServiceGroupEntryResource instance to associate with this aggregation session. This instance will be passed unmodified to any connected AggregationSink.
Returns:
A session key, which is a String which must be guaranteed by the underlying AggregatorSource implementation to be a unique token with respect to all other invocations of the addAggregation method with the same parameters and entry instance on the same AggregationSource instance. A null return value is not permitted, though the empty string "" is.
An exception MUST be thrown if the aggregation could not be created by the implementation.
Throws:
AggregatorParamTypeNotSupportedException
AggregatorException
java.lang.Exception

removeAggregation

public void removeAggregation(java.lang.String sessionKey)
                       throws AggregatorException,
                              java.lang.Exception
Description copied from interface: AggregatorSource
Terminates the data aggregation represented by sessionKey.

Specified by:
removeAggregation in interface AggregatorSource
Parameters:
sessionKey - The session key of the aggregation to terminate.
Throws:
AggregatorException
java.lang.Exception

terminate

public void terminate()
Description copied from interface: AggregatorSource
Called to free resources used by the source.

Specified by:
terminate in interface AggregatorSource

poll

public abstract org.apache.axis.encoding.AnyContentType poll(AggregatorPollType parameters,
                                                             org.apache.axis.message.addressing.EndpointReferenceType epr,
                                                             AggregatorConfig config)
This method must be implemented by subclasses to provide the specific specialised poll implementation. It will be called by the PollingAggregatorSource implementation every time it is time to poll for data. TODO: this method signature is getting a little messy... tidy up


deserializeParameter

public abstract AggregatorPollType deserializeParameter(org.apache.axis.message.MessageElement m)
                                                 throws DeserializationException
If the supplied message element is a supported parameter block, the deserialised form should be returned; otherwise null should be returned. This method will be invoked on all config parameters supplied to an aggregation until one is found that matches.

Throws:
DeserializationException