Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#setBinaryConfiguration()

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setBinaryConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BinaryObjectExceptionSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setMarshaller(new BinaryMarshaller());

    cfg.setCacheConfiguration(
        new CacheConfiguration(cacheName)
            .setCopyOnRead(true)
    );

    BinaryConfiguration bcfg = new BinaryConfiguration()
            .setNameMapper(new BinaryBasicNameMapper(false));

    cfg.setBinaryConfiguration(bcfg);

    return cfg;
}
 
Example 2
Source File: GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@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;
}
 
Example 3
Source File: IgnitePersistentStoreCacheGroupsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setConsistentId(gridName);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))
        .setPageSize(1024)
        .setWalMode(WALMode.LOG_ONLY);

    cfg.setDataStorageConfiguration(memCfg);

    cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false));

    if (ccfgs != null) {
        cfg.setCacheConfiguration(ccfgs);

        ccfgs = null;
    }

    return cfg;
}
 
Example 4
Source File: IgniteTestConfigurationBuilder.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 6 votes vote down vote up
private IgniteConfiguration createConfig() {
	IgniteConfiguration config = new IgniteConfiguration();
	config.setIgniteInstanceName( "OgmTestGrid" );
	config.setClientMode( false );
	BinaryConfiguration binaryConfiguration = new BinaryConfiguration();
	binaryConfiguration.setNameMapper( new BinaryBasicNameMapper( true ) );
	binaryConfiguration.setCompactFooter( false ); // it is necessary only for embedded collections (@ElementCollection)
	config.setBinaryConfiguration( binaryConfiguration );
	TransactionConfiguration transactionConfiguration = new TransactionConfiguration();
	// I'm going to use PESSIMISTIC here because some people had problem with it and it would be nice if tests
	// can highlight the issue. Ideally, we would want to test the different concurrency and isolation level.
	transactionConfiguration.setDefaultTxConcurrency( TransactionConcurrency.PESSIMISTIC );
	transactionConfiguration.setDefaultTxIsolation( TransactionIsolation.READ_COMMITTED );
	config.setTransactionConfiguration( transactionConfiguration );

	return config;
}
 
Example 5
Source File: IgniteCacheAbstractInsertSqlQuerySelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    BinaryConfiguration binCfg = new BinaryConfiguration();

    binCfg.setTypeConfigurations(Arrays.asList(
        new BinaryTypeConfiguration() {{
            setTypeName(Key.class.getName());
        }},
        new BinaryTypeConfiguration() {{
            setTypeName(Key2.class.getName());
        }}
    ));

    cfg.setBinaryConfiguration(binCfg);

    cfg.setPeerClassLoadingEnabled(false);

    return cfg;
}
 
Example 6
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @return Binary marshaller.
 */
protected BinaryMarshaller binaryMarshaller(
    BinaryNameMapper nameMapper,
    BinaryIdMapper mapper,
    BinarySerializer serializer,
    Collection<BinaryTypeConfiguration> cfgs,
    Collection<String> excludedClasses
) throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration();

    BinaryConfiguration bCfg = new BinaryConfiguration();

    bCfg.setNameMapper(nameMapper);
    bCfg.setIdMapper(mapper);
    bCfg.setSerializer(serializer);
    bCfg.setCompactFooter(compactFooter());

    bCfg.setTypeConfigurations(cfgs);

    iCfg.setBinaryConfiguration(bCfg);
    iCfg.setClientMode(false);
    iCfg.setDiscoverySpi(new TcpDiscoverySpi() {
        @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
            //No-op.
        }
    });
    iCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());

    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());

    BinaryMarshaller marsh = new BinaryMarshaller();

    MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null, excludedClasses);

    GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg);

    kernCtx.add(new GridSystemViewManager(kernCtx));
    kernCtx.add(new GridDiscoveryManager(kernCtx));

    marshCtx.onMarshallerProcessorStarted(kernCtx, null);

    marsh.setContext(marshCtx);

    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);

    return marsh;
}
 
Example 7
Source File: BinaryArrayIdentityResolverSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setMarshaller(new BinaryMarshaller());

    BinaryConfiguration binCfg = new BinaryConfiguration();

    BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration();
    BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration();

    binTypCfg1.setTypeName(InnerClass.class.getName());
    binTypCfg2.setTypeName(InnerClassBinarylizable.class.getName());

    List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();

    binTypCfgs.add(binTypCfg1);
    binTypCfgs.add(binTypCfg2);

    binCfg.setTypeConfigurations(binTypCfgs);

    cfg.setBinaryConfiguration(binCfg);

    return cfg;
}
 
Example 8
Source File: IgniteMassLoadSandboxTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<Integer, HugeIndexedObject> ccfg = new CacheConfiguration<>();

    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 1024));
    ccfg.setIndexedTypes(Integer.class, HugeIndexedObject.class);
    ccfg.setName(CACHE_NAME);

    cfg.setCacheConfiguration(ccfg);

    DataRegionConfiguration regCfg = new DataRegionConfiguration()
        .setName("dfltMemPlc")
        .setMetricsEnabled(true)
        .setMaxSize(2 * 1024L * 1024 * 1024)
        .setPersistenceEnabled(true);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration();

    dsCfg.setDefaultDataRegionConfiguration(regCfg)
        .setPageSize(4 * 1024)
        .setWriteThrottlingEnabled(true)
        .setCheckpointFrequency(checkpointFrequency);

    final String workDir = U.defaultWorkDirectory();
    final File db = U.resolveWorkDirectory(workDir, DFLT_STORE_DIR, false);
    final File wal = new File(db, "wal");
    if (setWalArchAndWorkToSameVal) {
        final String walAbsPath = wal.getAbsolutePath();

        dsCfg.setWalPath(walAbsPath);

        dsCfg.setWalArchivePath(walAbsPath);
    }
    else {
        dsCfg.setWalPath(wal.getAbsolutePath());

        dsCfg.setWalArchivePath(new File(wal, "archive").getAbsolutePath());
    }

    dsCfg.setWalMode(customWalMode != null ? customWalMode : WALMode.LOG_ONLY)
        .setWalHistorySize(1)
        .setWalSegments(10);

    if (walSegmentSize != 0)
        dsCfg.setWalSegmentSize(walSegmentSize);

    cfg.setDataStorageConfiguration(dsCfg);

    cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false));

    return cfg;
}
 
Example 9
Source File: BinaryFieldExtractionSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: BinarySerializationQuerySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    cfg.setDiscoverySpi(discoSpi);

    cfg.setMarshaller(new BinaryMarshaller());

    if (useReflectiveSerializer()) {
        BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration(EntityPlain.class.getName());
        BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration(EntitySerializable.class.getName());
        BinaryTypeConfiguration binTypCfg3 = new BinaryTypeConfiguration(EntityExternalizable.class.getName());
        BinaryTypeConfiguration binTypCfg4 = new BinaryTypeConfiguration(EntityBinarylizable.class.getName());
        BinaryTypeConfiguration binTypCfg5 = new BinaryTypeConfiguration(EntityWriteReadObject.class.getName());

        binTypCfg1.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg2.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg3.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg4.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg5.setSerializer(new BinaryReflectiveSerializer());

        List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();

        binTypCfgs.add(binTypCfg1);
        binTypCfgs.add(binTypCfg2);
        binTypCfgs.add(binTypCfg3);
        binTypCfgs.add(binTypCfg4);
        binTypCfgs.add(binTypCfg5);

        BinaryConfiguration binCfg = new BinaryConfiguration();

        binCfg.setTypeConfigurations(binTypCfgs);

        cfg.setBinaryConfiguration(binCfg);
    }

    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);

    List<QueryEntity> queryEntities = new ArrayList<>();

    queryEntities.add(entityForClass(EntityPlain.class));
    queryEntities.add(entityForClass(EntitySerializable.class));
    queryEntities.add(entityForClass(EntityExternalizable.class));
    queryEntities.add(entityForClass(EntityBinarylizable.class));
    queryEntities.add(entityForClass(EntityWriteReadObject.class));

    cacheCfg.setQueryEntities(queryEntities);

    cfg.setCacheConfiguration(cacheCfg);

    ignite = Ignition.start(cfg);

    cache = ignite.cache(DEFAULT_CACHE_NAME);
}
 
Example 11
Source File: FunctionalQueryTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Tested API:
 * <ul>
 * <li>{@link ClientCache#query(Query)}</li>
 * </ul>
 */
@Test
public void testQueries() throws Exception {
    IgniteConfiguration srvCfg = Config.getServerConfiguration();

    // No peer class loading from thin clients: we need the server to know about this class to deserialize
    // ScanQuery filter.
    srvCfg.setBinaryConfiguration(new BinaryConfiguration().setTypeConfigurations(Arrays.asList(
        new BinaryTypeConfiguration(getClass().getName()),
        new BinaryTypeConfiguration(SerializedLambda.class.getName())
    )));

    try (Ignite ignored = Ignition.start(srvCfg);
         IgniteClient client = Ignition.startClient(getClientConfiguration())
    ) {
        ClientCache<Integer, Person> cache = client.getOrCreateCache(Config.DEFAULT_CACHE_NAME);

        Map<Integer, Person> data = IntStream.rangeClosed(1, 100).boxed()
            .collect(Collectors.toMap(i -> i, i -> new Person(i, String.format("Person %s", i))));

        cache.putAll(data);

        int minId = data.size() / 2 + 1;
        int pageSize = (data.size() - minId) / 3;
        int expSize = data.size() - minId + 1; // expected query result size

        // Expected result
        Map<Integer, Person> exp = data.entrySet().stream()
            .filter(e -> e.getKey() >= minId)
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

        // Scan and SQL queries
        Collection<Query<Cache.Entry<Integer, Person>>> queries = Arrays.asList(
            new ScanQuery<Integer, Person>((i, p) -> p.getId() >= minId).setPageSize(pageSize),
            new SqlQuery<Integer, Person>(Person.class, "id >= ?").setArgs(minId).setPageSize(pageSize)
        );

        for (Query<Cache.Entry<Integer, Person>> qry : queries) {
            try (QueryCursor<Cache.Entry<Integer, Person>> cur = cache.query(qry)) {
                List<Cache.Entry<Integer, Person>> res = cur.getAll();

                assertEquals(
                    String.format("Unexpected number of rows from %s", qry.getClass().getSimpleName()),
                    expSize, res.size()
                );

                Map<Integer, Person> act = res.stream()
                    .collect(Collectors.toMap(Cache.Entry::getKey, Cache.Entry::getValue));

                assertEquals(String.format("unexpected rows from %s", qry.getClass().getSimpleName()), exp, act);
            }
        }

        checkSqlFieldsQuery(cache, minId, pageSize, expSize, exp, true);
        checkSqlFieldsQuery(cache, minId, pageSize, expSize, exp, false);
    }
}
 
Example 12
Source File: GridCacheAffinityRoutingBinarySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();

    typeCfg.setTypeName(AffinityTestKey.class.getName());

    CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(AffinityTestKey.class.getName(), "affKey");

    cfg.setCacheKeyConfiguration(keyCfg);

    BinaryConfiguration bCfg = new BinaryConfiguration();

    bCfg.setTypeConfigurations(Collections.singleton(typeCfg));

    cfg.setBinaryConfiguration(bCfg);

    cfg.setMarshaller(new BinaryMarshaller());

    return cfg;
}
 
Example 13
Source File: CacheQueryBuildValueTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setMarshaller(null);

    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;
}
 
Example 14
Source File: GridBinaryAffinityKeySelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@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);
    }

    return cfg;
}
 
Example 15
Source File: IgniteServiceProxyTimeoutInitializedTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    final ServiceConfiguration scfg = new ServiceConfiguration();

    if (igniteInstanceName.endsWith("0")) {
        scfg.setName("testService");
        scfg.setService(srvc);
        scfg.setMaxPerNodeCount(1);
        scfg.setTotalCount(1);
        scfg.setNodeFilter(new NodeFilter());

        final Map<String, String> attrs = new HashMap<>();

        attrs.put("clusterGroup", "0");

        cfg.setUserAttributes(attrs);

        cfg.setServiceConfiguration(scfg);
    }

    cfg.setMarshaller(null);

    final BinaryConfiguration binCfg = new BinaryConfiguration();

    // Despite defaults explicitly set to lower case.
    binCfg.setIdMapper(new BinaryBasicIdMapper(true));

    cfg.setBinaryConfiguration(binCfg);

    return cfg;
}
 
Example 16
Source File: IgnitePdsMultiNodePutGetRestartTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setClusterStateOnStart(ClusterState.INACTIVE);

    cfg.setConsistentId(gridName);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))
        .setWalMode(WALMode.LOG_ONLY).setWalSegmentSize(4 * 1024 * 1024);

    cfg.setDataStorageConfiguration(memCfg);

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);

    ccfg.setIndexedTypes(Integer.class, DbValue.class);

    ccfg.setRebalanceMode(CacheRebalanceMode.NONE);

    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

    cfg.setCacheConfiguration(ccfg);

    cfg.setMarshaller(null);

    BinaryConfiguration bCfg = new BinaryConfiguration();

    bCfg.setCompactFooter(false);

    cfg.setBinaryConfiguration(bCfg);

    return cfg;
}
 
Example 17
Source File: BinaryFieldsAbstractSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: GridCacheBinaryStoreAbstractSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@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);

    GridCacheBinaryStoreAbstractSelfTest.cfg = cfg;

    return cfg;
}
 
Example 19
Source File: BinaryConfigurationConsistencySelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setMarshaller(new BinaryMarshaller());

    cfg.setBinaryConfiguration(binaryCfg);

    return cfg;
}
 
Example 20
Source File: WalRecoveryTxLogicalRecordsTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<Integer, IndexedValue> ccfg = new CacheConfiguration<>(CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
    ccfg.setIndexedTypes(Integer.class, IndexedValue.class);

    if (extraCcfg != null)
        cfg.setCacheConfiguration(ccfg, new CacheConfiguration<>(extraCcfg));
    else
        cfg.setCacheConfiguration(ccfg);

    DataStorageConfiguration dbCfg = new DataStorageConfiguration();

    dbCfg.setPageSize(pageSize);

    dbCfg.setWalHistorySize(WAL_HIST_SIZE);

    dbCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
        .setMaxSize(100L * 1024 * 1024)
        .setPersistenceEnabled(true));

    if (checkpointFreq != null)
        dbCfg.setCheckpointFrequency(checkpointFreq);

    cfg.setDataStorageConfiguration(dbCfg);

    cfg.setMarshaller(null);

    BinaryConfiguration binCfg = new BinaryConfiguration();

    binCfg.setCompactFooter(false);

    cfg.setBinaryConfiguration(binCfg);

    return cfg;
}