Search in sources :

Example 76 with TcpCommunicationSpi

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

the class PlatformConfigurationUtils method readIgniteConfiguration.

/**
 * Reads Ignite configuration.
 * @param in Reader.
 * @param cfg Configuration.
 */
@SuppressWarnings("deprecation")
public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
    if (in.readBoolean())
        cfg.setClientMode(in.readBoolean());
    int[] evtTypes = in.readIntArray();
    if (evtTypes != null)
        cfg.setIncludeEventTypes(evtTypes);
    if (in.readBoolean())
        cfg.setMetricsExpireTime(in.readLong());
    if (in.readBoolean())
        cfg.setMetricsHistorySize(in.readInt());
    if (in.readBoolean())
        cfg.setMetricsLogFrequency(in.readLong());
    if (in.readBoolean())
        cfg.setMetricsUpdateFrequency(in.readLong());
    if (in.readBoolean())
        cfg.setNetworkSendRetryCount(in.readInt());
    if (in.readBoolean())
        cfg.setNetworkSendRetryDelay(in.readLong());
    if (in.readBoolean())
        cfg.setNetworkTimeout(in.readLong());
    String workDir = in.readString();
    if (workDir != null)
        cfg.setWorkDirectory(workDir);
    String locHost = in.readString();
    if (locHost != null)
        cfg.setLocalHost(locHost);
    if (in.readBoolean())
        cfg.setDaemon(in.readBoolean());
    if (in.readBoolean())
        cfg.setFailureDetectionTimeout(in.readLong());
    if (in.readBoolean())
        cfg.setClientFailureDetectionTimeout(in.readLong());
    if (in.readBoolean())
        cfg.setLongQueryWarningTimeout(in.readLong());
    if (in.readBoolean())
        cfg.setActiveOnStart(in.readBoolean());
    Object consId = in.readObjectDetached();
    if (consId instanceof Serializable) {
        cfg.setConsistentId((Serializable) consId);
    } else if (consId != null) {
        throw new IgniteException("IgniteConfiguration.ConsistentId should be Serializable.");
    }
    // Thread pools.
    if (in.readBoolean())
        cfg.setPublicThreadPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setStripedPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setServiceThreadPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setSystemThreadPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setAsyncCallbackPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setManagementThreadPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setDataStreamerThreadPoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setUtilityCachePoolSize(in.readInt());
    if (in.readBoolean())
        cfg.setQueryThreadPoolSize(in.readInt());
    readCacheConfigurations(in, cfg);
    readDiscoveryConfiguration(in, cfg);
    if (in.readBoolean()) {
        TcpCommunicationSpi comm = new TcpCommunicationSpi();
        comm.setAckSendThreshold(in.readInt());
        comm.setConnectTimeout(in.readLong());
        comm.setDirectBuffer(in.readBoolean());
        comm.setDirectSendBuffer(in.readBoolean());
        comm.setIdleConnectionTimeout(in.readLong());
        comm.setLocalAddress(in.readString());
        comm.setLocalPort(in.readInt());
        comm.setLocalPortRange(in.readInt());
        comm.setMaxConnectTimeout(in.readLong());
        comm.setMessageQueueLimit(in.readInt());
        comm.setReconnectCount(in.readInt());
        comm.setSelectorsCount(in.readInt());
        comm.setSlowClientQueueLimit(in.readInt());
        comm.setSocketReceiveBuffer(in.readInt());
        comm.setSocketSendBuffer(in.readInt());
        comm.setTcpNoDelay(in.readBoolean());
        comm.setUnacknowledgedMessagesBufferSize(in.readInt());
        cfg.setCommunicationSpi(comm);
    }
    if (in.readBoolean()) {
        // binary config is present
        if (cfg.getBinaryConfiguration() == null)
            cfg.setBinaryConfiguration(new BinaryConfiguration());
        if (// compact footer is set
        in.readBoolean())
            cfg.getBinaryConfiguration().setCompactFooter(in.readBoolean());
        if (in.readBoolean()) {
            // Simple name mapper.
            cfg.getBinaryConfiguration().setNameMapper(new BinaryBasicNameMapper(true));
        }
    }
    int attrCnt = in.readInt();
    if (attrCnt > 0) {
        Map<String, Object> attrs = new HashMap<>(attrCnt);
        for (int i = 0; i < attrCnt; i++) attrs.put(in.readString(), in.readObject());
        cfg.setUserAttributes(attrs);
    }
    if (in.readBoolean()) {
        AtomicConfiguration atomic = new AtomicConfiguration();
        atomic.setAtomicSequenceReserveSize(in.readInt());
        atomic.setBackups(in.readInt());
        atomic.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
        cfg.setAtomicConfiguration(atomic);
    }
    if (in.readBoolean()) {
        TransactionConfiguration tx = new TransactionConfiguration();
        tx.setPessimisticTxLogSize(in.readInt());
        tx.setDefaultTxConcurrency(TransactionConcurrency.fromOrdinal(in.readInt()));
        tx.setDefaultTxIsolation(TransactionIsolation.fromOrdinal(in.readInt()));
        tx.setDefaultTxTimeout(in.readLong());
        tx.setPessimisticTxLogLinger(in.readInt());
        cfg.setTransactionConfiguration(tx);
    }
    switch(in.readByte()) {
        case 1:
            cfg.setEventStorageSpi(new NoopEventStorageSpi());
            break;
        case 2:
            cfg.setEventStorageSpi(new MemoryEventStorageSpi().setExpireCount(in.readLong()).setExpireAgeMs(in.readLong()));
            break;
    }
    if (in.readBoolean())
        cfg.setMemoryConfiguration(readMemoryConfiguration(in));
    if (in.readBoolean())
        cfg.setSqlConnectorConfiguration(readSqlConnectorConfiguration(in));
    if (in.readBoolean())
        cfg.setClientConnectorConfiguration(readClientConnectorConfiguration(in));
    if (// ClientConnectorConfigurationEnabled override
    !in.readBoolean())
        cfg.setClientConnectorConfiguration(null);
    if (in.readBoolean())
        cfg.setPersistentStoreConfiguration(readPersistentStoreConfiguration(in));
    if (in.readBoolean())
        cfg.setDataStorageConfiguration(readDataStorageConfiguration(in));
    if (in.readBoolean())
        cfg.setSslContextFactory(readSslContextFactory(in));
    readPluginConfiguration(cfg, in);
    readLocalEventListeners(cfg, in);
}
Also used : Serializable(java.io.Serializable) TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) 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) IgniteException(org.apache.ignite.IgniteException) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Example 77 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.
 */
@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 78 with TcpCommunicationSpi

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

the class SingleSplitsLoadTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("ConstantConditions")
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();
    cfg.setCommunicationSpi(new TcpCommunicationSpi());
    cfg.setDiscoverySpi(new TcpDiscoverySpi());
    Log4JLogger log = (Log4JLogger) cfg.getGridLogger().getLogger(null);
    log.setLevel(Level.INFO);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 79 with TcpCommunicationSpi

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

the class IgniteTxConfigCacheSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    TcpCommunicationSpi commSpi = new TestCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setBackups(1);
    cfg.setCacheConfiguration(ccfg);
    final TransactionConfiguration txCfg = new TransactionConfiguration();
    txCfg.setDefaultTxTimeout(TX_TIMEOUT);
    cfg.setTransactionConfiguration(txCfg);
    return cfg;
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) 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)

Example 80 with TcpCommunicationSpi

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

the class IgniteCacheCommitDelayTxRecoveryTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
    cfg.setClientMode(client);
    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)

Aggregations

TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)113 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)98 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)75 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)30 MemoryEventStorageSpi (org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)8 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)6 CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)6 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)5 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)5 HashMap (java.util.HashMap)4 IgniteException (org.apache.ignite.IgniteException)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)4 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)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 DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)3 ArrayList (java.util.ArrayList)2