org.edg.info
Class ConsumerInstance

java.lang.Object
  extended byorg.edg.info.InstanceBase
      extended byorg.edg.info.ConsumerInstance
Direct Known Subclasses:
ContinuousConsumerInstance, OneTimeConsumerInstance

public abstract class ConsumerInstance
extends InstanceBase

The "agent" that serves the Consumer. This class holds state on behalf of the Consumer and contains methods that correspond to the Consumer API. The ConsumerServlet acts as a mediator between the Consumer and ConsumerInstance.


Field Summary
 
Fields inherited from class org.edg.info.InstanceBase
DEFAULT_TERMINATION_INTERVAL_MS, s_maxTerminationInterval, s_minTerminationInterval
 
Method Summary
 void abort()
          Aborts the query.
 boolean canPop()
          Method canPop() checks if any tuples can be popped.
 int count()
          Returns the number of stored tuples.
 void destroy()
          XXX-AC: note, this is called from a syncrhonized block in the instanceTracker.
abstract  void flushQueue(java.lang.String queueName, java.lang.String host)
           
 Message getCurrentMessageInFastQueue()
           
 Message getCurrentMessageInSlowQueue()
           
 long getLastPopTimeMillis()
           
 Message[] getMessagesInFastQueue()
           
 Message[] getMessagesInSlowQueue()
           
 int getNumTuplesInStore()
           
 org.glite.rgma.system.ProducerTableEntryList getProducerTableEntryList()
           
 java.lang.String getQuery()
           
 org.glite.rgma.system.QueryProperties getQueryProperties()
           
 boolean hasAborted()
          Returns a ResultSet containing the state of the aborted flag.
 void incCompletedExecutes()
           
abstract  boolean isExecuting()
          Returns the current status of the executing threads.
 org.glite.rgma.system.ResultSet pop()
          Attempts to pop the number of tuples of the stack.
 org.glite.rgma.system.ResultSet pop(int maxNumTuples)
          Attempts to pop the number of tuples off the stack.
abstract  void setProducerConnections(java.util.Vector servletConnections)
          Sets the list of producer connections for this Consumer to contact and sets isGlobalQuery to false.
 void start(long timeout)
          Will start executing each request.
 void start(long timeout, java.util.Vector servletConnections)
           
 
Methods inherited from class org.edg.info.InstanceBase
canDestroy, disconnect, getLastRegistryUpdateTimeMillis, getRegistryUpdateIntervalMillis, getResourceId, getStatus, getTerminationInterval, getTerminationIntervalMillis, getUserLastContactTimeMillis, isDestroyed, isTupleCheckingEnabled, notifyRegistrationThread, reconnect, setCloseCalled, setDestroyed, setRegistrationThread, setTerminationInterval, showSignOfLife, updateLastContactTime, updateRegistry, wasCloseCalled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isExecuting

public abstract boolean isExecuting()
                             throws org.glite.rgma.system.RGMAUserException
Returns the current status of the executing threads.

Returns:
true if any threads are still executing a query, false otherwise.
Throws:
org.glite.rgma.system.RGMAException - if the API has been closed or is disconnected.
org.glite.rgma.system.RGMAUserException

abort

public void abort()
           throws org.glite.rgma.system.RGMAUserException,
                  org.glite.rgma.system.RGMAInternalException
Aborts the query.

Throws:
org.glite.rgma.system.RGMAException - if unable to process the request.
org.glite.rgma.system.RGMAUserException
org.glite.rgma.system.RGMAInternalException

canPop

public boolean canPop()
               throws org.glite.rgma.system.RGMAUserException
Method canPop() checks if any tuples can be popped.

Returns:
true if tuples exist, false otherwise.
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected or by count()
org.glite.rgma.system.RGMAUserException

destroy

public void destroy()
XXX-AC: note, this is called from a syncrhonized block in the instanceTracker.

See Also:
org.edg.info.InstanceBase#destroy().

count

public int count()
          throws org.glite.rgma.system.RGMAUserException
Returns the number of stored tuples.

Returns:
int the number of stored tuples.
Throws:
org.glite.rgma.system.RGMAException - if this InstanceBase Object has been closed.
org.glite.rgma.system.RGMAUserException

hasAborted

public boolean hasAborted()
                   throws org.glite.rgma.system.RGMAUserException
Returns a ResultSet containing the state of the aborted flag.

Returns:
boolean true if any query was aborted, false otherwise.
Throws:
org.glite.rgma.system.RGMAException - if Object has been closed.
org.glite.rgma.system.RGMAUserException

pop

public org.glite.rgma.system.ResultSet pop()
                                    throws org.glite.rgma.system.RGMAUserException
Attempts to pop the number of tuples of the stack.

Returns:
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected, in invalid state or by QueueManager.pop().
org.glite.rgma.system.RGMAUserException

pop

public org.glite.rgma.system.ResultSet pop(int maxNumTuples)
                                    throws org.glite.rgma.system.RGMAUserException
Attempts to pop the number of tuples off the stack.

Parameters:
maxNumTuples - Must be >= 0.
Returns:
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected, in invalid state or by QueueManager.pop().
org.glite.rgma.system.RGMAUserException

start

public void start(long timeout)
           throws org.glite.rgma.system.RGMAUserException,
                  org.glite.rgma.system.RGMAInternalException
Will start executing each request. If the queryType is LATEST/HISTORY, each Producer is contacted and the Consumer query is executed. If the queryType is CONTINUOUS/CONTINUOUS+OLD then streaming is started.

Parameters:
timeout - period (in ms) when the start will be aborted. If this is 0 the start will run indefinately.
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected, already executing, timeout is less than zero or by startXQuery().
org.glite.rgma.system.RGMAUserException
org.glite.rgma.system.RGMAInternalException

incCompletedExecutes

public void incCompletedExecutes()

flushQueue

public abstract void flushQueue(java.lang.String queueName,
                                java.lang.String host)
Parameters:
queueName -
host -

setProducerConnections

public abstract void setProducerConnections(java.util.Vector servletConnections)
Sets the list of producer connections for this Consumer to contact and sets isGlobalQuery to false.

Parameters:
servletConnections - Vector of ServletConnection objects.

start

public void start(long timeout,
                  java.util.Vector servletConnections)
           throws org.glite.rgma.system.RGMAUserException,
                  org.glite.rgma.system.RGMAInternalException
Parameters:
timeout -
servletConnections -
Throws:
org.glite.rgma.system.RGMAException
org.glite.rgma.system.RGMAUserException
org.glite.rgma.system.RGMAInternalException

getQuery

public java.lang.String getQuery()
Returns:
The consumer's query.

getQueryProperties

public org.glite.rgma.system.QueryProperties getQueryProperties()
Returns:
The consumer's query properties.

getNumTuplesInStore

public int getNumTuplesInStore()
Returns:
The current number of tuples stored by the consumer's buffer.

getLastPopTimeMillis

public long getLastPopTimeMillis()
Returns:
Last pop time in milliseconds.

getProducerTableEntryList

public org.glite.rgma.system.ProducerTableEntryList getProducerTableEntryList()
Returns:
A list of producers the consumer is currently using.

getMessagesInFastQueue

public Message[] getMessagesInFastQueue()
Returns:
A list of messages stored in the fast message queue.

getMessagesInSlowQueue

public Message[] getMessagesInSlowQueue()
Returns:
A list of messages stored in the slow message queue.

getCurrentMessageInFastQueue

public Message getCurrentMessageInFastQueue()
Returns:
The current message being sent in the fast queue. Returns null if no message exists.

getCurrentMessageInSlowQueue

public Message getCurrentMessageInSlowQueue()
Returns:
The current message being sent in the slow quue. Returns null if no message exists.