use of org.apache.ignite.internal.visor.VisorTaskArgument in project ignite by apache.
the class VisorManagementEventSelfTest method testNotManagementOneNodeVisorTask.
/**
* Current test case start one node visor task that has not GridVisorManagementTask annotation.
* No exceptions are expected.
*
* @throws Exception If failed.
*/
@Test
public void testNotManagementOneNodeVisorTask() throws Exception {
IgniteEx ignite = startGrid(0);
doTestNotManagementVisorTask(TestNotManagementVisorOneNodeTask.class, new VisorTaskArgument(), ignite);
}
use of org.apache.ignite.internal.visor.VisorTaskArgument in project ignite by apache.
the class VisorManagementEventSelfTest method doTestNotManagementVisorTask.
/**
* @param cls class of the task.
* @param arg argument.
* @param ignite instance of Ignite.
*
* @throws Exception If failed.
*/
private <T, R> void doTestNotManagementVisorTask(Class<? extends ComputeTask<VisorTaskArgument<T>, R>> cls, T arg, IgniteEx ignite) throws Exception {
final AtomicReference<TaskEvent> evt = new AtomicReference<>();
final CountDownLatch evtLatch = new CountDownLatch(1);
ignite.events().localListen(new IgnitePredicate<TaskEvent>() {
@Override
public boolean apply(TaskEvent e) {
evt.set(e);
evtLatch.countDown();
return false;
}
}, EventType.EVT_MANAGEMENT_TASK_STARTED);
for (ClusterNode node : ignite.cluster().forServers().nodes()) ignite.compute().executeAsync(cls, new VisorTaskArgument<>(node.id(), arg, true));
assertFalse(evtLatch.await(10000, TimeUnit.MILLISECONDS));
}
use of org.apache.ignite.internal.visor.VisorTaskArgument in project ignite by apache.
the class VisorManagementEventSelfTest method doTestVisorTask.
/**
* @param cls class of the task.
* @param arg argument.
* @param ignite instance of Ignite.
*
* @throws Exception If failed.
*/
private <T, R> void doTestVisorTask(Class<? extends ComputeTask<VisorTaskArgument<T>, R>> cls, T arg, IgniteEx ignite) throws Exception {
final AtomicReference<TaskEvent> evt = new AtomicReference<>();
final CountDownLatch evtLatch = new CountDownLatch(1);
ignite.events().localListen(new IgnitePredicate<TaskEvent>() {
@Override
public boolean apply(TaskEvent e) {
evt.set(e);
evtLatch.countDown();
return false;
}
}, EventType.EVT_MANAGEMENT_TASK_STARTED);
for (ClusterNode node : ignite.cluster().forServers().nodes()) ignite.compute().executeAsync(cls, new VisorTaskArgument<>(node.id(), arg, true));
assertTrue(evtLatch.await(10000, TimeUnit.MILLISECONDS));
assertNotNull(evt.get());
}
Aggregations