Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setStoreKeepBinary()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setStoreKeepBinary() . 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: IgniteCacheInitializer.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
private CacheConfiguration<?,?> createEntityCacheConfiguration(EntityKeyMetadata entityKeyMetadata, SchemaDefinitionContext context) {
	CacheConfiguration<?,?> cacheConfiguration = new CacheConfiguration<>();
	cacheConfiguration.setStoreKeepBinary( true );
	cacheConfiguration.setSqlSchema( QueryUtils.DFLT_SCHEMA );
	cacheConfiguration.setBackups( 1 );
	cacheConfiguration.setName( StringHelper.stringBeforePoint( entityKeyMetadata.getTable() ) );
	cacheConfiguration.setAtomicityMode( CacheAtomicityMode.TRANSACTIONAL );

	QueryEntity queryEntity = new QueryEntity();
	queryEntity.setTableName( entityKeyMetadata.getTable() );
	queryEntity.setKeyType( getEntityIdClassName( entityKeyMetadata.getTable(), context ).getSimpleName() );
	queryEntity.setValueType( StringHelper.stringAfterPoint( entityKeyMetadata.getTable() ) );

	addTableInfo( queryEntity, context, entityKeyMetadata.getTable() );
	for ( AssociationKeyMetadata associationKeyMetadata : context.getAllAssociationKeyMetadata() ) {
		if ( associationKeyMetadata.getAssociationKind() != AssociationKind.EMBEDDED_COLLECTION
				&& associationKeyMetadata.getTable().equals( entityKeyMetadata.getTable() )
				&& !IgniteAssociationSnapshot.isThirdTableAssociation( associationKeyMetadata ) ) {
			appendIndex( queryEntity, associationKeyMetadata, context );
		}
	}
	addUserIndexes( queryEntity, context, entityKeyMetadata.getTable() );

	log.debugf( "queryEntity: %s", queryEntity );
	cacheConfiguration.setQueryEntities( Arrays.asList( queryEntity ) );
	return cacheConfiguration;
}
 
Example 2
Source File: GridCacheStoreManagerDeserializationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration.
 */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration() {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    CacheConfiguration cc = defaultCacheConfiguration();

    // Template
    cc.setName("*");

    cc.setRebalanceMode(SYNC);

    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);
    cc.setStoreKeepBinary(true);

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(cacheWriteSynchronizationMode());

    cc.setBackups(0);

    cc.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

    return cc;
}
 
Example 3
Source File: WithKeepBinaryCacheFullApiTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration() {
    CacheConfiguration cc = super.cacheConfiguration();

    cc.setStoreKeepBinary(true);

    return cc;
}
 
Example 4
Source File: BinaryTxCacheLocalEntriesSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setStoreKeepBinary(true);

    return ccfg;
}
 
Example 5
Source File: CacheJdbcPojoStoreAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration for test.
 * @throws Exception In case when failed to create cache configuration.
 */
protected CacheConfiguration cacheConfiguration() throws Exception {
    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setName(CACHE_NAME);
    cc.setCacheMode(PARTITIONED);
    cc.setAtomicityMode(transactional ? TRANSACTIONAL : ATOMIC);
    cc.setWriteBehindEnabled(false);
    cc.setStoreKeepBinary(storeKeepBinary());

    CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>();

    H2Dialect dialect = new H2Dialect();

    dialect.setFetchSize(FETCH_SZ);

    storeFactory.setDialect(dialect);
    storeFactory.setTypes(storeTypes());
    storeFactory.setDataSourceFactory(new H2DataSourceFactory()); // H2 DataSource factory.
    storeFactory.setSqlEscapeAll(sqlEscapeAll());
    storeFactory.setParallelLoadCacheMinimumThreshold(parallelLoadThreshold);

    cc.setCacheStoreFactory(storeFactory);
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    return cc;
}
 
Example 6
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 7
Source File: GridCacheBinaryObjectsAbstractSelfTest.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);

    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;
}
 
Example 8
Source File: GridCacheStoreValueBytesSelfTest.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);

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(REPLICATED);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    ccfg.setStoreKeepBinary(storeValBytes);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}