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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setInterceptor() . 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: IgniteSqlNotNullConstraintTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
private CacheConfiguration buildCacheConfigurationRestricted(String cacheName, boolean readThrough,
    boolean interceptor, boolean hasQueryEntity) {
    CacheConfiguration cfg = new CacheConfiguration<Integer, Person>()
        .setName(cacheName)
        .setCacheMode(CacheMode.PARTITIONED)
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

    if (readThrough) {
        cfg.setCacheStoreFactory(singletonFactory(new TestStore()));
        cfg.setReadThrough(true);
    }

    if (interceptor)
        cfg.setInterceptor(new TestInterceptor());

    if (hasQueryEntity) {
        cfg.setQueryEntities(F.asList(new QueryEntity(Integer.class, Person.class)
            .setNotNullFields(Collections.singleton("name"))));
    }

    return cfg;
}
 
Example 2
Source File: GridCacheInterceptorAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.INTERCEPTOR);

    if (nearEnabled())
        MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE);

    if (storeEnabled())
        MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    assertNotNull(interceptor);

    ccfg.setInterceptor(interceptor);

    if (!storeEnabled()) {
        ccfg.setCacheStoreFactory(null);
        ccfg.setReadThrough(false);
        ccfg.setWriteThrough(false);
    }

    return ccfg;
}
 
Example 3
Source File: CacheInterceptorPartitionCounterRandomOperationsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param cacheMode Cache mode.
 * @param backups Number of backups.
 * @param atomicityMode Cache atomicity mode.
 * @param store If {@code true} configures dummy cache store.
 * @return Cache configuration.
 */
protected CacheConfiguration<Object, Object> cacheConfiguration(
    CacheMode cacheMode,
    int backups,
    CacheAtomicityMode atomicityMode,
    boolean store) {
    CacheConfiguration<TestKey, TestValue> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setCacheMode(cacheMode);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    if (cacheMode == PARTITIONED)
        ccfg.setBackups(backups);

    if (store) {
        ccfg.setCacheStoreFactory(new TestStoreFactory());
        ccfg.setReadThrough(true);
        ccfg.setWriteThrough(true);
    }

    ccfg.setInterceptor(new TestInterceptor());

    return (CacheConfiguration)ccfg;
}
 
Example 4
Source File: GridCacheOnCopyFlagAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration() throws Exception {
    CacheConfiguration ccfg = defaultCacheConfiguration();

    assertTrue(ccfg.isCopyOnRead());

    interceptor = new Interceptor();

    ccfg.setInterceptor(interceptor);

    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setCacheMode(cacheMode());
    ccfg.setNearConfiguration(null);

    return ccfg;
}
 
Example 5
Source File: CacheInterceptorPartitionCounterLocalSanityTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param atomicityMode Cache atomicity mode.
 * @param store If {@code true} configures dummy cache store.
 * @return Cache configuration.
 */
protected CacheConfiguration<Object, Object> cacheConfiguration(
    CacheAtomicityMode atomicityMode,
    boolean store) {
    CacheConfiguration<TestKey, TestValue> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setCacheMode(LOCAL);

    if (store) {
        ccfg.setCacheStoreFactory(new TestStoreFactory());
        ccfg.setReadThrough(true);
        ccfg.setWriteThrough(true);
    }

    ccfg.setInterceptor(new TestInterceptor());

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

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

    assertNotNull(interceptor);

    ccfg.setInterceptor(interceptor);
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setBackups(2);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 7
Source File: InterceptorWithKeepBinaryCacheFullApiTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(IgniteConfiguration cfg, String cacheName) {
    CacheConfiguration cc = super.cacheConfiguration(cfg, cacheName);

    cc.setInterceptor(new TestInterceptor());

    return cc;
}
 
Example 8
Source File: CacheKeepBinaryWithInterceptorTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param atomicityMode Cache atomicity mode.
 * @param testPrimitives {@code True} if test interceptor with primitive values.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(CacheAtomicityMode atomicityMode, boolean testPrimitives) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setInterceptor(testPrimitives ? new TestInterceptor2() : new TestInterceptor1());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(1);

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

    cc.setInterceptor(new TestInterceptor());

    return cc;
}
 
Example 10
Source File: GridCacheLifecycleAwareSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setDiscoverySpi(new TcpDiscoverySpi());

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);

    ccfg.setWriteBehindEnabled(writeBehind);

    ccfg.setCacheMode(CacheMode.PARTITIONED);

    ccfg.setName(CACHE_NAME);

    TestStore store = new TestStore();

    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    lifecycleAwares.add(store.lifecycleAware);

    TestAffinityFunction affinity = new TestAffinityFunction();

    ccfg.setAffinity(affinity);

    lifecycleAwares.add(affinity);

    TestEvictionPolicy evictionPlc = new TestEvictionPolicy();

    ccfg.setEvictionPolicy(evictionPlc);
    ccfg.setOnheapCacheEnabled(true);

    lifecycleAwares.add(evictionPlc);

    if (near) {
        TestEvictionPolicy nearEvictionPlc = new TestEvictionPolicy();

        NearCacheConfiguration nearCfg = new NearCacheConfiguration();

        nearCfg.setNearEvictionPolicy(nearEvictionPlc);

        ccfg.setNearConfiguration(nearCfg);

        lifecycleAwares.add(nearEvictionPlc);
    }

    TestEvictionFilter evictionFilter = new TestEvictionFilter();

    ccfg.setEvictionFilter(evictionFilter);

    lifecycleAwares.add(evictionFilter);

    TestAffinityKeyMapper mapper = new TestAffinityKeyMapper();

    ccfg.setAffinityMapper(mapper);

    lifecycleAwares.add(mapper);

    TestInterceptor interceptor = new TestInterceptor();

    lifecycleAwares.add(interceptor);

    ccfg.setInterceptor(interceptor);

    TestTopologyValidator topValidator = new TestTopologyValidator();

    lifecycleAwares.add(topValidator);

    ccfg.setTopologyValidator(topValidator);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}