Class Handler

java.lang.Object
org.jenkinsci.plugins.durabletask.Handler
All Implemented Interfaces:
Serializable, org.jenkinsci.remoting.SerializableOnlyOverRemoting

public abstract class Handler extends Object implements org.jenkinsci.remoting.SerializableOnlyOverRemoting
A remote handler which may be sent to an agent and handle process output and results. If it needs to communicate with the master, you may use VirtualChannel.export(java.lang.Class<T>, T).
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    exited(int code, byte[] output)
    Notification that the process has exited or vanished.
    abstract void
    Notification that new process output is available.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.jenkinsci.remoting.SerializableOnlyOverRemoting

    getChannelForSerialization
  • Constructor Details

    • Handler

      public Handler()
  • Method Details

    • output

      public abstract void output(@NonNull InputStream stream) throws Exception
      Notification that new process output is available.

      Should only be called when at least one byte is available. Whatever bytes are actually read will not be offered on the next call, if there is one; there is no need to close the stream.

      There is no guarantee that output is offered in the form of complete lines of text, though in the typical case of line-oriented output it is likely that it will end in a newline.

      Buffering is the responsibility of the caller, and InputStream.markSupported() may be false.

      Parameters:
      stream - a way to read process output which has not already been handled
      Throws:
      Exception - if anything goes wrong, this watch is deactivated
    • exited

      @Asynchronous public abstract void exited(int code, @Nullable byte[] output) throws Exception
      Notification that the process has exited or vanished. output(java.io.InputStream) should have been called with any final uncollected output.

      Any metadata associated with the process may be deleted after this call completes, rendering subsequent Controller calls unsatisfiable.

      Note that unlike Controller.exitStatus(FilePath, Launcher), no specialized Launcher is available on the agent, so if there are specialized techniques for determining process liveness they will not be considered here; you still need to occasionally poll for an exit status from the master.

      Parameters:
      code - the exit code, if known (0 conventionally represents success); may be negative for anomalous conditions such as a missing process
      output - standard output captured, if DurableTask.captureOutput() was called; else null
      Throws:
      Exception