com.espertech.esper.view.stream
Class StreamFactorySvcImpl

java.lang.Object
  extended by com.espertech.esper.view.stream.StreamFactorySvcImpl
All Implemented Interfaces:
StreamFactoryService

public class StreamFactorySvcImpl
extends java.lang.Object
implements StreamFactoryService

Service implementation to reuse or not reuse event streams and existing filters depending on the type of statement.

For non-join statements, the class manages the reuse of event streams when filters match, and thus when an event stream is reused such can be the views under the stream. For joins however, this can lead to problems in multithread-safety since the statement resource lock would then have to be multiple locks, i.e. the reused statement's resource lock and the join statement's own lock, at a minimum.

For join statements, always creating a new event stream and therefore not reusing view resources, for use with joins.

This can be very effective in that if a client applications creates a large number of very similar statements in terms of filters and views used then these resources are all re-used across statements.

The re-use is multithread-safe in that (A) statement start/stop is locked against other engine processing (B) the first statement supplies the lock for shared filters and views, protecting multiple threads from entering into the same view. (C) joins statements do not participate in filter and view reuse


Constructor Summary
StreamFactorySvcImpl(java.lang.String engineURI, boolean isReuseViews)
          Ctor.
 
Method Summary
 Pair<EventStream,StatementAgentInstanceLock> createStream(java.lang.String statementId, FilterSpecCompiled filterSpec, FilterService filterService, EPStatementAgentInstanceHandle epStatementAgentInstanceHandle, boolean isJoin, ExprEvaluatorContext exprEvaluatorContext, boolean hasOrderBy, boolean filterWithSameTypeSubselect, java.lang.annotation.Annotation[] annotations, boolean stateless, int streamNum, boolean isCanIterateUnbound)
          See the method of the same name in StreamFactoryService.
 void destroy()
          Destroy the service.
 void dropStream(FilterSpecCompiled filterSpec, FilterService filterService, boolean isJoin, boolean hasOrderBy, boolean filterWithSameTypeSubselect, boolean stateless)
          See the method of the same name in StreamFactoryService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamFactorySvcImpl

public StreamFactorySvcImpl(java.lang.String engineURI,
                            boolean isReuseViews)
Ctor.

Parameters:
isReuseViews - indicator on whether stream and view resources are to be reused between statements
Method Detail

destroy

public void destroy()
Description copied from interface: StreamFactoryService
Destroy the service.

Specified by:
destroy in interface StreamFactoryService

createStream

public Pair<EventStream,StatementAgentInstanceLock> createStream(java.lang.String statementId,
                                                                 FilterSpecCompiled filterSpec,
                                                                 FilterService filterService,
                                                                 EPStatementAgentInstanceHandle epStatementAgentInstanceHandle,
                                                                 boolean isJoin,
                                                                 ExprEvaluatorContext exprEvaluatorContext,
                                                                 boolean hasOrderBy,
                                                                 boolean filterWithSameTypeSubselect,
                                                                 java.lang.annotation.Annotation[] annotations,
                                                                 boolean stateless,
                                                                 int streamNum,
                                                                 boolean isCanIterateUnbound)
See the method of the same name in StreamFactoryService. Always attempts to reuse an existing event stream. May thus return a new event stream or an existing event stream depending on whether filter criteria match.

Specified by:
createStream in interface StreamFactoryService
Parameters:
filterSpec - is the filter definition
epStatementAgentInstanceHandle - is the statement resource lock
statementId - the statement id
filterService - filter service to activate filter if not already active
isJoin - is indicatng whether the stream will participate in a join statement, information necessary for stream reuse and multithreading concerns
exprEvaluatorContext - expression evaluation context
hasOrderBy - if the consumer has order-by
Returns:
newly createdStatement event stream, not reusing existing instances

dropStream

public void dropStream(FilterSpecCompiled filterSpec,
                       FilterService filterService,
                       boolean isJoin,
                       boolean hasOrderBy,
                       boolean filterWithSameTypeSubselect,
                       boolean stateless)
See the method of the same name in StreamFactoryService.

Specified by:
dropStream in interface StreamFactoryService
Parameters:
filterSpec - is the filter definition
filterService - to be used to deactivate filter when the last event stream is dropped
isJoin - is indicatng whether the stream will participate in a join statement, information necessary for stream reuse and multithreading concerns
hasOrderBy - if the consumer has an order-by clause

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