public class StatementLifecycleSvcImpl extends Object implements StatementLifecycleSvc
Modifier and Type | Class and Description |
---|---|
static class |
StatementLifecycleSvcImpl.EPStatementDesc
Statement information.
|
Modifier and Type | Field and Description |
---|---|
protected EPServicesContext |
services
Services context for statement lifecycle management.
|
protected Map<Integer,StatementLifecycleSvcImpl.EPStatementDesc> |
stmtIdToDescMap
Maps of statement id to descriptor.
|
protected Map<String,EPStatement> |
stmtNameToStmtMap
Map of statement name to statement.
|
Constructor and Description |
---|
StatementLifecycleSvcImpl(EPServiceProvider epServiceProvider,
EPServicesContext services)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(StatementLifecycleObserver observer)
Add an observer to be called back when statement-state or listener/subscriber changes are registered.
|
protected static StatementSpecCompiled |
compile(StatementSpecRaw spec,
String eplStatement,
StatementContext statementContext,
boolean isSubquery,
boolean isOnDemandQuery,
Annotation[] annotations,
List<ExprSubselectNode> subselectNodes,
List<ExprDeclaredNode> declaredNodes,
Set<ExprTableAccessNode> tableAccessNodes,
EPServicesContext servicesContext)
Compiles a statement returning the compile (verified, non-serializable) form of a statement.
|
static SelectClauseSpecCompiled |
compileSelectAllowSubselect(SelectClauseSpecRaw spec)
Compile a select clause allowing subselects.
|
EPStatement |
createAndStart(StatementSpecRaw statementSpec,
String expression,
boolean isPattern,
String optStatementName,
Object userObject,
EPIsolationUnitServices isolationUnitServices,
Integer optionalStatementId,
EPStatementObjectModel optionalModel)
Create and start the statement.
|
protected StatementLifecycleSvcImpl.EPStatementDesc |
createStopped(StatementSpecRaw statementSpec,
Annotation[] annotations,
String expression,
boolean isPattern,
String statementName,
boolean nameProvided,
int statementId,
Map<String,Object> optAdditionalContext,
Object statementUserObject,
EPIsolationUnitServices isolationUnitServices,
boolean isFailed,
EPStatementObjectModel optionalModel)
Create stopped statement.
|
protected StatementLifecycleSvcImpl.EPStatementDesc |
createStoppedAssignName(StatementSpecRaw statementSpec,
String expression,
boolean isPattern,
String optStatementName,
int statementId,
Map<String,Object> optAdditionalContext,
Object userObject,
EPIsolationUnitServices isolationUnitServices,
EPStatementObjectModel optionalModel)
Creates and starts statement.
|
void |
destroy()
Destroy the service.
|
void |
destroy(int statementId)
Destroy statement by statement id.
|
void |
destroyAllStatements()
Destroys all started statements.
|
protected void |
destroyInternal(StatementLifecycleSvcImpl.EPStatementDesc desc) |
void |
dispatchStatementLifecycleEvent(StatementLifecycleEvent theEvent)
Dispatch event to observers.
|
EPStatementSPI |
getStatementById(int statementId)
Returns the statement given a statement id.
|
EPStatement |
getStatementByName(String name)
Returns the statement by the given name, or null if no such statement exists.
|
StatementContext |
getStatementContextById(int statementId) |
String |
getStatementNameById(int statementId) |
String[] |
getStatementNames()
Returns an array of statement names.
|
StatementSpecCompiled |
getStatementSpec(int statementId) |
Map<String,EPStatement> |
getStmtNameToStmt() |
void |
init()
Initialized the service before use.
|
void |
removeObserver(StatementLifecycleObserver observer)
Remove an observer to be called back when statement-state or listener/subscriber changes are registered.
|
void |
start(int statementId)
Start statement by statement id.
|
void |
start(int statementId,
StatementLifecycleSvcImpl.EPStatementDesc desc,
boolean isNewStatement,
boolean isRecoveringStatement,
boolean isResilient)
Start the given statement.
|
void |
startAllStatements()
Starts all stopped statements.
|
void |
stop(int statementId)
Stop statement by statement id.
|
void |
stopAllStatements()
Stops all started statements.
|
void |
updatedListeners(EPStatement statement,
EPStatementListenerSet listeners,
boolean isRecovery)
Statements indicate that listeners have been added through this method.
|
protected final EPServicesContext services
protected final Map<Integer,StatementLifecycleSvcImpl.EPStatementDesc> stmtIdToDescMap
protected final Map<String,EPStatement> stmtNameToStmtMap
public StatementLifecycleSvcImpl(EPServiceProvider epServiceProvider, EPServicesContext services)
epServiceProvider
- is the engine instance to hand to statement-aware listenersservices
- is engine servicespublic void addObserver(StatementLifecycleObserver observer)
StatementLifecycleSvc
The observers list is backed by a Set.
addObserver
in interface StatementLifecycleSvc
observer
- to addpublic void removeObserver(StatementLifecycleObserver observer)
StatementLifecycleSvc
removeObserver
in interface StatementLifecycleSvc
observer
- to removepublic void destroy()
StatementLifecycleSvc
destroy
in interface StatementLifecycleSvc
public void init()
StatementLifecycleSvc
init
in interface StatementLifecycleSvc
public Map<String,EPStatement> getStmtNameToStmt()
getStmtNameToStmt
in interface StatementLifecycleSvc
public EPStatement createAndStart(StatementSpecRaw statementSpec, String expression, boolean isPattern, String optStatementName, Object userObject, EPIsolationUnitServices isolationUnitServices, Integer optionalStatementId, EPStatementObjectModel optionalModel)
StatementLifecycleSvc
createAndStart
in interface StatementLifecycleSvc
statementSpec
- is the statement definition in bean object form, raw unvalidated and unoptimized.expression
- is the expression textisPattern
- is an indicator on whether this is a pattern statement and thus the iterator must return the last result,
versus for non-pattern statements the iterator returns view content.optStatementName
- is an optional statement name, null if none was supplieduserObject
- the application define user object associated to each statement, if suppliedisolationUnitServices
- isolated service servicesoptionalStatementId
- the statement idoptionalModel
- modelprotected StatementLifecycleSvcImpl.EPStatementDesc createStoppedAssignName(StatementSpecRaw statementSpec, String expression, boolean isPattern, String optStatementName, int statementId, Map<String,Object> optAdditionalContext, Object userObject, EPIsolationUnitServices isolationUnitServices, EPStatementObjectModel optionalModel)
statementSpec
- defines the statementexpression
- is the EPLisPattern
- is true for patternsoptStatementName
- is the optional statement namestatementId
- is the statement idoptAdditionalContext
- additional context for use by the statement contextuserObject
- the application define user object associated to each statement, if suppliedisolationUnitServices
- isolated service servicesoptionalModel
- modelprotected StatementLifecycleSvcImpl.EPStatementDesc createStopped(StatementSpecRaw statementSpec, Annotation[] annotations, String expression, boolean isPattern, String statementName, boolean nameProvided, int statementId, Map<String,Object> optAdditionalContext, Object statementUserObject, EPIsolationUnitServices isolationUnitServices, boolean isFailed, EPStatementObjectModel optionalModel)
statementSpec
- - statement definitionexpression
- is the expression textisPattern
- is true for patterns, false for non-patternsstatementName
- is the statement name assigned or givenstatementId
- is the statement idoptAdditionalContext
- additional context for use by the statement contextstatementUserObject
- the application define user object associated to each statement, if suppliedisolationUnitServices
- isolated service servicesisFailed
- to start the statement in failed statenameProvided
- true when an explicit statement name is providedannotations
- annotationsoptionalModel
- modelpublic void start(int statementId)
StatementLifecycleSvc
start
in interface StatementLifecycleSvc
statementId
- of the statement to start.public void start(int statementId, StatementLifecycleSvcImpl.EPStatementDesc desc, boolean isNewStatement, boolean isRecoveringStatement, boolean isResilient)
statementId
- is the statement iddesc
- is the cached statement infoisNewStatement
- indicator whether the statement is new or a stop-restart statementisRecoveringStatement
- if the statement is recovering or newisResilient
- true if recovering a resilient stmtpublic void stop(int statementId)
StatementLifecycleSvc
stop
in interface StatementLifecycleSvc
statementId
- of the statement to stop.public void destroy(int statementId)
StatementLifecycleSvc
destroy
in interface StatementLifecycleSvc
statementId
- statementId of the statement to destroypublic EPStatement getStatementByName(String name)
StatementLifecycleSvc
getStatementByName
in interface StatementLifecycleSvc
name
- is the statement namepublic StatementSpecCompiled getStatementSpec(int statementId)
getStatementSpec
in interface StatementLifecycleSvc
public EPStatementSPI getStatementById(int statementId)
getStatementById
in interface StatementLifecycleSvc
statementId
- is the statement idpublic StatementContext getStatementContextById(int statementId)
getStatementContextById
in interface StatementLifecycleStmtContextResolver
public String[] getStatementNames()
StatementLifecycleSvc
Only returns started and stopped statements.
getStatementNames
in interface StatementLifecycleSvc
public void startAllStatements() throws EPException
StatementLifecycleSvc
startAllStatements
in interface StatementLifecycleSvc
EPException
- to indicate a start error.public void stopAllStatements() throws EPException
StatementLifecycleSvc
stopAllStatements
in interface StatementLifecycleSvc
EPException
- to indicate a start error.public void destroyAllStatements() throws EPException
StatementLifecycleSvc
destroyAllStatements
in interface StatementLifecycleSvc
EPException
- to indicate a start error.public String getStatementNameById(int statementId)
getStatementNameById
in interface StatementLifecycleSvc
public void updatedListeners(EPStatement statement, EPStatementListenerSet listeners, boolean isRecovery)
StatementLifecycleSvc
updatedListeners
in interface StatementLifecycleSvc
statement
- is the statement for which listeners were addedlisteners
- is the set of listeners after adding the new listenerisRecovery
- indicator whether recoveringprotected static StatementSpecCompiled compile(StatementSpecRaw spec, String eplStatement, StatementContext statementContext, boolean isSubquery, boolean isOnDemandQuery, Annotation[] annotations, List<ExprSubselectNode> subselectNodes, List<ExprDeclaredNode> declaredNodes, Set<ExprTableAccessNode> tableAccessNodes, EPServicesContext servicesContext) throws EPStatementException
spec
- is the statement specificationeplStatement
- the statement to compilestatementContext
- the statement servicesisSubquery
- is true for subquery compilation or false for statement compileannotations
- statement annotationsisOnDemandQuery
- indicator whether on-demand querysubselectNodes
- subselectsdeclaredNodes
- declared expressionstableAccessNodes
- table nodesservicesContext
- servicesEPStatementException
- if the statement cannot be compiledpublic static SelectClauseSpecCompiled compileSelectAllowSubselect(SelectClauseSpecRaw spec) throws ExprValidationException
spec
- to compileExprValidationException
- when validation failsprotected void destroyInternal(StatementLifecycleSvcImpl.EPStatementDesc desc)
public void dispatchStatementLifecycleEvent(StatementLifecycleEvent theEvent)
StatementLifecycleSvc
dispatchStatementLifecycleEvent
in interface StatementLifecycleSvc
theEvent
- to dispatch