Search in sources :

Example 11 with VisorTaskArgument

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);
}
Also used : VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 12 with VisorTaskArgument

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));
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TaskEvent(org.apache.ignite.events.TaskEvent) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 13 with VisorTaskArgument

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());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TaskEvent(org.apache.ignite.events.TaskEvent) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

VisorTaskArgument (org.apache.ignite.internal.visor.VisorTaskArgument)13 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 Test (org.junit.Test)7 UUID (java.util.UUID)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 TaskEvent (org.apache.ignite.events.TaskEvent)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 Collection (java.util.Collection)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Collectors (java.util.stream.Collectors)2 IgniteDataStreamer (org.apache.ignite.IgniteDataStreamer)2 ComputeTask (org.apache.ignite.compute.ComputeTask)2 Event (org.apache.ignite.events.Event)2 GridClient (org.apache.ignite.internal.client.GridClient)2 GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)2 GridClientNode (org.apache.ignite.internal.client.GridClientNode)2 VisorValidateIndexesJobResult (org.apache.ignite.internal.visor.verify.VisorValidateIndexesJobResult)2