Search in sources :

Example 26 with BinaryConfiguration

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

the class BinaryConfigurationConsistencySelfTest method testPositiveEmptyConfig.

/**
     * @throws Exception If failed.
     */
public void testPositiveEmptyConfig() throws Exception {
    binaryCfg = new BinaryConfiguration();
    startGrids(2);
    isClient = true;
    startGrid(2);
}
Also used : BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration)

Example 27 with BinaryConfiguration

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

the class BinaryConfigurationConsistencySelfTest method customConfig.

/**
     * @return Custom BinaryConfiguration.
     * @param compactFooter Compact footer.
     */
private BinaryConfiguration customConfig(boolean compactFooter) {
    BinaryConfiguration c = new BinaryConfiguration();
    c.setIdMapper(new BinaryBasicIdMapper(true));
    c.setSerializer(new BinarySerializer() {

        @Override
        public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
        // No-op.
        }

        @Override
        public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
        // No-op.
        }
    });
    c.setCompactFooter(compactFooter);
    BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass");
    btc.setIdMapper(BinaryContext.defaultIdMapper());
    btc.setEnum(false);
    btc.setSerializer(new BinarySerializer() {

        @Override
        public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
        // No-op.
        }

        @Override
        public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
        // No-op.
        }
    });
    c.setTypeConfigurations(Arrays.asList(btc));
    return c;
}
Also used : BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper) BinaryWriter(org.apache.ignite.binary.BinaryWriter) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) BinaryReader(org.apache.ignite.binary.BinaryReader) BinarySerializer(org.apache.ignite.binary.BinarySerializer) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Example 28 with BinaryConfiguration

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

the class BinaryFieldExtractionSelfTest method createMarshaller.

/**
     * Create marshaller.
     *
     * @return Binary marshaller.
     * @throws Exception If failed.
     */
protected BinaryMarshaller createMarshaller() throws Exception {
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), log());
    BinaryMarshaller marsh = new BinaryMarshaller();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setBinaryConfiguration(bCfg);
    marsh.setContext(new MarshallerContextTestImpl(null));
    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
    return marsh;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 29 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 30 with BinaryConfiguration

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

the class PlatformConfigurationUtils method readIgniteConfiguration.

/**
     * Reads Ignite configuration.
     * @param in Reader.
     * @param cfg Configuration.
     */
public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
    if (in.readBoolean())
        cfg.setClientMode(in.readBoolean());
    int[] eventTypes = in.readIntArray();
    if (eventTypes != null)
        cfg.setIncludeEventTypes(eventTypes);
    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 localHost = in.readString();
    if (localHost != null)
        cfg.setLocalHost(localHost);
    if (in.readBoolean())
        cfg.setDaemon(in.readBoolean());
    if (in.readBoolean())
        cfg.setLateAffinityAssignment(in.readBoolean());
    if (in.readBoolean())
        cfg.setFailureDetectionTimeout(in.readLong());
    if (in.readBoolean())
        cfg.setClientFailureDetectionTimeout(in.readLong());
    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));
    readPluginConfiguration(cfg, in);
}
Also used : 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) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Aggregations

BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)38 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)29 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)18 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)12 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)12 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)11 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)10 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)9 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)6 NullLogger (org.apache.ignite.logger.NullLogger)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)4 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 LinkedHashMap (java.util.LinkedHashMap)3 IgniteException (org.apache.ignite.IgniteException)3 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)3 BinaryIdMapper (org.apache.ignite.binary.BinaryIdMapper)2 BinaryReader (org.apache.ignite.binary.BinaryReader)2 BinarySerializer (org.apache.ignite.binary.BinarySerializer)2