Search in sources :

Example 31 with BinaryConfiguration

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

the class BinaryConfigurationCustomSerializerSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setConnectorConfiguration(new ConnectorConfiguration());
    cfg.setMarshaller(new BinaryMarshaller());
    BinaryConfiguration binaryCfg = new BinaryConfiguration();
    BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass");
    btc.setIdMapper(BinaryContext.defaultIdMapper());
    btc.setEnum(false);
    // Set custom serializer that is unknown for Optimized marshaller.
    btc.setSerializer(new MyBinarySerializer());
    binaryCfg.setTypeConfigurations(Collections.singletonList(btc));
    cfg.setBinaryConfiguration(binaryCfg);
    // Set custom consistent ID that unknown for Optimized marshaller.
    cfg.setConsistentId(new MyConsistentId("test"));
    cfg.setCacheConfiguration(new CacheConfiguration("TEST"));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 32 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 33 with BinaryConfiguration

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

the class BinaryFieldsAbstractSelfTest method createMarshaller.

/**
 * Create marshaller.
 *
 * @return Binary marshaller.
 * @throws Exception If failed.
 */
protected BinaryMarshaller createMarshaller() throws Exception {
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setCompactFooter(compactFooter());
    bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName()), new BinaryTypeConfiguration(TestOuterObject.class.getName()), new BinaryTypeConfiguration(TestInnerObject.class.getName())));
    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setBinaryConfiguration(bCfg);
    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) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 34 with BinaryConfiguration

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

the class BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
    bCfg.setIdMapper(new BinaryBasicIdMapper(true));
    bCfg.setNameMapper(new BinaryBasicNameMapper(true));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper)

Example 35 with BinaryConfiguration

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

the class GridCacheBinaryObjectUserClassloaderSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(disco);
    cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName));
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setClassLoader(useWrappingLoader ? new WrappingClassLoader(getExternalClassLoader()) : getExternalClassLoader());
    if (customBinaryConf) {
        BinarySerializer bs = new BinarySerializer() {

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

            /**
             * {@inheritDoc}
             */
            @Override
            public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
                deserialized = true;
            }
        };
        BinaryTypeConfiguration btcfg1 = new BinaryTypeConfiguration();
        btcfg1.setTypeName("org.apache.ignite.tests.p2p.CacheDeploymentTestValue");
        btcfg1.setSerializer(bs);
        BinaryTypeConfiguration btcfg2 = new BinaryTypeConfiguration();
        btcfg2.setTypeName("org.apache.ignite.internal.processors.cache.binary." + "GridCacheBinaryObjectUserClassloaderSelfTest$TestValue1");
        btcfg2.setSerializer(bs);
        BinaryConfiguration bcfg = new BinaryConfiguration();
        Set<BinaryTypeConfiguration> set = new HashSet<>();
        set.add(btcfg1);
        set.add(btcfg2);
        bcfg.setTypeConfigurations(set);
        cfg.setBinaryConfiguration(bcfg);
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryWriter(org.apache.ignite.binary.BinaryWriter) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) BinaryReader(org.apache.ignite.binary.BinaryReader) BinarySerializer(org.apache.ignite.binary.BinarySerializer) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) HashSet(java.util.HashSet)

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