Search in sources :

Example 6 with CustomMessageWrapper

use of org.apache.ignite.internal.managers.discovery.CustomMessageWrapper 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)

Aggregations

CustomMessageWrapper (org.apache.ignite.internal.managers.discovery.CustomMessageWrapper)6 IgniteException (org.apache.ignite.IgniteException)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 DiscoverySpiCustomMessage (org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage)4 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 DiscoveryCustomMessage (org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)3 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)3 SQLException (java.sql.SQLException)2 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)2 TimeoutException (java.util.concurrent.TimeoutException)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 DiscoveryServerOnlyCustomMessage (org.apache.ignite.internal.managers.discovery.DiscoveryServerOnlyCustomMessage)2 DynamicCacheChangeBatch (org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch)2 SchemaProposeDiscoveryMessage (org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage)2 Span (org.apache.ignite.internal.processors.tracing.Span)2 TcpDiscoveryCustomEventMessage (org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage)2 TcpDiscoveryServerOnlyCustomEventMessage (org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryServerOnlyCustomEventMessage)2 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1