Class NodeWorker<N extends Node>

    • Constructor Detail

      • NodeWorker

        public NodeWorker()
    • Method Detail

      • abort

        public final void abort()
        Indicate that any current work should be aborted. Node implementations may not actually support aborting. In this case, the worker will continue its normal work process to its completion.
      • doAbort

        protected void doAbort()
        NodeWorker implementations can provide here own logic that shall be performed when an abort is triggered.
        Since:
        jadice server 5.5.0.0
      • abortNow

        public final void abortNow()
        Indicate that any current work should be aborted ASAP. Calling this method will close all input and output bundles and streams, thereby speeding up the termination.
      • doAbortNow

        protected void doAbortNow()
        NodeWorker implementations can provide here own logic that shall be performed when an immediate abort is triggered.

        jadice server 5.5.0.0

      • getInputBundle

        public final StreamBundle getInputBundle()
        Get the input stream bundle.
        Returns:
        the input bundle associated with this worker
      • getJob

        public final Job getJob()
      • getOutputBundle

        public final StreamBundle getOutputBundle()
        Returns the output stream bundle
        Returns:
        the output bundle associated with this worker
      • initialize

        public void initialize()
                        throws JobException
        This method may be overridden, in order do perform initialization which is necessary before the actual work is started.
        Caveat: this method may be called synchronously by the server master thread. Therefore the work done within this call should be kept to an absolute minimum so as not to stall the job acceptor.
        Throws:
        JobException - in case of initialization failure
      • isAbortRequested

        public final boolean isAbortRequested()
        Returns:
        whether the Node was asked to abort its work.
      • run

        public final void run()
        Specified by:
        run in interface Runnable
      • addInputBundle

        public void addInputBundle​(StreamBundle inputBundle)
        Set the input stream bundle
        Parameters:
        inputBundle - a StreamBundle
      • setDescriptor

        public final void setDescriptor​(N wd)
        Set the Node.
        Parameters:
        wd - the associated Node
      • setJob

        public final void setJob​(ServerJob sb)
        Set the server job.
        Parameters:
        sb - the associated ServerJob
      • addOutputBundle

        public void addOutputBundle​(StreamBundle sb)
        Set the output stream bundle
        Parameters:
        sb - a StreamBundle
      • work

        protected abstract void work()
                              throws Throwable
        Implement this method to let the node perform some useful work.

        Implementors are free to throw whatever exception they see fit. If any Throwable is thrown from this method, the failure manager is notified about the fatal failure of the whole pipeline.

        Throws:
        Throwable - in case of processing failure
      • postWork

        protected void postWork()
                         throws Throwable
        This method is called immediately after work() has returned. It will be called even when a failure in work() has occured.

        Use this method e.g. to finalize objects on the same Thread on which work() is executed.

        Throws:
        Throwable - in case of post processing errors
        See Also:
        work(), preWork()
      • getTransportSender

        protected final com.levigo.jadice.server.shared.transport.internal.TransportSender getTransportSender()
      • fail

        public final void fail​(org.jadice.util.log.qualified.QualifiedLogEvent event)
        Make the worker (and subsequently the node) fail due to the specified reason. This method will always throw a special kind of RuntimeException used to bubble-up the failure information.
        Specified by:
        fail in interface QualifiedLogEventReceiver
        Parameters:
        event - reason why this worker failed
      • fail

        public final void fail​(org.jadice.util.log.qualified.MessageID messageId,
                               Throwable cause,
                               Object... args)
        Make the worker (and subsequently the node) fail due to the specified reason. This method will always throw a special kind of RuntimeException used to bubble-up the failure information. If you have not defined an appropriate MessageID, you can use Messages#GENERIC as workaround.
        Specified by:
        fail in interface QualifiedLogEventReceiver
        Parameters:
        messageId - message ID why this worker failed
        cause - the exception that was thrown
        args - further details
      • fail

        public final void fail​(org.jadice.util.log.qualified.MessageID messageId,
                               Object... args)
        Make the worker (and subsequently the node) fail due to the specified reason. This method will always throw a special kind of RuntimeException used to bubble-up the failure information. If you have not defined an appropriate MessageID, you can use Messages#GENERIC as workaround.
        Specified by:
        fail in interface QualifiedLogEventReceiver
        Parameters:
        messageId - message ID why this worker failed
        args - further details
      • warn

        public void warn​(org.jadice.util.log.qualified.QualifiedLogEvent event)
        Emit a warning to be ultimately propagated to JobListener.
        Specified by:
        warn in interface QualifiedLogEventReceiver
        Parameters:
        event - reason of warning
      • warn

        public void warn​(org.jadice.util.log.qualified.MessageID messageId,
                         Throwable cause,
                         Object... args)
        Emit a warning to be ultimately propagated to JobListener. If you have not defined an appropriate MessageID, you can use Messages#GENERIC as workaround.
        Specified by:
        warn in interface QualifiedLogEventReceiver
        Parameters:
        messageId - message ID why this worker emits a warning
        cause - an exception that was thrown
        args - further details
      • warn

        public void warn​(org.jadice.util.log.qualified.MessageID messageId,
                         Object... args)
        Emit a warning to be ultimately propagated to JobListener.
        Specified by:
        warn in interface QualifiedLogEventReceiver
        Parameters:
        messageId - message ID why this worker emits a warning
        args - further details
      • error

        public void error​(org.jadice.util.log.qualified.QualifiedLogEvent event)
        Emit a non-fatal error to be ultimately propagated to JobListener.
        Specified by:
        error in interface QualifiedLogEventReceiver
        Parameters:
        event - reason of error
      • error

        public void error​(org.jadice.util.log.qualified.MessageID messageId,
                          Throwable cause,
                          Object... args)
        Emit a non-fatal error to be ultimately propagated to JobListener. If you have not defined an appropriate MessageID, you can use Messages#GENERIC as workaround.
        Specified by:
        error in interface QualifiedLogEventReceiver
        Parameters:
        messageId - message ID why this worker emits an error
        cause - an exception that was thrown
        args - further details
      • error

        public void error​(org.jadice.util.log.qualified.MessageID messageId,
                          Object... args)
        Emit a non-fatal error to be ultimately propagated to JobListener. If you have not defined an appropriate MessageID, you can use Messages#GENERIC as workaround.
        Specified by:
        error in interface QualifiedLogEventReceiver
        Parameters:
        messageId - message ID why this worker emits an error
        args - further details
      • getController

        protected WorkerController<N> getController()
        Return a WorkerController for this worker. The WorkerController interface is currently implemented by this class itself, leaving it to the good-will of owners of a WorkerController reference not to cast it to NodeWorker and abuse this power. This could conceivably be remedied by letting the node hand out an implementation of this interface which only delegates the methods clients are supposed to call.
        Returns:
        WorkerController for this worker
      • getLimitSupport

        protected LimitSupport getLimitSupport()
        The LimitSupport is an easy utility for ensuring that Limits are respected. The method must not be accessed before Worker was fully initialized.
        Returns:
        The Limit Test Utility.