com.ibm.jzos.wlm
Class WorkUnit
- java.lang.Object
-
- com.ibm.jzos.wlm.WorkUnit
-
public class WorkUnit extends java.lang.ObjectA 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 and 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 and Description voiddelete()Delete the WLM work unit.longgetEnclaveToken()booleanisDeleted()voidjoin()Join the WLM work unit.voidleave()Leave the WLM work unit.voidrun(java.lang.Runnable runnable)Execute the supplied Runnable against this WorkUnit.java.lang.Runnablewrap(java.lang.Runnable runnable)Convenience method for wrapping an existing Runnable with a WorkUnit.run() wrapper.
-
-
-
Constructor Detail
-
WorkUnit
public WorkUnit() throws ErrnoExceptionCreate a WLM work unit that represents a continuation of the work unit associated with the current home address space.- Throws:
ErrnoExceptionjava.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 instancefunctionName- a string that represents the descriptive function name of the associated work request.- Throws:
ErrnoExceptionjava.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 instancearrivalTime- 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:
ErrnoExceptionjava.lang.SecurityException- if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")- See Also:
ZUtil.getTodClock().
-
-
Method Detail
-
run
public void run(java.lang.Runnable runnable) throws ErrnoExceptionExecute 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
-
join
public void join() throws ErrnoExceptionJoin the WLM work unit.The programmer should ensure that
leave()is called for every WorkUnit.- Throws:
ErrnoExceptionjava.lang.IllegalStateException- if the WorkUnit has been deleted.- See Also:
run(Runnable),wrap(Runnable)
-
leave
public void leave() throws ErrnoExceptionLeave the WLM work unit.- Throws:
ErrnoExceptionjava.lang.IllegalStateException- if the WorkUnit has been deleted.
-
delete
public void delete() throws ErrnoExceptionDelete 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:
java.lang.IllegalStateException- if the WorkUnit has been deleted.
-
-