com.espertech.esper.epl.variable
Interface VariableService

All Known Implementing Classes:
VariableServiceImpl

public interface VariableService

Variables service for reading and writing variables, and for setting a version number for the current thread to consider variables for.

See implementation class for further details.


Field Summary
static int NOCONTEXT_AGENTINSTANCEID
           
 
Method Summary
 void allocateVariableState(java.lang.String variableName, int agentInstanceId, StatementExtensionSvcContext extensionServicesContext)
           
 void checkAndWrite(java.lang.String variableName, int agentInstanceId, java.lang.Object newValue)
          Check type of the value supplied and writes the new variable value.
 void commit()
          Commits the variable outstanding changes.
 void createNewVariable(java.lang.String optionalContextName, java.lang.String variableName, java.lang.String type, boolean constant, boolean array, boolean arrayOfPrimitive, java.lang.Object value, EngineImportService engineImportService)
          Creates a new variable.
 void deallocateVariableState(java.lang.String variableName, int agentInstanceId)
           
 void destroy()
           
 VariableReader getReader(java.lang.String variableName, int agentInstanceIdAccessor)
          Returns a reader that provides access to variable values.
 java.util.concurrent.ConcurrentHashMap<java.lang.Integer,VariableReader> getReadersPerCP(java.lang.String variableName)
           
 java.util.concurrent.locks.ReadWriteLock getReadWriteLock()
          Lock for use in atomic writes to the variable space.
 VariableMetaData getVariableMetaData(java.lang.String variableName)
           
 java.util.Map<java.lang.String,VariableReader> getVariableReadersNonCP()
          Returns a map of variable name and reader, for thread-safe iteration.
 java.lang.String isContextVariable(java.lang.String propertyName)
           
 void registerCallback(java.lang.String variableName, int agentInstanceId, VariableChangeCallback variableChangeCallback)
          Registers a callback invoked when the variable is written with a new value.
 void removeVariableIfFound(java.lang.String name)
          Removes a variable.
 void rollback()
          Rolls back the variable outstanding changes.
 void setLocalVersion()
          Sets the variable version that subsequent reads consider.
 void unregisterCallback(java.lang.String variableName, int agentInstanceId, VariableChangeCallback variableChangeCallback)
          Removes a callback.
 void write(int variableNumber, int agentInstanceId, java.lang.Object newValue)
          Writes a new variable value.
 

Field Detail

NOCONTEXT_AGENTINSTANCEID

static final int NOCONTEXT_AGENTINSTANCEID
See Also:
Constant Field Values
Method Detail

setLocalVersion

void setLocalVersion()
Sets the variable version that subsequent reads consider.


getReadWriteLock

java.util.concurrent.locks.ReadWriteLock getReadWriteLock()
Lock for use in atomic writes to the variable space.

Returns:
read write lock for external coordinated write

createNewVariable

void createNewVariable(java.lang.String optionalContextName,
                       java.lang.String variableName,
                       java.lang.String type,
                       boolean constant,
                       boolean array,
                       boolean arrayOfPrimitive,
                       java.lang.Object value,
                       EngineImportService engineImportService)
                       throws VariableExistsException,
                              VariableTypeException
Creates a new variable.

Parameters:
variableName - name of the variable
type - variable type
Throws:
VariableExistsException - if the variable name is already in use
VariableTypeException - if the variable type cannot be recognized

getReader

VariableReader getReader(java.lang.String variableName,
                         int agentInstanceIdAccessor)
Returns a reader that provides access to variable values. The reader considers the version currently set via setLocalVersion.

Parameters:
variableName - the variable that the reader should read
Returns:
reader

registerCallback

void registerCallback(java.lang.String variableName,
                      int agentInstanceId,
                      VariableChangeCallback variableChangeCallback)
Registers a callback invoked when the variable is written with a new value.

Parameters:
variableChangeCallback - a callback

unregisterCallback

void unregisterCallback(java.lang.String variableName,
                        int agentInstanceId,
                        VariableChangeCallback variableChangeCallback)
Removes a callback.

Parameters:
variableChangeCallback - a callback

write

void write(int variableNumber,
           int agentInstanceId,
           java.lang.Object newValue)
Writes a new variable value.

Must be followed by either a commit or rollback.

Parameters:
variableNumber - the index number of the variable to write (from VariableReader)
newValue - the new value

checkAndWrite

void checkAndWrite(java.lang.String variableName,
                   int agentInstanceId,
                   java.lang.Object newValue)
Check type of the value supplied and writes the new variable value.

Must be followed by either a commit or rollback.

Parameters:
newValue - the new value

commit

void commit()
Commits the variable outstanding changes.


rollback

void rollback()
Rolls back the variable outstanding changes.


getVariableReadersNonCP

java.util.Map<java.lang.String,VariableReader> getVariableReadersNonCP()
Returns a map of variable name and reader, for thread-safe iteration.

Returns:
variable names and readers

getVariableMetaData

VariableMetaData getVariableMetaData(java.lang.String variableName)

removeVariableIfFound

void removeVariableIfFound(java.lang.String name)
Removes a variable.

Parameters:
name - to remove

destroy

void destroy()

isContextVariable

java.lang.String isContextVariable(java.lang.String propertyName)

allocateVariableState

void allocateVariableState(java.lang.String variableName,
                           int agentInstanceId,
                           StatementExtensionSvcContext extensionServicesContext)

deallocateVariableState

void deallocateVariableState(java.lang.String variableName,
                             int agentInstanceId)

getReadersPerCP

java.util.concurrent.ConcurrentHashMap<java.lang.Integer,VariableReader> getReadersPerCP(java.lang.String variableName)

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com