Search in sources :

Example 1 with GridDeploymentRequest

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

the class CacheContinuousQueryFilterDeploymentFailedTest method testContinuousQueryFilterDeploymentFailed.

/**
 * Tests continuous query behavior in case of filter deployment obtaining failure.
 *
 * @throws Exception If failed.
 */
@Test
@SuppressWarnings({ "ThrowableNotThrown" })
public void testContinuousQueryFilterDeploymentFailed() throws Exception {
    startGrids(NODES_CNT - 1);
    IgniteEx cli = startClientGrid(NODES_CNT - 1);
    IgniteCache<Integer, Integer> cache = cli.createCache(DEFAULT_CACHE_NAME);
    ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
    Class<Factory<CacheEntryEventFilter<Integer, Integer>>> rmtFilterFactoryCls = (Class<Factory<CacheEntryEventFilter<Integer, Integer>>>) getExternalClassLoader().loadClass("org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilterFactory");
    qry.setRemoteFilterFactory(rmtFilterFactoryCls.newInstance());
    spi(grid(1)).blockMessages((node, msg) -> msg instanceof GridDeploymentRequest);
    assertThrowsWithCause(() -> cache.query(qry), CacheException.class);
    assertTrue(stopRoutineLatch.await(getTestTimeout(), MILLISECONDS));
    assertTrue(allGrids().stream().allMatch(g -> ((IgniteEx) g).context().systemView().view(CQ_SYS_VIEW).size() == 0));
}
Also used : Factory(javax.cache.configuration.Factory) TestRecordingCommunicationSpi.spi(org.apache.ignite.internal.TestRecordingCommunicationSpi.spi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) TestTcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi) Ignition.allGrids(org.apache.ignite.Ignition.allGrids) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheEntryEventFilter(javax.cache.event.CacheEntryEventFilter) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) CacheException(javax.cache.CacheException) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) StopRoutineDiscoveryMessage(org.apache.ignite.internal.processors.continuous.StopRoutineDiscoveryMessage) DiscoveryHook(org.apache.ignite.testframework.GridTestUtils.DiscoveryHook) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteEx(org.apache.ignite.internal.IgniteEx) Factory(javax.cache.configuration.Factory) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) CacheEntryEventFilter(javax.cache.event.CacheEntryEventFilter) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with GridDeploymentRequest

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

the class ClassLoadingProblemExtendedLoggingTest method testTimeout.

/**
 * Tests logging when executing job with communication problems.
 */
@Test
public void testTimeout() throws ClassNotFoundException {
    LogListener lsnr1 = LogListener.matches(msg -> msg.replace("\n", "").matches(".*?Failed to get resource from node \\(is node alive\\?\\).*?" + TimeoutException.class.getName() + ".*")).build();
    LogListener lsnr2 = LogListener.matches("Failed to send class-loading request to node").build();
    listeningLog.registerListener(lsnr1);
    listeningLog.registerListener(lsnr2);
    TestRecordingCommunicationSpi clientSpi = spi(client);
    AtomicInteger reqCntr = new AtomicInteger(0);
    spi(ignite).closure((node, msg) -> {
        if (msg instanceof GridDeploymentRequest && allowSuccessfulClassRequestsCnt - reqCntr.get() <= 0)
            clientSpi.blockMessages(GridDeploymentResponse.class, ignite.name());
        reqCntr.incrementAndGet();
    });
    Class cls = getExternalClassLoader().loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1");
    try {
        client.compute().execute(cls, ignite.cluster().localNode().id());
    } catch (Exception ignored) {
    /* No-op. */
    }
    doSleep(1500);
    assertTrue(lsnr1.check() || lsnr2.check());
    clientSpi.stopBlock();
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) TestRecordingCommunicationSpi.spi(org.apache.ignite.internal.TestRecordingCommunicationSpi.spi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) LT(org.apache.ignite.internal.util.typedef.internal.LT) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) GridTestUtils.setFieldValue(org.apache.ignite.testframework.GridTestUtils.setFieldValue) GridDeploymentResponse(org.apache.ignite.internal.managers.deployment.GridDeploymentResponse) Ints.asList(com.google.common.primitives.Ints.asList) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Parameterized(org.junit.runners.Parameterized) SHARED(org.apache.ignite.configuration.DeploymentMode.SHARED) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) LogListener(org.apache.ignite.testframework.LogListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) GridDeploymentResponse(org.apache.ignite.internal.managers.deployment.GridDeploymentResponse) TimeoutException(java.util.concurrent.TimeoutException) TimeoutException(java.util.concurrent.TimeoutException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with GridDeploymentRequest

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

the class ClassLoadingProblemExtendedLoggingTest method testCNFE.

/**
 * Tests logging when executing job and class is not found on initiator.
 */
@Test
public void testCNFE() throws Exception {
    LogListener srvLsnr1 = LogListener.matches("Failed to get resource from node").build();
    LogListener srvLsnr2 = LogListener.matches("Failed to find class on remote node").build();
    LogListener clientLsnr = LogListener.matches("Failed to resolve class").build();
    listeningLog.registerListener(srvLsnr1);
    listeningLog.registerListener(srvLsnr2);
    listeningLog.registerListener(clientLsnr);
    AtomicInteger reqCntr = new AtomicInteger(0);
    spi(ignite).closure((node, msg) -> {
        if (msg instanceof GridDeploymentRequest && allowSuccessfulClassRequestsCnt - reqCntr.get() <= 0)
            setFieldValue(msg, "rsrcName", "asdf");
        reqCntr.incrementAndGet();
    });
    Class cls = getExternalClassLoader().loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1");
    try {
        client.compute().execute(cls, ignite.cluster().localNode().id());
    } catch (Exception ignored) {
    /* No-op. */
    }
    assertTrue(srvLsnr1.check() || srvLsnr2.check());
    assertTrue(clientLsnr.check());
    spi(ignite).closure(null);
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) TimeoutException(java.util.concurrent.TimeoutException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with GridDeploymentRequest

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

the class GridP2PContinuousDeploymentClientDisconnectTest method blockClassLoadingRequest.

/**
 * Blocks peer-class loading for {@link #P2P_TEST_OBJ_RSRC_NAME} resource.
 *
 * @param node The node where peer-class loading should be blocked.
 */
private void blockClassLoadingRequest(IgniteEx node) {
    GridKernalContext ctx = node.context();
    GridDeploymentManager deploymentMgr = ctx.deploy();
    Object comm = GridTestUtils.getFieldValue(deploymentMgr, "comm");
    GridMessageListener peerLsnr = GridTestUtils.getFieldValue(comm, "peerLsnr");
    ctx.io().removeMessageListener(TOPIC_CLASSLOAD, peerLsnr);
    GridMessageListener newPeerLsnr = new GridMessageListener() {

        @Override
        public void onMessage(UUID nodeId, Object msg, byte plc) {
            GridDeploymentRequest req = (GridDeploymentRequest) msg;
            String rsrcName = GridTestUtils.getFieldValue(req, "rsrcName");
            if (rsrcName.equals(P2P_TEST_OBJ_RSRC_NAME))
                return;
            peerLsnr.onMessage(nodeId, msg, plc);
        }
    };
    ctx.io().addMessageListener(TOPIC_CLASSLOAD, newPeerLsnr);
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GridDeploymentManager(org.apache.ignite.internal.managers.deployment.GridDeploymentManager) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) UUID(java.util.UUID)

Aggregations

GridDeploymentRequest (org.apache.ignite.internal.managers.deployment.GridDeploymentRequest)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 TimeoutException (java.util.concurrent.TimeoutException)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)2 TestRecordingCommunicationSpi.spi (org.apache.ignite.internal.TestRecordingCommunicationSpi.spi)2 LogListener (org.apache.ignite.testframework.LogListener)2 Ints.asList (com.google.common.primitives.Ints.asList)1 List (java.util.List)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 CacheException (javax.cache.CacheException)1 Factory (javax.cache.configuration.Factory)1 CacheEntryEventFilter (javax.cache.event.CacheEntryEventFilter)1 IgniteCache (org.apache.ignite.IgniteCache)1 Ignition.allGrids (org.apache.ignite.Ignition.allGrids)1