Module ibm.jzos

Class WorkUnit

java.lang.Object
com.ibm.jzos.wlm.WorkUnit

public class WorkUnit extends Object
A class with methods to interface with WorkloadManager (WLM) Work Units.

Uses JNI wrappers to the following C Library APIs:

  • ContinueWorkUnit
  • CreateWorkUnit
  • JoinWorkUnit
  • LeaveWorkUnit
  • DeleteWorkUnit

Note: It is the programmer's responsibility to maintain the lifecycle of a WorkUnit and to delete() it.

Note: If a WorkUnit is joined to a Thread and that thread creates new Threads, these new threads are not automatically joined to the WorkUnit.

For additional information, see:

Since:
2.3.2
See Also:
  • Constructor Details

    • WorkUnit

      public WorkUnit() throws ErrnoException
      Create a WLM work unit that represents a continuation of the work unit associated with the current home address space.
      Throws:
      ErrnoException
      SecurityException - if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
    • WorkUnit

      public WorkUnit(ServerClassification serverClassification, String functionName)
      Create a WLM work unit.
      Parameters:
      serverClassification - a configured WorkloadManager ServerClassification instance
      functionName - a string that represents the descriptive function name of the associated work request.
      Throws:
      ErrnoException
      SecurityException - if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
    • WorkUnit

      public WorkUnit(ServerClassification serverClassification, byte[] arrivalTime, String functionName)
      Create a WLM work unit.
      Parameters:
      serverClassification - a configured WorkloadManager ServerClassification instance
      arrivalTime - The arrival time in STCK format of the associated work request.
      functionName - a string that represents the descriptive function name of the associated work request.
      Throws:
      ErrnoException
      SecurityException - if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
  • Method Details

    • run

      public void run(Runnable runnable) throws ErrnoException
      Execute the supplied Runnable against this WorkUnit.

      This does the following:

                      join();
                      try {
                              runnable.run();
                      } finally {
                              leave();
                      }
                      
      Parameters:
      runnable - the Runnable
      Throws:
      ErrnoException
    • wrap

      public Runnable wrap(Runnable runnable)
      Convenience method for wrapping an existing Runnable with a WorkUnit.run() wrapper.

      This does the following:

                      return new Runnable() {
                              public void run() {
                                      WorkUnit.this.run(runnable);
                              }
                      };
                 

      For example:

                 new Thread(aWorkUnit.wrap(aRunnable)).start();
                 
      Parameters:
      runnable -
      Returns:
      the wrapped Runnable
    • join

      public void join() throws ErrnoException
      Join the WLM work unit.

      The programmer should ensure that leave() is called for every WorkUnit.

      Throws:
      ErrnoException
      IllegalStateException - if the WorkUnit has been deleted.
      See Also:
    • leave

      public void leave() throws ErrnoException
      Leave the WLM work unit.
      Throws:
      ErrnoException
      IllegalStateException - if the WorkUnit has been deleted.
    • delete

      public void delete() throws ErrnoException
      Delete the WLM work unit.

      Has no effect if already deleted.

      Throws:
      ErrnoException
    • isDeleted

      public boolean isDeleted()
      Returns:
      bool true if the WorkUnit has been deleted
    • getEnclaveToken

      public long getEnclaveToken()
      Returns:
      the enclave token.
      Throws:
      IllegalStateException - if the WorkUnit has been deleted.