GNDMS 0.6.0
RESTful verison of GNDMS
|
Performs all requests necessary for taskflow execution. More...
Public Member Functions | |
void | execTF (Order order, String dn) |
Executes a complete task flow. | |
void | execTF (Order order, String dn, boolean withQuote, final Quote desiredQuote) |
Executes a complete task flow. | |
GORFXClient | getGorfxClient () |
Delivers the value of ::gorfxClient. | |
void | setGorfxClient (GORFXClient gorfxClient) |
Sets the value of ::gorfxClient to gorfxClient. | |
TaskFlowClient | getTfClient () |
Delivers the value of ::tfClient. | |
void | setTfClient (TaskFlowClient tfClient) |
Sets the value of ::tfClient to tfClient. | |
TaskClient | getTaskClient () |
Delivers the value of ::taskClient. | |
void | setTaskClient (TaskClient taskClient) |
Sets the value of ::taskClient to taskClient. | |
long | getPollingDelay () |
Delivers the value of ::pollingDelay. | |
void | setPollingDelay (long pollingDelay) |
Sets the value of ::pollingDelay to pollingDelay. | |
Protected Member Functions | |
GNDMSResponseHeader | setupContext (final GNDMSResponseHeader context) |
Offers implementing clients the possibility to add values to the request context. | |
abstract void | handleStatus (TaskStatus stat) |
Handler method for the current task status. | |
abstract Integer | selectQuote (List< Specifier< Quote >> quotes) |
Allows the caller to select a quote. | |
abstract void | handleTaskSpecifier (Specifier< Facets > ts) |
Allows additional handling for the task specifier. | |
abstract void | handleResult (TaskResult res) |
Handler for the task result. | |
abstract void | handleFailure (TaskFailure fail) |
Handler for task failures. | |
Private Member Functions | |
boolean | finished (TaskStatus ts) |
Checks if ts is FINISHED. | |
boolean | failed (TaskStatus ts) |
Checks if ts is FINISHED. | |
Private Attributes | |
GORFXClient | gorfxClient |
A ready to uses instance of the gorfx client. | |
TaskFlowClient | tfClient |
A ready to uses instance of the taskflow client. | |
TaskClient | taskClient |
A ready to uses instance of the task client. | |
long | pollingDelay = 1000 |
delay in ms to poll the task status, once the task is running. |
Performs all requests necessary for taskflow execution.
void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.execTF | ( | Order | order, |
String | dn | ||
) |
Executes a complete task flow.
order | The order of the taskflow. |
dn | The DN of the user calling the task flow. |
void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.execTF | ( | Order | order, |
String | dn, | ||
boolean | withQuote, | ||
final Quote | desiredQuote | ||
) |
Executes a complete task flow.
This method is imported when you want to understand the Taskflow protocoll.
order | The order of the taskflow. |
dn | The DN of the user calling the task flow. |
withQuote | Activates co-scheduling |
desiredQuote | A quote holding desired time values for the tasflow execution. |
this is imporant */ // sends the order and creates the task flow ResponseEntity<Specifier<Facets>> res = gorfxClient.createTaskFlow( order.getTaskFlowType(), order, dn, wid, context ); if ( !HttpStatus.CREATED.equals( res.getStatusCode() ) ) throw new RuntimeException( "createTaskFlow failed " + res.getStatusCode().name() ); // the taskflow id is stored under "id" in the urlmap String tid = res.getBody().getUriMap().get( "id" ); Integer q = null; if( withQuote ) { if( desiredQuote != null ) { tfClient.setQuote( order.getTaskFlowType(), tid, desiredQuote, dn, wid ); } // queries the quotes for the task flow ResponseEntity<List<Specifier<Quote>>> res2 = tfClient.getQuotes( order.getTaskFlowType(), tid, dn, wid ); if ( !HttpStatus.OK.equals( res2.getStatusCode() ) ) throw new RuntimeException( "getQuotes failed " + res2.getStatusCode().name() ); // lets the implementors of this class choose a quote q = selectQuote( res2.getBody() ); } // // 'til here it is valid to change the order and request new quotes // // accepts quote q and triggers task creation ResponseEntity<Specifier<Facets>> res3 = tfClient.createTask( order.getTaskFlowType(), tid, q, dn, wid ); if(! HttpStatus.CREATED.equals( res3.getStatusCode() ) ) throw new RuntimeException( "createTask failed " + res3.getStatusCode().name() ); // let the implementor do smart things with the task specifier handleTaskSpecifier( res3.getBody() ); // the task id is stored under "taskId" in the specifiers urlmap String taskId = res3.getBody().getUriMap().get( "taskId" ); ResponseEntity<TaskStatus> stat; TaskStatus ts; do { // queries the status of the task execution stat = taskClient.getStatus( taskId, dn, wid ); if(! HttpStatus.OK.equals( stat.getStatusCode() ) ) throw new RuntimeException( "Task::getStatus failed " + stat.getStatusCode().name() ); ts = stat.getBody(); // allows the implementor to do something with the task status handleStatus( ts ); try { Thread.sleep( pollingDelay ); } catch ( InterruptedException e ) { throw new RuntimeException( e ); } } while( !( finished( ts ) || failed( ts ) ) ); // run 'til the task hits a final state // finished without an error, good if( finished( ts ) ) { // collect the result ResponseEntity<TaskResult> tr = taskClient.getResult( taskId, dn, wid ); if(! HttpStatus.OK.equals( tr.getStatusCode() ) ) throw new RuntimeException( "Failed to obtain task result " + tr.getStatusCode().name() ); // do something with it handleResult( tr.getBody() ); } else { // must be failed, not so good // find out way ResponseEntity<TaskFailure> tf = taskClient.getErrors( taskId, dn, wid ); if(! HttpStatus.OK.equals( tf.getStatusCode() ) ) throw new RuntimeException( "Failed to obtain task errors " + tf.getStatusCode().name() ); // handle the failure handleFailure( tf.getBody() ); } /**
boolean de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.failed | ( | TaskStatus | ts | ) | [private] |
Checks if ts is FINISHED.
ts | The current task state. |
true
if ts is FINISHED boolean de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.finished | ( | TaskStatus | ts | ) | [private] |
Checks if ts is FINISHED.
ts | The current task state. |
true
if ts is FINISHED GORFXClient de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.getGorfxClient | ( | ) |
Delivers the value of ::gorfxClient.
long de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.getPollingDelay | ( | ) |
Delivers the value of ::pollingDelay.
TaskClient de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.getTaskClient | ( | ) |
Delivers the value of ::taskClient.
TaskFlowClient de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.getTfClient | ( | ) |
Delivers the value of ::tfClient.
abstract void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.handleFailure | ( | TaskFailure | fail | ) | [protected, pure virtual] |
Handler for task failures.
Override this method to gain access to the task(flow) error object, e.g. to send an error-report to someone who cares.
fail | The failure object. |
Implemented in de.zib.gndms.gndmc.gorfx.ExampleTaskFlowExecClient.
abstract void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.handleResult | ( | TaskResult | res | ) | [protected, pure virtual] |
Handler for the task result.
Override this method to gain access to the task(flow) result an send it to the user, post process it or store it for later usage.
res | The result object. |
Implemented in de.zib.gndms.gndmc.gorfx.ExampleTaskFlowExecClient.
abstract void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.handleStatus | ( | TaskStatus | stat | ) | [protected, pure virtual] |
Handler method for the current task status.
This method can be used to delegate the current task progress to the user.
stat | The current task status. |
Implemented in de.zib.gndms.gndmc.gorfx.ExampleTaskFlowExecClient.
abstract void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.handleTaskSpecifier | ( | Specifier< Facets > | ts | ) | [protected, pure virtual] |
Allows additional handling for the task specifier.
ts | The task specifier, including all task facets as payload. |
Implemented in de.zib.gndms.gndmc.gorfx.ExampleTaskFlowExecClient.
abstract Integer de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.selectQuote | ( | List< Specifier< Quote >> | quotes | ) | [protected, pure virtual] |
Allows the caller to select a quote.
quotes | All available quotes. |
null
will disable quote usage. Implemented in de.zib.gndms.gndmc.gorfx.ExampleTaskFlowExecClient.
void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.setGorfxClient | ( | GORFXClient | gorfxClient | ) |
Sets the value of ::gorfxClient to gorfxClient.
gorfxClient | The new value of ::gorfxClient. |
void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.setPollingDelay | ( | long | pollingDelay | ) |
Sets the value of ::pollingDelay to pollingDelay.
pollingDelay | The new value of ::pollingDelay. |
void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.setTaskClient | ( | TaskClient | taskClient | ) |
Sets the value of ::taskClient to taskClient.
taskClient | The new value of ::taskClient. |
void de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.setTfClient | ( | TaskFlowClient | tfClient | ) |
Sets the value of ::tfClient to tfClient.
tfClient | The new value of ::tfClient. |
GNDMSResponseHeader de.zib.gndms.gndmc.gorfx.AbstractTaskFlowExecClient.setupContext | ( | final GNDMSResponseHeader | context | ) | [protected] |
Offers implementing clients the possibility to add values to the request context.
The request context is used to create taskflows and the right place to provide myProxyTokens.
context | The create request context. |