java.lang.Object
com.ibm.jzos.wlm.WorkUnit
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 Summary
ConstructorsConstructorDescriptionWorkUnit()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, String functionName) Create a WLM work unit.WorkUnit(ServerClassification serverClassification, String functionName) Create a WLM work unit. -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()Delete the WLM work unit.longbooleanvoidjoin()Join the WLM work unit.voidleave()Leave the WLM work unit.voidExecute the supplied Runnable against this WorkUnit.Convenience method for wrapping an existing Runnable with a WorkUnit.run() wrapper.
-
Constructor Details
-
WorkUnit
Create a WLM work unit that represents a continuation of the work unit associated with the current home address space.- Throws:
ErrnoExceptionSecurityException- if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
-
WorkUnit
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:
ErrnoExceptionSecurityException- if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
-
WorkUnit
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:
ErrnoExceptionSecurityException- if a a SecurityManager is active and the user doesn't have access to JzosPermission("WorkloadManager")
-
-
Method Details
-
run
Execute the supplied Runnable against this WorkUnit.This does the following:
join(); try { runnable.run(); } finally { leave(); }- Parameters:
runnable- the Runnable- Throws:
ErrnoException
-
wrap
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
Join the WLM work unit.The programmer should ensure that
leave()is called for every WorkUnit.- Throws:
ErrnoExceptionIllegalStateException- if the WorkUnit has been deleted.- See Also:
-
leave
Leave the WLM work unit.- Throws:
ErrnoExceptionIllegalStateException- if the WorkUnit has been deleted.
-
delete
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.
-