Search in sources :

Example 1 with CassandraCacheStore

use of org.apache.ignite.cache.store.cassandra.CassandraCacheStore in project ignite by apache.

the class CacheStoreHelper method createCacheStore.

/** */
public static CacheStore createCacheStore(String cacheName, Resource persistenceSettings, DataSource conn, CacheStoreSession session, Logger log) {
    CassandraCacheStore<Integer, Integer> cacheStore = new CassandraCacheStore<>(conn, new KeyValuePersistenceSettings(persistenceSettings), Runtime.getRuntime().availableProcessors());
    try {
        Field sesField = CassandraCacheStore.class.getDeclaredField("storeSes");
        Field logField = CassandraCacheStore.class.getDeclaredField("log");
        sesField.setAccessible(true);
        logField.setAccessible(true);
        sesField.set(cacheStore, session != null ? session : new TestCacheSession(cacheName));
        logField.set(cacheStore, new Log4JLogger(log));
    } catch (Throwable e) {
        throw new RuntimeException("Failed to initialize test Ignite cache store", e);
    }
    return cacheStore;
}
Also used : Field(java.lang.reflect.Field) KeyValuePersistenceSettings(org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings) Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger) CassandraCacheStore(org.apache.ignite.cache.store.cassandra.CassandraCacheStore)

Aggregations

Field (java.lang.reflect.Field)1 CassandraCacheStore (org.apache.ignite.cache.store.cassandra.CassandraCacheStore)1 KeyValuePersistenceSettings (org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings)1 Log4JLogger (org.apache.ignite.logger.log4j.Log4JLogger)1