org.edg.info
Class InsertableInstance

java.lang.Object
  extended byorg.edg.info.InstanceBase
      extended byorg.edg.info.DeclarableInstance
          extended byorg.edg.info.InsertableInstance
Direct Known Subclasses:
CleanableInstance, FastStreamProducerInstance

public abstract class InsertableInstance
extends DeclarableInstance

Superclass for all producers that have "insertable" behaviour.


Field Summary
 
Fields inherited from class org.edg.info.InstanceBase
DEFAULT_TERMINATION_INTERVAL_MS, s_maxTerminationInterval, s_minTerminationInterval
 
Method Summary
 boolean canDestroy()
          Determines if this insertable can be destroyed.
 void declareAsArchiver()
          Sets the declareAsArchiverFlag to true
 void declareTable(java.lang.String tableName, java.lang.String predicate, int hrpSec, int lrpSec)
          Declares a table with a predicate and history/latest retention period.
 void destroy()
          Tidies up any open resources.
 java.util.HashMap getConsumerConnections()
           
 int getHistoryRetentionPeriod(java.lang.String tableName)
          Gets the HistoryRetentionPeriod.
 long getLastStreamDurationMillis()
           
 int getLatestRetentionPeriod(java.lang.String tableName)
          Gets the LatestRetentionPeriod.
 int getMaxBufferSize()
           
 long getMinRetentionPeriod()
          Deprecated.  
 java.util.HashMap getQueueTracker()
           
 java.util.Hashtable getRetentionPeriods()
           
 long getStreamDurationMillis()
           
 void insert(java.lang.String[] sqlInsert)
          Inserts a number of tuples.
 boolean isAutoInsertTimestampEnabled()
          Returns state of autoInsertTimestamp.
 void setAutoInsertTimestamp(boolean autoInsertTimestampEnabled)
          Sets the autoInsertTimestampEnabled.
 void setMinRetentionPeriod(long minRetentionPeriodMS)
          Deprecated.  
 void startStreaming(org.edg.info.system.StreamRequest request, java.lang.String select, int flags)
          Creates a new socket connection back to the consumer that is making the request and adds this to the list of consumer connections.
 void stopStreaming(org.edg.info.system.StreamRequest request)
          Stops streaming to consumer specified by request.
 void streamTuples()
          Sends pending tuples for all tables in this Producer to all registered Consumers.
 
Methods inherited from class org.edg.info.DeclarableInstance
declareTable, getClientHostName, getProducerType, setClientHostName, undeclareTable, updateRegistry
 
Methods inherited from class org.edg.info.InstanceBase
disconnect, getCreationTimeMillis, getLastRegistryUpdateTimeMillis, getRegistryUpdateIntervalMillis, getResourceId, getStatus, getTerminationInterval, getTerminationIntervalMillis, getUserLastContactTimeMillis, isDestroyed, isTupleCheckingEnabled, notifyRegistrationThread, reconnect, setCloseCalled, setDestroyed, setRegistrationThread, setTerminationInterval, showSignOfLife, updateLastContactTime, wasCloseCalled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setAutoInsertTimestamp

public void setAutoInsertTimestamp(boolean autoInsertTimestampEnabled)
                            throws org.glite.rgma.system.RGMAException
Sets the autoInsertTimestampEnabled.

Parameters:
autoInsertTimestampEnabled - The autoInsertTimestampEnabled to set
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected.

isAutoInsertTimestampEnabled

public boolean isAutoInsertTimestampEnabled()
Returns state of autoInsertTimestamp.

Returns:
boolean
Throws:
org.glite.rgma.system.RGMAException - Thrown if the remote connection fails.

setMinRetentionPeriod

public void setMinRetentionPeriod(long minRetentionPeriodMS)
                           throws org.glite.rgma.system.RGMAException
Deprecated.  

Sets the minRetentionPeriod - minimum time a tuple is held in the queue.

Parameters:
minRetentionPeriodMS - Minimum retention period (in ms).
Throws:
org.glite.rgma.system.RGMAException - Thrown if minRetP < 0 or instance isn't connected

getMinRetentionPeriod

public long getMinRetentionPeriod()
                           throws org.glite.rgma.system.RGMAException
Deprecated.  

Gets the minRetentionPeriod (default is zero).

Returns:
minRetentionPeriod the minimum time that a tuple is held in a queue
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected.

getLatestRetentionPeriod

public int getLatestRetentionPeriod(java.lang.String tableName)
                             throws org.glite.rgma.system.RGMAException
Gets the LatestRetentionPeriod.

Returns:
LatestRetentionPeriod The minimum time for which latest tuples are stored.
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected.

getHistoryRetentionPeriod

public int getHistoryRetentionPeriod(java.lang.String tableName)
                              throws org.glite.rgma.system.RGMAException
Gets the HistoryRetentionPeriod.

Returns:
HistoryRetentionPeriod The minimum time for which history tuples are stored.
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected.

canDestroy

public boolean canDestroy()
Determines if this insertable can be destroyed.

Overrides:
canDestroy in class InstanceBase
Returns:
true if this insertable can be destroyed.

destroy

public void destroy()
Tidies up any open resources. If a retention period has been set, the SPI will still be active until the period expires. This gives the Consumer time to receive published tuples even when the SPI has been closed. If no retention period is defined, the SPI is closed as normal.

Overrides:
destroy in class DeclarableInstance

declareAsArchiver

public void declareAsArchiver()
Sets the declareAsArchiverFlag to true


declareTable

public void declareTable(java.lang.String tableName,
                         java.lang.String predicate,
                         int hrpSec,
                         int lrpSec)
                  throws org.glite.rgma.system.RGMAUserException,
                         org.glite.rgma.system.RGMAInternalException
Declares a table with a predicate and history/latest retention period.

Parameters:
tableName - Name of table to declare
predicate - Predicate (can be empty string)
hrpSec - History retention period (in seconds).
lrpSec - Latest retention period (in seconds).
Throws:
org.glite.rgma.system.RGMAUserException
org.glite.rgma.system.RGMAInternalException

insert

public void insert(java.lang.String[] sqlInsert)
            throws org.glite.rgma.system.RGMAUserException,
                   org.glite.rgma.system.RGMABufferFullException,
                   org.glite.rgma.system.RGMAInternalException
Inserts a number of tuples. Checks SQL for validity and presence of MeasurementDate/Time then calls insert(FastInsertStatement[]). TupleChecking: checks tuples for number of columns (if column names were not provided) or for column names (if these were provided in Insert statement). NB: Assumes that EITHER both MeasurementTime and MeasurementDate are set OR neither is set. Throws an exception if only one is set.

Parameters:
sqlInsert - SQL INSERT statements.
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected, INSERT not valid, table not declared, Schema could not be contacted, error in date/time in Tuple or error in tuple columns.
org.glite.rgma.system.RGMAUserException
org.glite.rgma.system.RGMABufferFullException
org.glite.rgma.system.RGMAInternalException

streamTuples

public void streamTuples()
                  throws org.glite.rgma.system.RGMAInternalException
Sends pending tuples for all tables in this Producer to all registered Consumers.

Throws:
org.glite.rgma.system.RGMAInternalException

startStreaming

public void startStreaming(org.edg.info.system.StreamRequest request,
                           java.lang.String select,
                           int flags)
                    throws org.glite.rgma.system.RGMAUserException,
                           org.glite.rgma.system.RGMAInternalException
Creates a new socket connection back to the consumer that is making the request and adds this to the list of consumer connections.

Parameters:
request - Stream request
select - SQL SELECT statement
flags - Consumer flags
Throws:
org.glite.rgma.system.RGMAException - Thrown if flags aren't valid, aren't CONTINUOUS, if not connected, if SELECT statement is invalid, if table hasn't been declared, or if queue operation fails.
org.glite.rgma.system.RGMAUserException
org.glite.rgma.system.RGMAInternalException

stopStreaming

public void stopStreaming(org.edg.info.system.StreamRequest request)
Stops streaming to consumer specified by request.

Parameters:
request - Stream request
Throws:
org.glite.rgma.system.RGMAException - Thrown if not connected

getMaxBufferSize

public int getMaxBufferSize()
Returns:
Returns the maxBufferSize.

getQueueTracker

public java.util.HashMap getQueueTracker()
Returns:
Returns a copy of the queueTracker.

getRetentionPeriods

public java.util.Hashtable getRetentionPeriods()
Returns:
Returns a copy of the retentionPeriod tracker.

getConsumerConnections

public java.util.HashMap getConsumerConnections()
Returns:
Returns a copy of the tableMapConsumerConnections.

getStreamDurationMillis

public long getStreamDurationMillis()
Returns:
The current duration of the streaming request. If no streaming is being carried out, -1 is returned.

getLastStreamDurationMillis

public long getLastStreamDurationMillis()
Returns:
The duration of the last request.