Search in sources :

Example 1 with BinaryConfiguration

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

the class BinaryContext method configure.

/**
     * @param marsh Binary marshaller.
     * @param cfg Configuration.
     * @throws BinaryObjectException In case of error.
     */
public void configure(BinaryMarshaller marsh, IgniteConfiguration cfg) throws BinaryObjectException {
    if (marsh == null)
        return;
    this.marsh = marsh;
    marshCtx = marsh.getContext();
    BinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
    if (binaryCfg == null)
        binaryCfg = new BinaryConfiguration();
    assert marshCtx != null;
    optmMarsh.setContext(marshCtx);
    configure(binaryCfg.getNameMapper(), binaryCfg.getIdMapper(), binaryCfg.getSerializer(), binaryCfg.getTypeConfigurations());
    compactFooter = binaryCfg.isCompactFooter();
}
Also used : BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration)

Example 2 with BinaryConfiguration

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

the class GridBinaryAffinityKeySelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
    typeCfg.setTypeName(TestObject.class.getName());
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setTypeConfigurations(Collections.singleton(typeCfg));
    cfg.setBinaryConfiguration(bCfg);
    CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestObject.class.getName(), "affKey");
    CacheKeyConfiguration keyCfg2 = new CacheKeyConfiguration("TestObject2", "affKey");
    cfg.setCacheKeyConfiguration(keyCfg, keyCfg2);
    cfg.setMarshaller(new BinaryMarshaller());
    if (!igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT))) {
        CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        cacheCfg.setCacheMode(PARTITIONED);
        cfg.setCacheConfiguration(cacheCfg);
    }
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    return cfg;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with BinaryConfiguration

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

the class GridBinaryWildcardsSelfTest method binaryMarshaller.

/**
     *
     */
protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs) throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setNameMapper(nameMapper);
    bCfg.setIdMapper(mapper);
    bCfg.setSerializer(serializer);
    bCfg.setTypeConfigurations(cfgs);
    iCfg.setBinaryConfiguration(bCfg);
    BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), 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) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 4 with BinaryConfiguration

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

the class BinaryObjectBuilderDefaultMappersSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
    customTypeCfg.setTypeName(CustomIdMapper.class.getName());
    customTypeCfg.setIdMapper(new BinaryIdMapper() {

        @Override
        public int typeId(String clsName) {
            return ~BinaryContext.defaultIdMapper().typeId(clsName);
        }

        @Override
        public int fieldId(int typeId, String fieldName) {
            return typeId + ~BinaryContext.defaultIdMapper().fieldId(typeId, fieldName);
        }
    });
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setCompactFooter(compactFooter());
    bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()), new BinaryTypeConfiguration(Value.class.getName()), new BinaryTypeConfiguration("org.gridgain.grid.internal.util.binary.mutabletest.*"), customTypeCfg));
    bCfg.setIdMapper(new BinaryBasicIdMapper(false));
    bCfg.setNameMapper(new BinaryBasicNameMapper(false));
    cfg.setBinaryConfiguration(bCfg);
    cfg.setMarshaller(new BinaryMarshaller());
    this.cfg = cfg;
    return cfg;
}
Also used : BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration)

Example 5 with BinaryConfiguration

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

the class BinaryObjectBuilderAdditionalSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cacheCfg.setCacheMode(REPLICATED);
    CacheConfiguration cacheCfg2 = new CacheConfiguration("partitioned");
    cacheCfg2.setCacheMode(PARTITIONED);
    cfg.setCacheConfiguration(cacheCfg, cacheCfg2);
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setCompactFooter(compactFooter());
    bCfg.setClassNames(Arrays.asList("org.apache.ignite.internal.binary.mutabletest.*"));
    cfg.setMarshaller(new BinaryMarshaller());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

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