Search in sources :

Example 96 with TcpCommunicationSpi

use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.

the class PlatformConfigurationUtils method writeIgniteConfiguration.

/**
     * Writes Ignite configuration.
     *
     * @param w Writer.
     * @param cfg Configuration.
     */
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.writeBoolean(cfg.isLateAffinityAssignment());
    w.writeBoolean(true);
    w.writeLong(cfg.getFailureDetectionTimeout());
    w.writeBoolean(true);
    w.writeLong(cfg.getClientFailureDetectionTimeout());
    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());
    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 97 with TcpCommunicationSpi

use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.

the class GridIoManagerSelfTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    ctx.config().setCommunicationSpi(new TcpCommunicationSpi());
    ctx.config().setMarshaller(new JdkMarshaller());
    // Turn off peer class loading to simplify mocking.
    ctx.config().setPeerClassLoadingEnabled(false);
    // Register local and remote nodes in discovery manager.
    GridDiscoveryManager mockedDiscoveryMgr = Mockito.mock(GridDiscoveryManager.class);
    when(mockedDiscoveryMgr.localNode()).thenReturn(locNode);
    when(mockedDiscoveryMgr.remoteNodes()).thenReturn(F.<ClusterNode>asList(rmtNode));
    ctx.add(mockedDiscoveryMgr);
}
Also used : GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Example 98 with TcpCommunicationSpi

use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi 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 99 with TcpCommunicationSpi

use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.

the class GridCacheAbstractSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    if (isDebug())
        disco.setAckTimeout(Integer.MAX_VALUE);
    cfg.setDiscoverySpi(disco);
    cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName));
    TcpCommunicationSpi comm = new TcpCommunicationSpi();
    comm.setSharedMemoryPort(-1);
    cfg.setCommunicationSpi(comm);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 100 with TcpCommunicationSpi

use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.

the class IgniteCachePutAllRestartTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setPeerClassLoadingEnabled(false);
    ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setName(CACHE_NAME);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setBackups(1);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setNearConfiguration(null);
    cfg.setCacheConfiguration(cacheCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)109 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)94 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)72 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)29 MemoryEventStorageSpi (org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)8 CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)5 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)5 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)5 HashMap (java.util.HashMap)4 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)4 LinkedHashMap (java.util.LinkedHashMap)3 UUID (java.util.UUID)3 IgniteException (org.apache.ignite.IgniteException)3 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)3 DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)3 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2