Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD
 

com.newstep.solid.management.runtime
Class AsyncExecHelper

public class AsyncExecHelper      
Provides a mechanism for synchronously waiting for a ManagedExecutable
to reach a stable state. The AsyncExecHelper allows clients to block waiting
for the specified state to be achieved via the ExecStateFuture.
The returned future can be redeemed anytime after transition has been fired
(by calling the get method) and will allow clients to control
ManagedExecutable states in a sequential synchronous fashion.


NOTE: although it is possible to apply the helper to any
SyncManagedExectuables it is not recommended since the sync functions will
intoduce unnecessary overhead



Example:



void startSystem(AsyncManagedExecutable a, AsyncManagedExecutable b, AsyncManagedExecutable c) throws SomeException {
try {
// start a and b
ExecStateFuture aStartFuture = AsyncExecHelper.start(a);
ExecStateFuture bStartFuture = AsyncExecHelper.start(b);

// wait for a and b to finish starting before starting c
ExecState aStartResult = aStartFuture.get();
if(!ExecState.RUNNING.equals(aStartResult)) {
throw new SomeException(ce);
}

ExecState aStartResult = aStartFuture.get();
if(!ExecState.RUNNING.equals(aStartResult)) {
throw new SomeException(ce);
}

// start c
ExecStateFuture cStartFuture = AsyncExecHelper.start(c);

// wait for c to finish starting before returning
cStartFuture.get();
ExecState cStartResult = cStartFuture.get();
if(!ExecState.RUNNING.equals(cStartResult)) {
throw new SomeException(ce);
}

} catch(CancellationException ce) {
throw new SomeException(ce);
} catch(InvalidStateException ise) {
throw new SomeException(ise);
} catch(ExecutableException exee) {
throw new SomeException(exee);
} catch(ExecutionException exe) {
throw new SomeException(exe);
}
}

 
 

Method Summary
public static ExecStateFuture
public static ExecStateFuture
public static ExecStateFuture
public static ExecStateFuture
public static ExecStateFuture
Method Detail
resume
public static ExecStateFuture resume (ManagedExecutable mgdExec)
 
invokes the resume transition on the ManagedExecutable and provides a
future through which the transition can be tracked.
Parameters:
mgdExec the ManagedExecutable to resume
Return:
an ExecStateFuture which can be redeemed when the executable
reaches the RUNNING state
Static.
Throws:
ExecutableException
 

shutdown
public static ExecStateFuture shutdown (ManagedExecutable mgdExec)
 
invokes the shutdown transition on the ManagedExecutable and provides a
future through which the transition can be tracked.
Parameters:
mgdExec the ManagedExecutable to shutdown
Return:
an ExecStateFuture which can be redeemed when the executable
reaches the DONE state
Static.
Throws:
ExecutableException
 

start
public static ExecStateFuture start (ManagedExecutable mgdExec)
 
invokes the start transition on the ManagedExecutable and provides a
future through which the transition can be tracked.
Parameters:
mgdExec the ManagedExecutable to start
Return:
an ExecStateFuture which can be redeemed when the executable
reaches the RUNNING state
Static.
Throws:
ExecutableException
 

stop
public static ExecStateFuture stop (ManagedExecutable mgdExec)
 
invokes the stop transition on the ManagedExecutable and provides a
future through which the transition can be tracked.
Parameters:
mgdExec the ManagedExecutable to stop
Return:
an ExecStateFuture which can be redeemed when the executable
reaches the DONE state
Static.
Throws:
ExecutableException
 

suspend
public static ExecStateFuture suspend (ManagedExecutable mgdExec)
 
invokes the suspend transition on the ManagedExecutable and provides a
future through which the transition can be tracked.
Parameters:
mgdExec the ManagedExecutable to suspend
Return:
an ExecStateFuture which can be redeemed when the executable
reaches the SUSPENDED state
Static.
Throws:
ExecutableException
 

Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD