use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class PlatformConfigurationUtils method readCacheConfiguration.
/**
* Reads cache configuration from a stream.
*
* @param in Stream.
* @return Cache configuration.
*/
public static CacheConfiguration readCacheConfiguration(BinaryRawReaderEx in) {
assert in != null;
CacheConfiguration ccfg = new CacheConfiguration();
ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt()));
ccfg.setBackups(in.readInt());
ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
ccfg.setCopyOnRead(in.readBoolean());
ccfg.setEagerTtl(in.readBoolean());
ccfg.setInvalidate(in.readBoolean());
ccfg.setStoreKeepBinary(in.readBoolean());
ccfg.setLoadPreviousValue(in.readBoolean());
ccfg.setDefaultLockTimeout(in.readLong());
ccfg.setLongQueryWarningTimeout(in.readLong());
ccfg.setMaxConcurrentAsyncOperations(in.readInt());
ccfg.setName(in.readString());
ccfg.setReadFromBackup(in.readBoolean());
ccfg.setRebalanceBatchSize(in.readInt());
ccfg.setRebalanceDelay(in.readLong());
ccfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(in.readInt()));
ccfg.setRebalanceThrottle(in.readLong());
ccfg.setRebalanceTimeout(in.readLong());
ccfg.setSqlEscapeAll(in.readBoolean());
ccfg.setWriteBehindBatchSize(in.readInt());
ccfg.setWriteBehindEnabled(in.readBoolean());
ccfg.setWriteBehindFlushFrequency(in.readLong());
ccfg.setWriteBehindFlushSize(in.readInt());
ccfg.setWriteBehindFlushThreadCount(in.readInt());
ccfg.setWriteBehindCoalescing(in.readBoolean());
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
ccfg.setReadThrough(in.readBoolean());
ccfg.setWriteThrough(in.readBoolean());
ccfg.setStatisticsEnabled(in.readBoolean());
String memoryPolicyName = in.readString();
if (memoryPolicyName != null)
ccfg.setMemoryPolicyName(memoryPolicyName);
ccfg.setPartitionLossPolicy(PartitionLossPolicy.fromOrdinal((byte) in.readInt()));
Object storeFactory = in.readObjectDetached();
if (storeFactory != null)
ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
int qryEntCnt = in.readInt();
if (qryEntCnt > 0) {
Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
for (int i = 0; i < qryEntCnt; i++) entities.add(readQueryEntity(in));
ccfg.setQueryEntities(entities);
}
if (in.readBoolean())
ccfg.setNearConfiguration(readNearConfiguration(in));
ccfg.setEvictionPolicy(readEvictionPolicy(in));
if (ccfg.getEvictionPolicy() != null)
ccfg.setOnheapCacheEnabled(true);
ccfg.setAffinity(readAffinityFunction(in));
ccfg.setExpiryPolicyFactory(readExpiryPolicyFactory(in));
int pluginCnt = in.readInt();
if (pluginCnt > 0) {
ArrayList<CachePluginConfiguration> plugins = new ArrayList<>();
for (int i = 0; i < pluginCnt; i++) {
if (in.readBoolean()) {
// Java cache plugin.
readCachePluginConfiguration(ccfg, in);
} else {
// Platform cache plugin.
plugins.add(new PlatformCachePluginConfiguration(in.readObjectDetached()));
}
}
if (ccfg.getPluginConfigurations() != null) {
Collections.addAll(plugins, ccfg.getPluginConfigurations());
}
ccfg.setPluginConfigurations(plugins.toArray(new CachePluginConfiguration[plugins.size()]));
}
return ccfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheAffinityBackupsSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(backups);
ccfg.setAffinity(new RendezvousAffinityFunction());
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteCacheAffinitySelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration cache0 = cacheConfiguration(null);
CacheConfiguration cache2 = cacheConfiguration(null);
cache2.setName(CACHE2);
cache2.setAffinity(new RendezvousAffinityFunction());
if (igniteInstanceName.contains("0"))
cfg.setCacheConfiguration(cache0);
else
cfg.setCacheConfiguration(cache0, cache2);
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridAffinityMappedTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
if (igniteInstanceName.endsWith("1"))
// Empty cache configuration.
cfg.setCacheConfiguration();
else {
assert igniteInstanceName.endsWith("2") || igniteInstanceName.endsWith("3");
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setAffinity(new MockCacheAffinityFunction());
cacheCfg.setAffinityMapper(new MockCacheAffinityKeyMapper());
cfg.setCacheConfiguration(cacheCfg);
cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, igniteInstanceName.endsWith("2") ? 0 : 1));
}
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridAffinityP2PSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings({ "unchecked" })
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDeploymentMode(depMode);
if (igniteInstanceName.endsWith("1"))
// Empty cache configuration.
c.setCacheConfiguration();
else {
assert igniteInstanceName.endsWith("2") || igniteInstanceName.endsWith("3");
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(PARTITIONED);
GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(URLS);
cc.setAffinity((AffinityFunction) ldr.loadClass(EXT_AFFINITY_CLS_NAME).newInstance());
cc.setAffinityMapper((AffinityKeyMapper) ldr.loadClass(EXT_AFFINITY_MAPPER_CLS_NAME).newInstance());
c.setCacheConfiguration(cc);
c.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, igniteInstanceName.endsWith("2") ? 0 : 1));
}
return c;
}
Aggregations