Search in sources :

Example 26 with DiscoveryCustomMessage

use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.

the class CacheBlockOnReadAbstractTest method destroyCachePredicate.

/**
 * Checks that given discovery event is from "Destroy cache" operation.
 *
 * @param discoEvt Discovery event.
 */
private static boolean destroyCachePredicate(DiscoveryEvent discoEvt) {
    if (discoEvt instanceof DiscoveryCustomEvent) {
        DiscoveryCustomEvent discoCustomEvt = (DiscoveryCustomEvent) discoEvt;
        DiscoveryCustomMessage customMsg = discoCustomEvt.customMessage();
        if (customMsg instanceof DynamicCacheChangeBatch) {
            DynamicCacheChangeBatch cacheChangeBatch = (DynamicCacheChangeBatch) customMsg;
            ExchangeActions exchangeActions = U.field(cacheChangeBatch, "exchangeActions");
            Collection<CacheActionData> stopRequests = exchangeActions.cacheStopRequests();
            return !stopRequests.isEmpty();
        }
    }
    return false;
}
Also used : CacheActionData(org.apache.ignite.internal.processors.cache.ExchangeActions.CacheActionData) ExchangeActions(org.apache.ignite.internal.processors.cache.ExchangeActions) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)

Example 27 with DiscoveryCustomMessage

use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.

the class GridServiceProxyTopologyInitializationTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    if (getTestIgniteInstanceName(NODES_CNT - 1).equals(igniteInstanceName)) {
        ((TestTcpDiscoverySpi) cfg.getDiscoverySpi()).discoveryHook(new DiscoveryHook() {

            @Override
            public void beforeDiscovery(DiscoveryCustomMessage customMsg) {
                if (customMsg instanceof ServiceClusterDeploymentResultBatch) {
                    fullMsgReceivedLatch.countDown();
                    try {
                        fullMsgUnblockedLatch.await(getTestTimeout(), MILLISECONDS);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }

            @Override
            public void afterDiscovery(DiscoveryCustomMessage customMsg) {
                if (customMsg instanceof ServiceClusterDeploymentResultBatch)
                    fullMsgHandledLatch.countDown();
            }
        });
        cfg.setUserAttributes(Collections.singletonMap(ATTR_SKIP_DEPLOYMENT, true));
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TestTcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) DiscoveryHook(org.apache.ignite.testframework.GridTestUtils.DiscoveryHook)

Example 28 with DiscoveryCustomMessage

use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.

the class RunningQueriesTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setDiscoverySpi(new TcpDiscoverySpi() {

        @Override
        public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
            if (CustomMessageWrapper.class.isAssignableFrom(msg.getClass())) {
                DiscoveryCustomMessage delegate = ((CustomMessageWrapper) msg).delegate();
                if (DynamicCacheChangeBatch.class.isAssignableFrom(delegate.getClass())) {
                    ((DynamicCacheChangeBatch) delegate).requests().stream().filter((c) -> !c.cacheName().equalsIgnoreCase("default")).findAny().ifPresent((c) -> {
                        try {
                            awaitTimeout();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    });
                } else if (SchemaProposeDiscoveryMessage.class.isAssignableFrom(delegate.getClass())) {
                    try {
                        awaitTimeout();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            super.sendCustomEvent(msg);
        }
    });
    cfg.setCommunicationSpi(new TcpCommunicationSpi() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) {
            if (GridIoMessage.class.isAssignableFrom(msg.getClass())) {
                Message gridMsg = ((GridIoMessage) msg).message();
                if (GridNearAtomicSingleUpdateFilterRequest.class.isAssignableFrom(gridMsg.getClass()) || GridNearAtomicFullUpdateRequest.class.isAssignableFrom(gridMsg.getClass())) {
                    try {
                        awaitTimeout();
                    } catch (Exception ignore) {
                    }
                }
            }
            super.sendMessage(node, msg, ackC);
        }
    });
    return cfg;
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Connection(java.sql.Connection) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) GridNearAtomicFullUpdateRequest(org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicFullUpdateRequest) TimeoutException(java.util.concurrent.TimeoutException) IgniteEx(org.apache.ignite.internal.IgniteEx) SqlQuery(org.apache.ignite.cache.query.SqlQuery) Cache(javax.cache.Cache) QueryEntity(org.apache.ignite.cache.QueryEntity) CyclicBarrier(java.util.concurrent.CyclicBarrier) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) Set(java.util.Set) Description(org.junit.runner.Description) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IgniteCache(org.apache.ignite.IgniteCache) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) TestWatcher(org.junit.rules.TestWatcher) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) Message(org.apache.ignite.plugin.extensions.communication.Message) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteUtils.resolveIgnitePath(org.apache.ignite.internal.util.IgniteUtils.resolveIgnitePath) CustomMessageWrapper(org.apache.ignite.internal.managers.discovery.CustomMessageWrapper) GridNearAtomicSingleUpdateFilterRequest(org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFilterRequest) SQLException(java.sql.SQLException) ClusterNode(org.apache.ignite.cluster.ClusterNode) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) G(org.apache.ignite.internal.util.typedef.G) SchemaProposeDiscoveryMessage(org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) TimeUnit(java.util.concurrent.TimeUnit) Rule(org.junit.Rule) Ignore(org.junit.Ignore) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Statement(java.sql.Statement) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) Assert(org.junit.Assert) Collections(java.util.Collections) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) ClusterNode(org.apache.ignite.cluster.ClusterNode) CustomMessageWrapper(org.apache.ignite.internal.managers.discovery.CustomMessageWrapper) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) SchemaProposeDiscoveryMessage(org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) TimeoutException(java.util.concurrent.TimeoutException) IgniteException(org.apache.ignite.IgniteException) SQLException(java.sql.SQLException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 29 with DiscoveryCustomMessage

use of org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage in project ignite by apache.

the class KillQueryTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration<?, ?> cache = GridAbstractTest.defaultCacheConfiguration();
    cache.setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));
    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setSqlFunctionClasses(TestSQLFunctions.class);
    cache.setIndexedTypes(Integer.class, Integer.class, Long.class, Long.class, String.class, Person.class);
    cfg.setCacheConfiguration(cache);
    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    if (++cntr == NODES_COUNT)
        clientBlocker = commSpi;
    cfg.setDiscoverySpi(new TcpDiscoverySpi() {

        @Override
        public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
            if (msg instanceof CustomMessageWrapper) {
                DiscoveryCustomMessage delegate = ((CustomMessageWrapper) msg).delegate();
                if (delegate instanceof DynamicCacheChangeBatch) {
                    try {
                        awaitTimeout();
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                } else if (delegate instanceof SchemaProposeDiscoveryMessage) {
                    try {
                        awaitTimeout();
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
            super.sendCustomEvent(msg);
        }
    }.setIpFinder(IP_FINDER));
    return cfg;
}
Also used : DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) CustomMessageWrapper(org.apache.ignite.internal.managers.discovery.CustomMessageWrapper) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) SchemaProposeDiscoveryMessage(org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) TimeoutException(java.util.concurrent.TimeoutException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) SQLException(java.sql.SQLException) CacheException(javax.cache.CacheException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

DiscoveryCustomMessage (org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)29 DiscoveryCustomEvent (org.apache.ignite.internal.events.DiscoveryCustomEvent)10 DynamicCacheChangeBatch (org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch)9 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)8 DiscoveryHook (org.apache.ignite.testframework.GridTestUtils.DiscoveryHook)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 IgniteException (org.apache.ignite.IgniteException)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 IgniteEx (org.apache.ignite.internal.IgniteEx)6 DiscoverySpiCustomMessage (org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage)6 Test (org.junit.Test)6 UUID (java.util.UUID)5 TestTcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi)5 Ignite (org.apache.ignite.Ignite)4 Collection (java.util.Collection)3 List (java.util.List)3 CyclicBarrier (java.util.concurrent.CyclicBarrier)3 IgniteNeedReconnectException (org.apache.ignite.internal.IgniteNeedReconnectException)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3