Search in sources :

Example 6 with CommunicationSpi

use of org.apache.ignite.spi.communication.CommunicationSpi in project ignite by apache.

the class GridTcpCommunicationSpiMultithreadedSelfTest method afterTest.

/**
 * @throws Exception If failed.
 */
@Override
protected void afterTest() throws Exception {
    super.afterTest();
    for (MessageListener lsnr : lsnrs.values()) {
        lsnr.rcvdMsgs.clear();
        lsnr.rmtMsgCnt.set(0);
    }
    for (CommunicationSpi spi : spis.values()) {
        final ConcurrentMap<UUID, GridCommunicationClient[]> clients = U.field(spi, "clients");
        assert GridTestUtils.waitForCondition(new PA() {

            @Override
            public boolean apply() {
                for (GridCommunicationClient[] clients0 : clients.values()) {
                    for (GridCommunicationClient client : clients0) {
                        if (client != null)
                            return false;
                    }
                }
                return true;
            }
        }, getTestTimeout()) : "Clients: " + clients;
    }
}
Also used : PA(org.apache.ignite.internal.util.typedef.PA) CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) UUID(java.util.UUID) GridCommunicationClient(org.apache.ignite.internal.util.nio.GridCommunicationClient)

Example 7 with CommunicationSpi

use of org.apache.ignite.spi.communication.CommunicationSpi in project ignite by apache.

the class GridManagerStopSelfTest method testStopCommunicationManager.

/**
 * @throws Exception If failed.
 */
public void testStopCommunicationManager() throws Exception {
    CommunicationSpi spi = new TcpCommunicationSpi();
    injectLogger(spi);
    ctx.config().setCommunicationSpi(spi);
    ctx.config().setMarshaller(new BinaryMarshaller());
    GridIoManager mgr = new GridIoManager(ctx);
    mgr.onKernalStop(true);
    mgr.stop(false);
}
Also used : CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridIoManager(org.apache.ignite.internal.managers.communication.GridIoManager) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Example 8 with CommunicationSpi

use of org.apache.ignite.spi.communication.CommunicationSpi in project ignite by apache.

the class GridFailFastNodeFailureDetectionSelfTest method failNode.

/**
 * @param ignite Ignite.
 * @throws Exception In case of error.
 */
private void failNode(Ignite ignite) throws Exception {
    DiscoverySpi disco = ignite.configuration().getDiscoverySpi();
    U.invoke(disco.getClass(), disco, "simulateNodeFailure");
    CommunicationSpi comm = ignite.configuration().getCommunicationSpi();
    U.invoke(comm.getClass(), comm, "simulateNodeFailure");
}
Also used : CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 9 with CommunicationSpi

use of org.apache.ignite.spi.communication.CommunicationSpi in project ignite by apache.

the class PlatformConfigurationUtils method writeIgniteConfiguration.

/**
 * Writes Ignite configuration.
 *
 * @param w Writer.
 * @param cfg Configuration.
 */
@SuppressWarnings("deprecation")
public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfiguration cfg) {
    assert w != null;
    assert cfg != null;
    w.writeBoolean(true);
    w.writeBoolean(cfg.isClientMode());
    w.writeIntArray(cfg.getIncludeEventTypes());
    w.writeBoolean(true);
    w.writeLong(cfg.getMetricsExpireTime());
    w.writeBoolean(true);
    w.writeInt(cfg.getMetricsHistorySize());
    w.writeBoolean(true);
    w.writeLong(cfg.getMetricsLogFrequency());
    w.writeBoolean(true);
    w.writeLong(cfg.getMetricsUpdateFrequency());
    w.writeBoolean(true);
    w.writeInt(cfg.getNetworkSendRetryCount());
    w.writeBoolean(true);
    w.writeLong(cfg.getNetworkSendRetryDelay());
    w.writeBoolean(true);
    w.writeLong(cfg.getNetworkTimeout());
    w.writeString(cfg.getWorkDirectory());
    w.writeString(cfg.getLocalHost());
    w.writeBoolean(true);
    w.writeBoolean(cfg.isDaemon());
    w.writeBoolean(true);
    w.writeLong(cfg.getFailureDetectionTimeout());
    w.writeBoolean(true);
    w.writeLong(cfg.getClientFailureDetectionTimeout());
    w.writeBoolean(true);
    w.writeLong(cfg.getLongQueryWarningTimeout());
    w.writeBoolean(true);
    w.writeBoolean(cfg.isActiveOnStart());
    w.writeObject(cfg.getConsistentId());
    // Thread pools.
    w.writeBoolean(true);
    w.writeInt(cfg.getPublicThreadPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getStripedPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getServiceThreadPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getSystemThreadPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getAsyncCallbackPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getManagementThreadPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getDataStreamerThreadPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getUtilityCacheThreadPoolSize());
    w.writeBoolean(true);
    w.writeInt(cfg.getQueryThreadPoolSize());
    CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
    if (cacheCfg != null) {
        w.writeInt(cacheCfg.length);
        for (CacheConfiguration ccfg : cacheCfg) writeCacheConfiguration(w, ccfg);
    } else
        w.writeInt(0);
    writeDiscoveryConfiguration(w, cfg.getDiscoverySpi());
    CommunicationSpi comm = cfg.getCommunicationSpi();
    if (comm instanceof TcpCommunicationSpi) {
        w.writeBoolean(true);
        TcpCommunicationSpi tcp = (TcpCommunicationSpi) comm;
        w.writeInt(tcp.getAckSendThreshold());
        w.writeLong(tcp.getConnectTimeout());
        w.writeBoolean(tcp.isDirectBuffer());
        w.writeBoolean(tcp.isDirectSendBuffer());
        w.writeLong(tcp.getIdleConnectionTimeout());
        w.writeString(tcp.getLocalAddress());
        w.writeInt(tcp.getLocalPort());
        w.writeInt(tcp.getLocalPortRange());
        w.writeLong(tcp.getMaxConnectTimeout());
        w.writeInt(tcp.getMessageQueueLimit());
        w.writeInt(tcp.getReconnectCount());
        w.writeInt(tcp.getSelectorsCount());
        w.writeInt(tcp.getSlowClientQueueLimit());
        w.writeInt(tcp.getSocketReceiveBuffer());
        w.writeInt(tcp.getSocketSendBuffer());
        w.writeBoolean(tcp.isTcpNoDelay());
        w.writeInt(tcp.getUnacknowledgedMessagesBufferSize());
    } else
        w.writeBoolean(false);
    BinaryConfiguration bc = cfg.getBinaryConfiguration();
    if (bc != null) {
        // binary config exists
        w.writeBoolean(true);
        // compact footer is set
        w.writeBoolean(true);
        w.writeBoolean(bc.isCompactFooter());
        w.writeBoolean(bc.getNameMapper() instanceof BinaryBasicNameMapper && ((BinaryBasicNameMapper) (bc.getNameMapper())).isSimpleName());
    } else
        w.writeBoolean(false);
    Map<String, ?> attrs = cfg.getUserAttributes();
    if (attrs != null) {
        w.writeInt(attrs.size());
        for (Map.Entry<String, ?> e : attrs.entrySet()) {
            w.writeString(e.getKey());
            w.writeObject(e.getValue());
        }
    } else
        w.writeInt(0);
    AtomicConfiguration atomic = cfg.getAtomicConfiguration();
    if (atomic != null) {
        w.writeBoolean(true);
        w.writeInt(atomic.getAtomicSequenceReserveSize());
        w.writeInt(atomic.getBackups());
        writeEnumInt(w, atomic.getCacheMode(), AtomicConfiguration.DFLT_CACHE_MODE);
    } else
        w.writeBoolean(false);
    TransactionConfiguration tx = cfg.getTransactionConfiguration();
    if (tx != null) {
        w.writeBoolean(true);
        w.writeInt(tx.getPessimisticTxLogSize());
        writeEnumInt(w, tx.getDefaultTxConcurrency(), TransactionConfiguration.DFLT_TX_CONCURRENCY);
        writeEnumInt(w, tx.getDefaultTxIsolation(), TransactionConfiguration.DFLT_TX_ISOLATION);
        w.writeLong(tx.getDefaultTxTimeout());
        w.writeInt(tx.getPessimisticTxLogLinger());
    } else
        w.writeBoolean(false);
    EventStorageSpi evtStorageSpi = cfg.getEventStorageSpi();
    if (evtStorageSpi == null)
        w.writeByte((byte) 0);
    else if (evtStorageSpi instanceof NoopEventStorageSpi)
        w.writeByte((byte) 1);
    else if (evtStorageSpi instanceof MemoryEventStorageSpi) {
        w.writeByte((byte) 2);
        w.writeLong(((MemoryEventStorageSpi) evtStorageSpi).getExpireCount());
        w.writeLong(((MemoryEventStorageSpi) evtStorageSpi).getExpireAgeMs());
    }
    writeMemoryConfiguration(w, cfg.getMemoryConfiguration());
    writeSqlConnectorConfiguration(w, cfg.getSqlConnectorConfiguration());
    writeClientConnectorConfiguration(w, cfg.getClientConnectorConfiguration());
    w.writeBoolean(cfg.getClientConnectorConfiguration() != null);
    writePersistentStoreConfiguration(w, cfg.getPersistentStoreConfiguration());
    writeDataStorageConfiguration(w, cfg.getDataStorageConfiguration());
    writeSslContextFactory(w, cfg.getSslContextFactory());
    w.writeString(cfg.getIgniteHome());
    w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit());
    w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax());
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) EventStorageSpi(org.apache.ignite.spi.eventstorage.EventStorageSpi) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) NoopEventStorageSpi(org.apache.ignite.spi.eventstorage.NoopEventStorageSpi) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) NoopEventStorageSpi(org.apache.ignite.spi.eventstorage.NoopEventStorageSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) PlatformDotNetBinaryConfiguration(org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 10 with CommunicationSpi

use of org.apache.ignite.spi.communication.CommunicationSpi in project ignite by apache.

the class IgniteCachePartitionedQuerySelfTest method testScanQueryPagination.

/**
 * @throws Exception If failed.
 */
public void testScanQueryPagination() throws Exception {
    final int pageSize = 5;
    final AtomicInteger pages = new AtomicInteger(0);
    IgniteCache<Integer, Integer> cache = jcache(Integer.class, Integer.class);
    for (int i = 0; i < 50; i++) cache.put(i, i);
    CommunicationSpi spi = ignite().configuration().getCommunicationSpi();
    assert spi instanceof TestTcpCommunicationSpi;
    TestTcpCommunicationSpi commSpi = (TestTcpCommunicationSpi) spi;
    commSpi.filter = new IgniteInClosure<Message>() {

        @Override
        public void apply(Message msg) {
            if (!(msg instanceof GridIoMessage))
                return;
            Message msg0 = ((GridIoMessage) msg).message();
            if (msg0 instanceof GridCacheQueryRequest) {
                assertEquals(pageSize, ((GridCacheQueryRequest) msg0).pageSize());
                pages.incrementAndGet();
            } else if (msg0 instanceof GridCacheQueryResponse)
                assertTrue(((GridCacheQueryResponse) msg0).data().size() <= pageSize);
        }
    };
    try {
        ScanQuery<Integer, Integer> qry = new ScanQuery<Integer, Integer>();
        qry.setPageSize(pageSize);
        List<Cache.Entry<Integer, Integer>> all = cache.query(qry).getAll();
        assertTrue(pages.get() > ignite().cluster().forDataNodes(DEFAULT_CACHE_NAME).nodes().size());
        assertEquals(50, all.size());
    } finally {
        commSpi.filter = null;
    }
}
Also used : GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) ScanQuery(org.apache.ignite.cache.query.ScanQuery) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridCacheQueryResponse(org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridCacheQueryRequest(org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest)

Aggregations

CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)13 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)7 UUID (java.util.UUID)4 GridCommunicationClient (org.apache.ignite.internal.util.nio.GridCommunicationClient)4 DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)4 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 IgniteRunnable (org.apache.ignite.lang.IgniteRunnable)2 Message (org.apache.ignite.plugin.extensions.communication.Message)2 GridTestMessage (org.apache.ignite.spi.communication.GridTestMessage)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1