Search in sources :

Example 41 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration 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 42 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class PlatformCppConfigurationClosure method apply0.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("deprecation")
@Override
protected void apply0(IgniteConfiguration igniteCfg) {
    // 3. Validate and copy Interop configuration setting environment pointer along the way.
    PlatformConfiguration interopCfg = igniteCfg.getPlatformConfiguration();
    if (interopCfg != null && !(interopCfg instanceof PlatformCppConfiguration))
        throw new IgniteException("Illegal interop configuration (must be of type " + PlatformCppConfiguration.class.getName() + "): " + interopCfg.getClass().getName());
    PlatformCppConfiguration cppCfg = interopCfg != null ? (PlatformCppConfiguration) interopCfg : null;
    if (cppCfg == null)
        cppCfg = new PlatformCppConfiguration();
    PlatformMemoryManagerImpl memMgr = new PlatformMemoryManagerImpl(gate, 1024);
    PlatformCppConfigurationEx cppCfg0 = new PlatformCppConfigurationEx(cppCfg, gate, memMgr);
    igniteCfg.setPlatformConfiguration(cppCfg0);
    // Check marshaller
    Marshaller marsh = igniteCfg.getMarshaller();
    if (marsh == null) {
        igniteCfg.setMarshaller(new BinaryMarshaller());
        cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to " + BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
    } else if (!(marsh instanceof BinaryMarshaller))
        throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() + " can be used when running Apache Ignite C++): " + marsh.getClass().getName());
    BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration();
    if (bCfg == null) {
        bCfg = new BinaryConfiguration();
        bCfg.setCompactFooter(false);
        bCfg.setNameMapper(new BinaryBasicNameMapper(true));
        bCfg.setIdMapper(new BinaryBasicIdMapper(true));
        igniteCfg.setBinaryConfiguration(bCfg);
        cppCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " + "note that binary name mapper is set to " + bCfg.getNameMapper() + " and binary ID mapper is set to " + bCfg.getIdMapper() + " (other nodes must have the same binary name and ID mapper types)."));
    } else {
        BinaryNameMapper nameMapper = bCfg.getNameMapper();
        if (nameMapper == null) {
            bCfg.setNameMapper(new BinaryBasicNameMapper(true));
            cppCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " + bCfg.getNameMapper() + " (other nodes must have the same binary name mapper type)."));
        }
        BinaryIdMapper idMapper = bCfg.getIdMapper();
        if (idMapper == null) {
            bCfg.setIdMapper(new BinaryBasicIdMapper(true));
            cppCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " + bCfg.getIdMapper() + " (other nodes must have the same binary ID mapper type)."));
        }
    }
    if (bCfg.isCompactFooter())
        throw new IgniteException("Unsupported " + BinaryMarshaller.class.getName() + " \"compactFooter\" flag: must be false when running Apache Ignite C++.");
    // Set Ignite home so that marshaller context works.
    String ggHome = igniteCfg.getIgniteHome();
    if (ggHome != null)
        U.setIgniteHome(ggHome);
}
Also used : PlatformConfiguration(org.apache.ignite.configuration.PlatformConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) PlatformCppConfiguration(org.apache.ignite.platform.cpp.PlatformCppConfiguration) IgniteException(org.apache.ignite.IgniteException) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryNameMapper(org.apache.ignite.binary.BinaryNameMapper) PlatformMemoryManagerImpl(org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl)

Example 43 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class PlatformDotNetConfigurationClosure method setBinaryConfiguration.

/**
 * Sets binary config.
 *
 * @param igniteCfg Ignite config.
 * @param dotNetCfg .NET config.
 */
private void setBinaryConfiguration(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx dotNetCfg) {
    // Check marshaller.
    Marshaller marsh = igniteCfg.getMarshaller();
    if (marsh == null) {
        igniteCfg.setMarshaller(new BinaryMarshaller());
        dotNetCfg.warnings(Collections.singleton("Marshaller is automatically set to " + BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
    } else if (!(marsh instanceof BinaryMarshaller))
        throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() + " can be used when running Apache Ignite.NET): " + marsh.getClass().getName());
    BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration();
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) IgniteException(org.apache.ignite.IgniteException)

Example 44 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class GridCacheUtilsSelfTest method binaryMarshaller.

/**
 * @return Binary marshaller.
 * @throws IgniteCheckedException if failed.
 */
private BinaryMarshaller binaryMarshaller() throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    iCfg.setBinaryConfiguration(bCfg);
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(new MarshallerContextTestImpl(null));
    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
    return marsh;
}
Also used : NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 45 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class IgnitePdsNoActualWalHistoryTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(CACHE_NAME);
    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    cfg.setCacheConfiguration(ccfg);
    DataStorageConfiguration dbCfg = new DataStorageConfiguration();
    dbCfg.setPageSize(4 * 1024);
    cfg.setDataStorageConfiguration(dbCfg);
    dbCfg.setWalSegmentSize(4 * 1024 * 1024).setWalHistorySize(2).setWalSegments(10).setWalMode(WALMode.LOG_ONLY).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(100 * 1024 * 1024).setPersistenceEnabled(true));
    cfg.setMarshaller(null);
    BinaryConfiguration binCfg = new BinaryConfiguration();
    binCfg.setCompactFooter(false);
    cfg.setBinaryConfiguration(binCfg);
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)59 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)49 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)26 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)20 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)19 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)17 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)16 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)14 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)11 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)10 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)10 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)5 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)5 NullLogger (org.apache.ignite.logger.NullLogger)5 LinkedHashMap (java.util.LinkedHashMap)4 IgniteException (org.apache.ignite.IgniteException)4 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)4