Search in sources :

Example 1 with GridDeploymentResponse

use of org.apache.ignite.internal.managers.deployment.GridDeploymentResponse in project ignite by apache.

the class GridPeerDeploymentRetryModifiedTest method deploymentTest.

/**
 * @throws Exception If failed.
 */
private void deploymentTest() throws Exception {
    Ignite g1 = startGrid(1);
    IgniteEx g2 = startGrid(2);
    try {
        GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(URLS);
        ClusterNode node = g1.cluster().node(g2.cluster().localNode().id());
        g1.compute(g1.cluster().forRemotes()).execute((ComputeTask<Object, T2>) ldr.loadClass(EXT_TASK_CLASS_NAME).newInstance(), new T2<>(node, null));
        TestRecordingCommunicationSpi rec1 = (TestRecordingCommunicationSpi) g1.configuration().getCommunicationSpi();
        rec1.blockMessages((n, message) -> message instanceof GridDeploymentResponse);
        ComputeTask<Object, T2> task = (ComputeTask<Object, T2>) ldr.loadClass(EXT_TASK_CLASS_NAME).newInstance();
        try {
            g1.compute(g1.cluster().forRemotes()).withTimeout(2000).execute(task, new T2<>(node, "foo"));
            fail("Exception should be thrown");
        } catch (IgniteException ignore) {
        // Expected exception.
        // ignore.printStackTrace();
        }
        rec1.stopBlock(false, null, true, true);
        try {
            g1.compute(g1.cluster().forRemotes()).execute(task, new T2<>(node, "bar"));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        assertFalse(g2.cache(DEFAULT_CACHE_NAME).containsKey("foo"));
        assertTrue(g2.cache(DEFAULT_CACHE_NAME).containsKey("bar"));
    } finally {
        stopAllGrids(true);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeTask(org.apache.ignite.compute.ComputeTask) GridTestExternalClassLoader(org.apache.ignite.testframework.GridTestExternalClassLoader) GridDeploymentResponse(org.apache.ignite.internal.managers.deployment.GridDeploymentResponse) MalformedURLException(java.net.MalformedURLException) IgniteException(org.apache.ignite.IgniteException) IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite) T2(org.apache.ignite.internal.util.typedef.T2)

Example 2 with GridDeploymentResponse

use of org.apache.ignite.internal.managers.deployment.GridDeploymentResponse in project ignite by apache.

the class GridPeerDeploymentRetryTest method deploymentTest.

/**
 * @throws Exception If failed.
 */
private void deploymentTest() throws Exception {
    Ignite g1 = startGrid(1);
    Ignite g2 = startGrid(2);
    try {
        GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(URLS);
        TestRecordingCommunicationSpi rec1 = (TestRecordingCommunicationSpi) g1.configuration().getCommunicationSpi();
        rec1.blockMessages((node, message) -> message instanceof GridDeploymentResponse);
        ComputeTask<Object, ?> task = (ComputeTask<Object, ?>) ldr.loadClass(EXT_TASK_CLASS_NAME).newInstance();
        ClusterNode node = g1.cluster().node(g2.cluster().localNode().id());
        try {
            g1.compute(g1.cluster().forRemotes()).execute(task, node);
            fail("Exception should be thrown");
        } catch (IgniteException ignore) {
        // Expected exception.
        }
        rec1.stopBlock(false, null, true, true);
        g1.compute(g1.cluster().forRemotes()).execute(task, node);
    } finally {
        stopAllGrids(true);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteException(org.apache.ignite.IgniteException) ComputeTask(org.apache.ignite.compute.ComputeTask) GridTestExternalClassLoader(org.apache.ignite.testframework.GridTestExternalClassLoader) Ignite(org.apache.ignite.Ignite) GridDeploymentResponse(org.apache.ignite.internal.managers.deployment.GridDeploymentResponse)

Aggregations

Ignite (org.apache.ignite.Ignite)2 IgniteException (org.apache.ignite.IgniteException)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 ComputeTask (org.apache.ignite.compute.ComputeTask)2 GridDeploymentResponse (org.apache.ignite.internal.managers.deployment.GridDeploymentResponse)2 GridTestExternalClassLoader (org.apache.ignite.testframework.GridTestExternalClassLoader)2 MalformedURLException (java.net.MalformedURLException)1 T2 (org.apache.ignite.internal.util.typedef.T2)1