Search in sources :

Example 6 with BinaryConfiguration

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

the class CacheQueryBuildValueTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setMarshaller(null);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(TestBuilderValue.class.getName());
    ArrayList<QueryIndex> idxs = new ArrayList<>();
    QueryIndex idx = new QueryIndex("iVal");
    idxs.add(idx);
    LinkedHashMap<String, String> fields = new LinkedHashMap<>();
    fields.put("iVal", Integer.class.getName());
    entity.setFields(fields);
    entity.setIndexes(idxs);
    ccfg.setQueryEntities(Collections.singleton(entity));
    cfg.setCacheConfiguration(ccfg);
    BinaryConfiguration binaryCfg = new BinaryConfiguration();
    BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
    typeCfg.setTypeName(TestBuilderValue.class.getName());
    binaryCfg.setTypeConfigurations(Collections.singletonList(typeCfg));
    cfg.setBinaryConfiguration(binaryCfg);
    return cfg;
}
Also used : ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) LinkedHashMap(java.util.LinkedHashMap) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) QueryIndex(org.apache.ignite.cache.QueryIndex) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 7 with BinaryConfiguration

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

the class GridCacheBinaryObjectsAbstractDataStreamerSelfTest 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(cacheMode());
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setNearConfiguration(nearConfiguration());
    cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode());
    cfg.setCacheConfiguration(cacheCfg);
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
    cfg.setBinaryConfiguration(bCfg);
    cfg.setMarshaller(new BinaryMarshaller());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 8 with BinaryConfiguration

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

the class GridCacheBinaryStoreAbstractSelfTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@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(Key.class.getName(), Value.class.getName()));
    cfg.setBinaryConfiguration(bCfg);
    cfg.setMarshaller(new BinaryMarshaller());
    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cacheCfg.setCacheStoreFactory(singletonFactory(STORE));
    cacheCfg.setStoreKeepBinary(keepBinaryInStore());
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);
    cfg.setCacheConfiguration(cacheCfg);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(disco);
    GridCacheBinaryStoreAbstractSelfTest.cfg = cfg;
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 9 with BinaryConfiguration

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

the class GridCacheBinaryObjectsAbstractSelfTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(disco);
    CacheConfiguration cacheCfg = createCacheConfig();
    cacheCfg.setCacheStoreFactory(singletonFactory(new TestStore()));
    CacheConfiguration binKeysCacheCfg = createCacheConfig();
    binKeysCacheCfg.setCacheStoreFactory(singletonFactory(new MapCacheStoreStrategy.MapCacheStore()));
    binKeysCacheCfg.setStoreKeepBinary(true);
    binKeysCacheCfg.setName("BinKeysCache");
    cfg.setCacheConfiguration(cacheCfg, binKeysCacheCfg);
    cfg.setMarshaller(new BinaryMarshaller());
    List<BinaryTypeConfiguration> binTypes = new ArrayList<>();
    binTypes.add(new BinaryTypeConfiguration() {

        {
            setTypeName("ArrayHashedKey");
        }
    });
    BinaryConfiguration binCfg = new BinaryConfiguration();
    binCfg.setTypeConfigurations(binTypes);
    cfg.setBinaryConfiguration(binCfg);
    CacheKeyConfiguration arrayHashCfg = new CacheKeyConfiguration("ArrayHashedKey", "fld1");
    cfg.setCacheKeyConfiguration(arrayHashCfg);
    GridCacheBinaryObjectsAbstractSelfTest.cfg = cfg;
    return cfg;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) ArrayList(java.util.ArrayList) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 10 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)

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