Search in sources :

Example 21 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 22 with BinaryConfiguration

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

the class BinaryObjectExceptionSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
    cfg.setCacheConfiguration(new CacheConfiguration(cacheName).setCopyOnRead(true));
    BinaryConfiguration bcfg = new BinaryConfiguration().setNameMapper(new BinaryBasicNameMapper(false));
    cfg.setBinaryConfiguration(bcfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 23 with BinaryConfiguration

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

the class GridAbstractTest method getConfiguration.

/**
 * This method should be overridden by subclasses to change configuration parameters.
 *
 * @param igniteInstanceName Ignite instance name.
 * @return Grid configuration used for starting of grid.
 * @throws Exception If failed.
 */
@SuppressWarnings("deprecation")
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = getConfiguration(igniteInstanceName, getTestResources());
    cfg.setNodeId(null);
    if (GridTestProperties.getProperty(GridTestProperties.BINARY_COMPACT_FOOTERS) != null) {
        if (!Boolean.valueOf(GridTestProperties.getProperty(GridTestProperties.BINARY_COMPACT_FOOTERS))) {
            BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
            if (bCfg == null) {
                bCfg = new BinaryConfiguration();
                cfg.setBinaryConfiguration(bCfg);
            }
            bCfg.setCompactFooter(false);
        }
    }
    if (Boolean.valueOf(GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER))) {
        BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
        if (bCfg == null) {
            bCfg = new BinaryConfiguration();
            cfg.setBinaryConfiguration(bCfg);
        }
        bCfg.setNameMapper(new BinaryBasicNameMapper(true));
    }
    if (igniteInstanceName != null && igniteInstanceName.matches(".*\\d")) {
        String idStr = UUID.randomUUID().toString();
        if (igniteInstanceName.startsWith(getTestIgniteInstanceName())) {
            String idxStr = String.valueOf(getTestIgniteInstanceIndex(igniteInstanceName));
            while (idxStr.length() < 5) idxStr = '0' + idxStr;
            char[] chars = idStr.toCharArray();
            for (int i = 0; i < idxStr.length(); i++) chars[chars.length - idxStr.length() + i] = idxStr.charAt(i);
            cfg.setNodeId(UUID.fromString(new String(chars)));
        } else {
            char[] chars = idStr.toCharArray();
            chars[0] = igniteInstanceName.charAt(igniteInstanceName.length() - 1);
            chars[1] = '0';
            chars[chars.length - 3] = '0';
            chars[chars.length - 2] = '0';
            chars[chars.length - 1] = igniteInstanceName.charAt(igniteInstanceName.length() - 1);
            cfg.setNodeId(UUID.fromString(new String(chars)));
        }
    }
    if (isMultiJvm())
        ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(LOCAL_IP_FINDER);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper)

Example 24 with BinaryConfiguration

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

the class CacheObjectBinaryProcessorImpl method start.

/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
    if (marsh instanceof BinaryMarshaller) {
        if (ctx.clientNode())
            ctx.event().addLocalEventListener(clientDisconLsnr, EVT_CLIENT_NODE_DISCONNECTED);
        transport = new BinaryMetadataTransport(metadataLocCache, ctx, log);
        BinaryMetadataHandler metaHnd = new BinaryMetadataHandler() {

            @Override
            public void addMeta(int typeId, BinaryType newMeta) throws BinaryObjectException {
                assert newMeta != null;
                assert newMeta instanceof BinaryTypeImpl;
                if (!discoveryStarted) {
                    BinaryMetadataHolder holder = metadataLocCache.get(typeId);
                    BinaryMetadata oldMeta = holder != null ? holder.metadata() : null;
                    BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, ((BinaryTypeImpl) newMeta).metadata());
                    if (oldMeta != mergedMeta)
                        metadataLocCache.putIfAbsent(typeId, new BinaryMetadataHolder(mergedMeta, 0, 0));
                    return;
                }
                BinaryMetadata newMeta0 = ((BinaryTypeImpl) newMeta).metadata();
                CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(binaryCtx));
            }

            @Override
            public BinaryType metadata(int typeId) throws BinaryObjectException {
                return CacheObjectBinaryProcessorImpl.this.metadata(typeId);
            }

            @Override
            public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
                return CacheObjectBinaryProcessorImpl.this.metadata0(typeId);
            }

            @Override
            public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
                return CacheObjectBinaryProcessorImpl.this.metadata(typeId, schemaId);
            }
        };
        BinaryMarshaller bMarsh0 = (BinaryMarshaller) marsh;
        binaryCtx = new BinaryContext(metaHnd, ctx.config(), ctx.log(BinaryContext.class));
        IgniteUtils.invoke(BinaryMarshaller.class, bMarsh0, "setBinaryContext", binaryCtx, ctx.config());
        binaryMarsh = new GridBinaryMarshaller(binaryCtx);
        binaries = new IgniteBinaryImpl(ctx, this);
        if (!getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK)) {
            BinaryConfiguration bCfg = ctx.config().getBinaryConfiguration();
            if (bCfg != null) {
                Map<String, Object> map = new HashMap<>();
                map.put("globIdMapper", bCfg.getIdMapper() != null ? bCfg.getIdMapper().getClass().getName() : null);
                map.put("globSerializer", bCfg.getSerializer() != null ? bCfg.getSerializer().getClass() : null);
                map.put("compactFooter", bCfg.isCompactFooter());
                if (bCfg.getTypeConfigurations() != null) {
                    Map<Object, Object> typeCfgsMap = new HashMap<>();
                    for (BinaryTypeConfiguration c : bCfg.getTypeConfigurations()) {
                        typeCfgsMap.put(c.getTypeName() != null, Arrays.asList(c.getIdMapper() != null ? c.getIdMapper().getClass() : null, c.getSerializer() != null ? c.getSerializer().getClass() : null, c.isEnum()));
                        if (c.isEnum())
                            BinaryUtils.validateEnumValues(c.getTypeName(), c.getEnumValues());
                    }
                    map.put("typeCfgs", typeCfgsMap);
                }
                ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION, map);
            }
        }
    }
}
Also used : BinaryTypeImpl(org.apache.ignite.internal.binary.BinaryTypeImpl) BinaryType(org.apache.ignite.binary.BinaryType) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) BinaryMetadataHandler(org.apache.ignite.internal.binary.BinaryMetadataHandler) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) BinaryObject(org.apache.ignite.binary.BinaryObject) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 25 with BinaryConfiguration

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

the class GridDefaultBinaryMappersBinaryMetaDataSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setNameMapper(new BinaryBasicNameMapper(false));
    bCfg.setIdMapper(new BinaryBasicIdMapper(false));
    bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
    cfg.setBinaryConfiguration(bCfg);
    cfg.setMarshaller(new BinaryMarshaller());
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cfg.setCacheConfiguration(ccfg);
    GridDefaultBinaryMappersBinaryMetaDataSelfTest.cfg = cfg;
    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) 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