Re: Cancel tasks on Ignite compute grid worker nodes

2016-05-19 Thread fs12345
Hi, 

Thank you for your help.
I have tried activeTaskFutures() and was able to cancel tasks that way. 

Regards,







--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Cancel-tasks-on-Ignite-compute-grid-worker-nodes-tp5027p5039.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Cancel tasks on Ignite compute grid worker nodes

2016-05-19 Thread vkulichenko
In addition there is IgniteCompute.activeTaskFutures() method that returns
all currently running tasks executed by current node. You can also use these
futures to cancel tasks.

Also note that you can only cancel the whole task (which as usually a set of
several job executed on server nodes). Once you cancel the task, all jobs
will be interrupted.

-Val



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Cancel-tasks-on-Ignite-compute-grid-worker-nodes-tp5027p5035.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Cancel tasks on Ignite compute grid worker nodes

2016-05-19 Thread vdpyatkov
Hello,

My first answer is corrupted. I duplicate it again

I would used support asynchronous operation, and cancel IgniteFuture if
needed.
For example:
1) Create cluster group by attribute
cg = cluster.forAttribute("ROLE", "worker");
2) Make compute async
c = igniteClient.compute(cg).withAsync()
3) Start executing task
c.call(job)
IgniteFuture f = c.future()
4) cancel or wait result
f.cancel()
f.get()





fs12345 wrote
> Hi all,
> 
> Let me start by saying I am quite a novice with Apache Ignite. 
> 
> Here is my question : I want to be able to monitor and cancel tasks
> running or that are going to run on worker nodes of an Ignite Cluster (say
> for example if one task takes too long to complete), and without using
> Visor. 
> 
> I tried to query all EVTS_TASK_EXECUTION events (from EventType) on all
> nodes as follows:
> 
> Ignite grid = Ignition.ignite("GRID_NAME");
> Collection
> 
>  allEvents = grid.events().remoteQuery(event -> true,0,
> EventType.EVTS_TASK_EXECUTION)
> for (Event evt : allEvents){
>   TaskEvent taskEvent = (TaskEvent) evt;
>   System.out.println(taskEvent);
> }
> 
> Each TaskEvent,  has a taskSessionId() method, and a .node() method. It
> seems that the .node() method returns the client node that originated the
> task with the corresponding IgniteUuid returned by taskSessionId().
> 
> On the other hand, when looking at ClusterMetrics for worker nodes I can
> retrieve the number of Jobs currently running on Worker Nodes, current CPU
> load etc : 
> 
> ClusterGroup workerNodes = grid.cluster().forAttribute("ROLE","WORKER");
> for(ClusterNode node : workerNodes.nodes()){
>   System.out.println(node.metrics().getCurrentActiveJobs());
> }
> 
> How could I 
>   1) Cancel tasks currently being run on worker nodes (whose number are
> displayed in the result of getCurrentActiveJobs()) or 
>   2) Cancel tasks dispatched by the clients nodes, for which I have an
> IgniteUuid ,
>   
> possibly without using grid.close() or such hard methods.
> 
> Thanks for your help





--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Cancel-tasks-on-Ignite-compute-grid-worker-nodes-tp5027p5034.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Cancel tasks on Ignite compute grid worker nodes

2016-05-19 Thread vdpyatkov
fs12345 wrote
> Hi all,
> 
> Let me start by saying I am quite a novice with Apache Ignite. 
> 
> Here is my question : I want to be able to monitor and cancel tasks
> running or that are going to run on worker nodes of an Ignite Cluster (say
> for example if one task takes too long to complete), and without using
> Visor. 
> 
> I tried to query all EVTS_TASK_EXECUTION events (from EventType) on all
> nodes as follows:
> 
> Ignite grid = Ignition.ignite("GRID_NAME");
> Collection
> 
>  allEvents = grid.events().remoteQuery(event -> true,0,
> EventType.EVTS_TASK_EXECUTION)
> for (Event evt : allEvents){
>   TaskEvent taskEvent = (TaskEvent) evt;
>   System.out.println(taskEvent);
> }
> 
> Each TaskEvent,  has a taskSessionId() method, and a .node() method. It
> seems that the .node() method returns the client node that originated the
> task with the corresponding IgniteUuid returned by taskSessionId().
> 
> On the other hand, when looking at ClusterMetrics for worker nodes I can
> retrieve the number of Jobs currently running on Worker Nodes, current CPU
> load etc : 
> Hello,
> 
> I not sure, what I all understood correctly.
> But I would used support asynchronous operation, and cancel IgniteFuture
> if needed.
> For example:
> 1) Create cluster group by attribute
> cg = cluster.forAttribute("ROLE", "worker");
> 2) Make compute async
> c = igniteClient.compute(cg).withAsync()
> 3) Start executing task
> c.call(job)
> IgniteFuture f = c.future()
> 4) cancel or wait result
> f.cancel()
> f.get()
> 
> ClusterGroup workerNodes = grid.cluster().forAttribute("ROLE","WORKER");
> for(ClusterNode node : workerNodes.nodes()){
>   System.out.println(node.metrics().getCurrentActiveJobs());
> }
> 
> How could I 
>   1) Cancel tasks currently being run on worker nodes (whose number are
> displayed in the result of getCurrentActiveJobs()) or 
>   2) Cancel tasks dispatched by the clients nodes, for which I have an
> IgniteUuid ,
>   
> possibly without using grid.close() or such hard methods.
> 
> Thanks for your help





--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Cancel-tasks-on-Ignite-compute-grid-worker-nodes-tp5027p5033.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.