java.lang.Object
com.espertech.esper.runtime.internal.kernel.service.EPRuntimeImpl
All Implemented Interfaces:
EPRuntime, EPRuntimeSPI

public class EPRuntimeImpl extends Object implements EPRuntimeSPI
Service provider encapsulates the runtime's services for runtime and administration interfaces.
  • Constructor Details

    • EPRuntimeImpl

      public EPRuntimeImpl(com.espertech.esper.common.client.configuration.Configuration configuration, String runtimeURI, Map<String,EPRuntimeSPI> runtimes, EPRuntimeOptions options) throws com.espertech.esper.common.client.configuration.ConfigurationException
      Constructor - initializes services.
      Parameters:
      configuration - is the runtimeconfiguration
      runtimeURI - is the runtime URI or "default" (or null which it assumes as "default") if this is the default provider
      runtimes - map of URI and runtime
      options - runtime options or null when not provided
      Throws:
      com.espertech.esper.common.client.configuration.ConfigurationException - is thrown to indicate a configuraton error
  • Method Details

    • postInitialize

      public void postInitialize()
      Invoked after an initialize operation.
      Specified by:
      postInitialize in interface EPRuntimeSPI
    • setConfiguration

      public void setConfiguration(com.espertech.esper.common.client.configuration.Configuration configuration)
      Sets runtime configuration information for use in the next initialize.
      Specified by:
      setConfiguration in interface EPRuntimeSPI
      Parameters:
      configuration - is the runtimeconfigs
    • getURI

      public String getURI()
      Description copied from interface: EPRuntime
      Returns the runtime URI, or "default" if this is the default runtime.
      Specified by:
      getURI in interface EPRuntime
      Returns:
      runtime URI
    • getEventService

      public EPEventService getEventService()
      Description copied from interface: EPRuntime
      Returns the event service, for sending events to the runtime and for controlling time
      Specified by:
      getEventService in interface EPRuntime
      Returns:
      event service
    • getDeploymentService

      public EPDeploymentService getDeploymentService()
      Description copied from interface: EPRuntime
      Returns the deployment service, for deploying and undeploying compiled modules
      Specified by:
      getDeploymentService in interface EPRuntime
      Returns:
      deployment service
    • getStageService

      public EPStageService getStageService() throws EPRuntimeDestroyedException
      Description copied from interface: EPRuntime
      Returns the stage service, for managing stages
      Specified by:
      getStageService in interface EPRuntime
      Returns:
      stage service
      Throws:
      EPRuntimeDestroyedException - thrown when the runtime has been destroyed
    • getServicesContext

      public EPServicesContext getServicesContext()
      Specified by:
      getServicesContext in interface EPRuntimeSPI
    • getConfigurationDeepCopy

      public com.espertech.esper.common.client.configuration.Configuration getConfigurationDeepCopy()
      Description copied from interface: EPRuntime
      Returns a deep-copy of the configuration that is actively in use by the runtime.

      Note: This can be an expensive operation.

      Specified by:
      getConfigurationDeepCopy in interface EPRuntime
      Returns:
      deep copy of the configuration
    • getConfigurationTransient

      public Map<String,Object> getConfigurationTransient()
      Description copied from interface: EPRuntime
      Returns the transient configuration, which are configuration values that are passed by reference (and not by value)
      Specified by:
      getConfigurationTransient in interface EPRuntime
      Returns:
      transient configuration
    • destroy

      public void destroy()
      Description copied from interface: EPRuntime
      Destroys the runtime.

      Releases any resources held by the runtime. The runtime enteres a state in which operations provided by the runtime are not guaranteed to operate properly.

      Removes the runtime URI from the known URIs. Allows configuration to change for the instance.

      When destroying a runtime your application must make sure that threads that are sending events into the runtime have completed their work. More generally, the runtime should not be currently in use during or after the destroy operation.

      Specified by:
      destroy in interface EPRuntime
    • isDestroyed

      public boolean isDestroyed()
      Description copied from interface: EPRuntime
      Returns true if the runtime is in destroyed state, or false if not.
      Specified by:
      isDestroyed in interface EPRuntime
      Returns:
      indicator whether the runtime has been destroyed
    • initialize

      public void initialize()
      Description copied from interface: EPRuntime
      Frees any resources associated with this runtime instance, and leaves the runtime instance ready for further use.

      Do not use the EPDeploymentService administrative and EPEventService runtime instances obtained before the initialize (including related services such as configuration, module management, etc.). Your application must obtain new administrative and runtime instances.

      Retains the existing configuration of the runtime instance but forgets any runtime configuration changes.

      Stops and destroys any existing statement resources such as filters, patterns, expressions, views.

      Specified by:
      initialize in interface EPRuntime
    • initialize

      public void initialize(Consumer<EPRuntimeSPIRunAfterDestroyCtx> runAfterDestroy)
      Specified by:
      initialize in interface EPRuntimeSPI
    • initialize

      public void initialize(Long currentTime)
      Specified by:
      initialize in interface EPRuntimeSPI
    • doInitialize

      protected void doInitialize(Long startTime, EPRuntimeOptions options, Consumer<EPRuntimeSPIRunAfterDestroyCtx> runAfterDestroy)
      Performs the initialization.
      Parameters:
      startTime - optional start time
      options - runtime options or null when not provided
      runAfterDestroy - consumer to execute after destroy
    • getContext

      public Context getContext()
      Description copied from interface: EPRuntime
      Provides naming context for public named objects.

      An extension point designed for use by input and output adapters as well as other extension services.

      Specified by:
      getContext in interface EPRuntime
      Returns:
      naming context providing name-to-object bindings
    • getRuntimeInstanceWideLock

      public ReadWriteLock getRuntimeInstanceWideLock()
      Description copied from interface: EPRuntime
      Returns the runtime-instance global read-write lock. The send-event methods takes a read lock. The EPDeploymentService.deploy(EPCompiled) and EPDeploymentService.undeploy(String) methods take a write lock.
      Specified by:
      getRuntimeInstanceWideLock in interface EPRuntime
      Returns:
      runtime instance global read-write lock
    • getServiceStatusProvider

      public AtomicBoolean getServiceStatusProvider()
      Specified by:
      getServiceStatusProvider in interface EPRuntimeSPI
    • addRuntimeStateListener

      public void addRuntimeStateListener(EPRuntimeStateListener listener)
      Description copied from interface: EPRuntime
      Add a listener to runtime state changes that receives a before-destroy event. The listener collection applies set-semantics.
      Specified by:
      addRuntimeStateListener in interface EPRuntime
      Parameters:
      listener - to add
    • removeRuntimeStateListener

      public boolean removeRuntimeStateListener(EPRuntimeStateListener listener)
      Description copied from interface: EPRuntime
      Removate a listener to runtime state changes.
      Specified by:
      removeRuntimeStateListener in interface EPRuntime
      Parameters:
      listener - to remove
      Returns:
      true to indicate the listener was removed, or fals
    • getEventServiceSPI

      public EPEventServiceSPI getEventServiceSPI()
      Specified by:
      getEventServiceSPI in interface EPRuntimeSPI
    • removeAllRuntimeStateListeners

      public void removeAllRuntimeStateListeners()
      Description copied from interface: EPRuntime
      Remove all listeners to runtime state changes.
      Specified by:
      removeAllRuntimeStateListeners in interface EPRuntime
    • getDataFlowService

      public com.espertech.esper.common.client.dataflow.core.EPDataFlowService getDataFlowService()
      Description copied from interface: EPRuntime
      Returns the data flow service, for managing dataflows
      Specified by:
      getDataFlowService in interface EPRuntime
      Returns:
      data flow service
    • getContextPartitionService

      public com.espertech.esper.common.client.context.EPContextPartitionService getContextPartitionService()
      Description copied from interface: EPRuntime
      Returns the context partition service, for context partition information
      Specified by:
      getContextPartitionService in interface EPRuntime
      Returns:
      context partition service
    • getVariableService

      public com.espertech.esper.common.client.variable.EPVariableService getVariableService()
      Description copied from interface: EPRuntime
      Returns the variable service, for reading and writing variables
      Specified by:
      getVariableService in interface EPRuntime
      Returns:
      variable service
    • getMetricsService

      public com.espertech.esper.common.client.metric.EPMetricsService getMetricsService()
      Description copied from interface: EPRuntime
      Returns the metrics service, for managing runtime and statement metrics reporting
      Specified by:
      getMetricsService in interface EPRuntime
      Returns:
      metrics service
    • getEventTypeService

      public EPEventTypeService getEventTypeService()
      Description copied from interface: EPRuntime
      Returns the event type service, for obtaining information on event types
      Specified by:
      getEventTypeService in interface EPRuntime
      Returns:
      event type service
    • getRenderEventService

      public com.espertech.esper.common.client.render.EPRenderEventService getRenderEventService()
      Description copied from interface: EPRuntime
      Returns the event rendering service, for rendering events to JSON and XML
      Specified by:
      getRenderEventService in interface EPRuntime
      Returns:
      render event service
    • getFireAndForgetService

      public EPFireAndForgetService getFireAndForgetService()
      Description copied from interface: EPRuntime
      Returns the fire-and-forget service, for executing fire-and-forget queries
      Specified by:
      getFireAndForgetService in interface EPRuntime
      Returns:
      fire-and-forget service
    • getThreadingService

      public ThreadingService getThreadingService()
      Specified by:
      getThreadingService in interface EPRuntimeSPI
    • getRuntimePath

      public com.espertech.esper.common.client.EPCompilerPathable getRuntimePath()
      Description copied from interface: EPRuntime
      Returns a path object for use by the compiler that represents a snapshot of the EPL objects deployed into the runtime at the time of this call. The EPL objects deployed after a call to this method are not included.
      Specified by:
      getRuntimePath in interface EPRuntime
      Returns:
      path
    • traverseStatements

      public void traverseStatements(BiConsumer<EPDeployment,EPStatement> consumer)
      Specified by:
      traverseStatements in interface EPRuntimeSPI
    • getStatementSelectionSvc

      public EPRuntimeStatementSelectionSPI getStatementSelectionSvc()
      Specified by:
      getStatementSelectionSvc in interface EPRuntimeSPI
    • getReflectiveCompileSvc

      public EPRuntimeCompileReflectiveSPI getReflectiveCompileSvc()
      Specified by:
      getReflectiveCompileSvc in interface EPRuntimeSPI