Class AssemblyLinePool


  • public final class AssemblyLinePool
    extends java.lang.Object
    This class implements a pool of AssemblyLines. The purpose of this pool is to make using AssemblyLines more efficient by re-using AssemblyLine objects. This pool is especially useful when Server mode Connectors are used in an AssemblyLine. By configuring a pool of AssemblyLines it is possible to speed up the processing of requests directed at a Server mode Connector, because each request can be serviced by a different AssesmblyLine from the pool. Moreover when a request has been processed by an AssemblyLine object that object does not have to terminate (thus wasting system resources on AssemblyLine termination) but is returned to the pool to be used for servicing other requests.
    • Constructor Detail

      • AssemblyLinePool

        public AssemblyLinePool​(java.lang.String assemblyLine,
                                Log log,
                                RSInterface parent,
                                AssemblyLineConfig alConfig)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • AssemblyLinePool

        public AssemblyLinePool​(java.lang.String assemblyLine,
                                Log log,
                                RSInterface parent,
                                AssemblyLineConfig alConfig,
                                int debugPort)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • AssemblyLinePool

        public AssemblyLinePool​(java.lang.String assemblyLine,
                                Log log,
                                RSInterface parent,
                                AssemblyLineConfig alConfig,
                                java.lang.String debugHost,
                                int debugPort,
                                boolean debugOnError,
                                java.util.Map<java.lang.String,​java.lang.Boolean> componentDebugModes)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • startThread

        public AssemblyLinePool.ALWorker startThread​(java.lang.String name,
                                                     ConnectorInterface iterator)
                                              throws java.lang.Exception
        Starts a new thread with the provided Iterator. This method is typically called from the AssemblyLine containing a Server mode connector. The server mode connector returns a connector interface that is used to handle a "client" request of some kind. The thread started will insert the connector as the sole iterator and drive the AssemblyLine instance until the connector returns EOF.
        Throws:
        java.lang.Exception
      • startThread

        public AssemblyLinePool.ALWorker startThread​(java.lang.String name,
                                                     ConnectorConfig config)
                                              throws java.lang.Exception
        Starts a new thread with the provided connector config. This method is typically called when a server mode connector is being started in its own thread.
        Throws:
        java.lang.Exception
      • startThread

        public AssemblyLinePool.ALWorker startThread​(java.lang.String name,
                                                     Entry workEntry)
                                              throws java.lang.Exception
        Starts a new thread with the provided work entry. This method is typically called to execute an AL instance with a single work entry.
        Throws:
        java.lang.Exception
      • releaseAssemblyLine

        public void releaseAssemblyLine​(java.lang.Thread owner)
        Called by a thread to release its reserved AssemblyLine instance.
        Parameters:
        owner - The Thread object that previously called executeEvent)
      • getConnectorPoolTimeout

        public long getConnectorPoolTimeout()
        Returns the connector pool timeout in milliseconds.
      • setConnectorPoolTimeout

        public void setConnectorPoolTimeout​(long connectorPoolTimeout)
        Sets the connector pool timeout in milliseconds.
      • runtimeConnectorTypeExcluded

        public boolean runtimeConnectorTypeExcluded​(ConnectorInterface connector)
        Returns true if the connector type is excluded from pooling.
      • hasRunningThreads

        public boolean hasRunningThreads()
        Returns true if there are active eventhandlers using this ALPool as interceptor.
      • executeEvent

        public Entry executeEvent​(java.lang.Thread source,
                                  Entry event)
                           throws java.lang.Exception
        Called by a thread to execute a cycle in the AssemblyLine
        Parameters:
        source - The caller's thread object
        event - The entry passed as the initial work entry
        Throws:
        java.lang.Exception
      • executeEvent

        public Entry executeEvent​(java.lang.Thread source,
                                  Entry event,
                                  boolean processTCB)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • terminate

        public void terminate()
        Called to block future calls from EventHandlers from executing. When an EH calls this ALPool after this method has completed, an exception is thrown to end the eventhandler.
      • getComponentDebugMode

        public boolean getComponentDebugMode​(java.lang.String componentName)
                                      throws java.lang.Exception
        Query the debug mode of the specified component (Connector or Function Component). May be called by different threads.
        Parameters:
        componentName - The name of the component as it appears in the configuration of the AssemblyLine.
        Returns:
        The debug mode of the component.
        Throws:
        java.lang.Exception - If the component name is invalid.
      • setComponentDebugMode

        public void setComponentDebugMode​(java.lang.String componentName,
                                          boolean debug)
                                   throws java.lang.Exception
        Modify the debug mode of the specified component. May be called by different threads.
        Parameters:
        componentName - The name of the component.
        debug - The new debug mode setting.
        Throws:
        java.lang.Exception - If the component name is invalid.
      • enableDebug

        public void enableDebug​(int port,
                                java.lang.String host,
                                boolean onerror)
                         throws java.lang.Exception
        Configure a debugger. May be called by other threads.
        Parameters:
        port - The TCP port number of the remote debugger client
        host - The host name of the remote debugger client
        onerror - If true breakpoints are disabled except when there is an error.
        Throws:
        java.lang.Exception - If there is already a debugger, if the debugger cannot be initialized or if the Pool size is more than one.
      • disableDebug

        public void disableDebug​(java.lang.Object msg)
        Remove the configured debugger. May be called by other threads.
        Parameters:
        msg - Message to be sent.
      • getActiveAssemblyLines

        public java.util.List<AssemblyLine> getActiveAssemblyLines()