Closes #67

Invoke effector: support timeout

Passes the timeout arg (if supplied) when making the REST api call to Brooklyn. 
The response from this is written to stdout.

If it times out, the REST api still gives back a 202 response code with a json 
payload describing the executing task. The `br` tool simply writes that to 
stdout. For example:

```
cli/target/bin/darwin.amd64/br app rbfvau9i75 effector stop invoke --timeout 1ms

{"id":"kpML04c1","displayName":"stop","description":"Invoking effector stop on 
server @ localhost with parameters 
{}","entityId":"rbfvau9i75","entityDisplayName":"server @ 
localhost","tags":["EFFECTOR",{"entityId":"rbfvau9i75","effectorName":"stop"},{"entitlementContext":{"user":"<snip>","sourceIp":"0:0:0:0:0:0:0:1","requestUri":"/v1/applications/rbfvau9i75/entities/rbfvau9i75/effectors/stop","requestUniqueIdentifier":"rjuSuB"}},{"type":"org.apache.brooklyn.api.mgmt.ManagementContext"},{"wrappingType":"targetEntity","entity":{"type":"org.apache.brooklyn.api.entity.Entity","id":"rbfvau9i75"}},{"entitlementContext":{"user":"<snip>","sourceIp":"0:0:0:0:0:0:0:1","requestUri":"/v1/applications/rbfvau9i75/entities/rbfvau9i75/effectors/stop","requestUniqueIdentifier":"rjuSuB"}},{"wrappingType":"contextEntity","entity":{"type":"org.apache.brooklyn.api.entity.Entity","id":"rbfvau9i75"}}],"submitTimeUtc":1517490162402,"startTimeUtc":1517490162402,"endTimeUtc":null,"currentStatus":"In
 progress"
 
,"result":null,"isError":false,"isCancelled":false,"children":[{"link":"/v1/activities/X9j8xcJ1","metadata":{"id":"X9j8xcJ1","taskName":"invoking
 stop[] on 1 node","entityId":"rbfvau9i75","entityDisplayName":"server @ 
localhost"}}],"submittedByTask":null,"blockingTask":{"link":"/v1/activities/X9j8xcJ1","metadata":{"id":"X9j8xcJ1","taskName":"invoking
 stop[] on 1 node","entityId":"rbfvau9i75","entityDisplayName":"server @ 
localhost"}},"detailedStatus":"Waiting on Task[invoking stop[] on 1 
node]@X9j8xcJ1\n\nTask[stop]@kpML04c1\nChildren:\n  Task[invoking stop[] on 1 
node]@X9j8xcJ1: Executing 1 child task\n\nIn progress, thread waiting (notify) 
on java.util.concurrent.FutureTask@61fe3136\nAt: 
com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)\n
    org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:384)\n    
org.apache.brooklyn.util.core.task.BasicTask.getUnchecked(BasicTask.java:393)\n 
   org.apache.brooklyn.util.core.task.DynamicTasks$TaskQue
 ueingResult.andWaitForSuccess(DynamicTasks.java:195)\n    
org.apache.brooklyn.util.core.task.DynamicTasks.get(DynamicTasks.java:363)\n    
org.apache.brooklyn.core.entity.trait.StartableMethods.stop(StartableMethods.java:58)\n
    
org.apache.brooklyn.core.entity.AbstractApplication.doStop(AbstractApplication.java:271)\n
    
org.apache.brooklyn.core.entity.AbstractApplication.stop(AbstractApplication.java:246)\n
    
org.apache.brooklyn.util.javalang.Reflections.invokeMethodFromArgs(Reflections.java:984)\n
    
org.apache.brooklyn.util.javalang.Reflections.invokeMethodFromArgs(Reflections.java:871)\n
    
org.apache.brooklyn.util.javalang.Reflections.invokeMethodFromArgs(Reflections.java:857)\n
    
org.apache.brooklyn.util.javalang.Reflections.invokeMethodFromArgs(Reflections.java:852)\n
    
org.apache.brooklyn.core.mgmt.internal.AbstractManagementContext.invokeEffectorMethodLocal(AbstractManagementContext.java:327)\n
    org.apache.brooklyn.core.mgmt.internal.AbstractManagementContext.invokeEff
 ectorMethodSync(AbstractManagementContext.java:366)\n    
org.apache.brooklyn.core.mgmt.internal.EffectorUtils.invokeMethodEffector(EffectorUtils.java:274)\n
    
org.apache.brooklyn.core.effector.MethodEffector.call(MethodEffector.java:153)\n
    
org.apache.brooklyn.core.entity.trait.Startable$StopEffectorBody.call(Startable.java:68)\n
    
org.apache.brooklyn.core.entity.trait.Startable$StopEffectorBody.call(Startable.java:60)\n
    
org.apache.brooklyn.core.effector.EffectorTasks$EffectorBodyTaskFactory$1.call(EffectorTasks.java:82)\n
    
org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:364)\n
    
org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:565)","streams":{},"links":{"self":"/v1/activities/kpML04c1","children":"/v1/activities/kpML04c1/children","entity":"/v1/applications/rbfvau9i75/entities/rbfvau9i75"}}
```


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/05252218
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/05252218
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/05252218

Branch: refs/heads/master
Commit: 0525221813377b182d81a609f0970472868cafa1
Parents: 48e9f40 782af9d
Author: Geoff Macartney <geoff.macart...@cloudsoftcorp.com>
Authored: Fri Feb 2 19:00:31 2018 +0000
Committer: Geoff Macartney <geoff.macart...@cloudsoftcorp.com>
Committed: Fri Feb 2 19:00:31 2018 +0000

----------------------------------------------------------------------
 cli/api/entity_effectors/effectors.go |  5 ++++-
 cli/commands/invoke.go                | 22 +++++++++++++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


Reply via email to