Module ibm.jzos

Class WorkUnit


  • public class WorkUnit
    extends java.lang.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:
    WorkloadManager, ServerClassification
    • Constructor Summary

      Constructors 
      Constructor Description
      WorkUnit()
      Create a WLM work unit that represents a continuation of the work unit associated with the current home address space.
      WorkUnit​(ServerClassification serverClassification, byte[] arrivalTime, java.lang.String functionName)
      Create a WLM work unit.
      WorkUnit​(ServerClassification serverClassification, java.lang.String functionName)
      Create a WLM work unit.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()
      Delete the WLM work unit.
      long getEnclaveToken()  
      boolean isDeleted()  
      void join()
      Join the WLM work unit.
      void leave()
      Leave the WLM work unit.
      void run​(java.lang.Runnable runnable)
      Execute the supplied Runnable against this WorkUnit.
      java.lang.Runnable wrap​(java.lang.Runnable runnable)
      Convenience method for wrapping an existing Runnable with a WorkUnit.run() wrapper.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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
        java.lang.SecurityException - if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
      • WorkUnit

        public WorkUnit​(ServerClassification serverClassification,
                        java.lang.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
        java.lang.SecurityException - if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
      • WorkUnit

        public WorkUnit​(ServerClassification serverClassification,
                        byte[] arrivalTime,
                        java.lang.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
        java.lang.SecurityException - if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
    • Method Detail

      • run

        public void run​(java.lang.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 java.lang.Runnable wrap​(java.lang.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
      • leave

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

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

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