use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class PlatformConfigurationUtils method readNearConfiguration.
/**
* Reads the near config.
*
* @param in Stream.
* @return NearCacheConfiguration.
*/
public static NearCacheConfiguration readNearConfiguration(BinaryRawReader in) {
NearCacheConfiguration cfg = new NearCacheConfiguration();
cfg.setNearStartSize(in.readInt());
cfg.setNearEvictionPolicy(readEvictionPolicy(in));
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class PlatformConfigurationUtils method writeCacheConfiguration.
/**
* Writes cache configuration.
*
* @param writer Writer.
* @param ccfg Configuration.
*/
public static void writeCacheConfiguration(BinaryRawWriter writer, CacheConfiguration ccfg) {
assert writer != null;
assert ccfg != null;
writeEnumInt(writer, ccfg.getAtomicityMode(), CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE);
writer.writeInt(ccfg.getBackups());
writeEnumInt(writer, ccfg.getCacheMode(), CacheConfiguration.DFLT_CACHE_MODE);
writer.writeBoolean(ccfg.isCopyOnRead());
writer.writeBoolean(ccfg.isEagerTtl());
writer.writeBoolean(ccfg.isInvalidate());
writer.writeBoolean(ccfg.isStoreKeepBinary());
writer.writeBoolean(ccfg.isLoadPreviousValue());
writer.writeLong(ccfg.getDefaultLockTimeout());
writer.writeLong(ccfg.getLongQueryWarningTimeout());
writer.writeInt(ccfg.getMaxConcurrentAsyncOperations());
writer.writeString(ccfg.getName());
writer.writeBoolean(ccfg.isReadFromBackup());
writer.writeInt(ccfg.getRebalanceBatchSize());
writer.writeLong(ccfg.getRebalanceDelay());
writeEnumInt(writer, ccfg.getRebalanceMode(), CacheConfiguration.DFLT_REBALANCE_MODE);
writer.writeLong(ccfg.getRebalanceThrottle());
writer.writeLong(ccfg.getRebalanceTimeout());
writer.writeBoolean(ccfg.isSqlEscapeAll());
writer.writeInt(ccfg.getWriteBehindBatchSize());
writer.writeBoolean(ccfg.isWriteBehindEnabled());
writer.writeLong(ccfg.getWriteBehindFlushFrequency());
writer.writeInt(ccfg.getWriteBehindFlushSize());
writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
writer.writeBoolean(ccfg.getWriteBehindCoalescing());
writeEnumInt(writer, ccfg.getWriteSynchronizationMode());
writer.writeBoolean(ccfg.isReadThrough());
writer.writeBoolean(ccfg.isWriteThrough());
writer.writeBoolean(ccfg.isStatisticsEnabled());
writer.writeString(ccfg.getMemoryPolicyName());
writer.writeInt(ccfg.getPartitionLossPolicy().ordinal());
if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
writer.writeObject(((PlatformDotNetCacheStoreFactoryNative) ccfg.getCacheStoreFactory()).getNativeFactory());
else
writer.writeObject(null);
Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
if (qryEntities != null) {
writer.writeInt(qryEntities.size());
for (QueryEntity e : qryEntities) writeQueryEntity(writer, e);
} else
writer.writeInt(0);
NearCacheConfiguration nearCfg = ccfg.getNearConfiguration();
if (nearCfg != null) {
writer.writeBoolean(true);
writeNearConfiguration(writer, nearCfg);
} else
writer.writeBoolean(false);
writeEvictionPolicy(writer, ccfg.getEvictionPolicy());
writeAffinityFunction(writer, ccfg.getAffinity());
writeExpiryPolicyFactory(writer, ccfg.getExpiryPolicyFactory());
CachePluginConfiguration[] plugins = ccfg.getPluginConfigurations();
if (plugins != null) {
int cnt = 0;
for (CachePluginConfiguration cfg : plugins) {
if (cfg instanceof PlatformCachePluginConfiguration)
cnt++;
}
writer.writeInt(cnt);
for (CachePluginConfiguration cfg : plugins) {
if (cfg instanceof PlatformCachePluginConfiguration)
writer.writeObject(((PlatformCachePluginConfiguration) cfg).nativeCfg());
}
}
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class IgniteCacheTopologySafeGetSelfTest method cacheCfg.
/**
* @param name Cache name.
* @param cacheMode Cache mode.
* @param near Near enabled flag.
* @return Cache configuration.
*/
@SuppressWarnings("unchecked")
private CacheConfiguration cacheCfg(String name, CacheAtomicityMode cacheMode, boolean near) {
CacheConfiguration cfg = new CacheConfiguration(name);
cfg.setAtomicityMode(cacheMode);
cfg.setBackups(1);
if (near)
cfg.setNearConfiguration(new NearCacheConfiguration());
else
cfg.setNearConfiguration(null);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheNearMultiNodeSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
cfg.setDiscoverySpi(spi);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setCacheStoreFactory(singletonFactory(store));
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setAffinity(aff);
cacheCfg.setAtomicityMode(atomicityMode());
cacheCfg.setBackups(BACKUPS);
cacheCfg.setNearConfiguration(new NearCacheConfiguration());
cfg.setCacheConfiguration(cacheCfg);
cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheGetStoreErrorSelfTest 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);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(cacheMode);
if (nearEnabled)
cc.setNearConfiguration(new NearCacheConfiguration());
cc.setAtomicityMode(TRANSACTIONAL);
cc.setCacheStoreFactory(new IgniteReflectionFactory<CacheStore>(TestStore.class));
cc.setReadThrough(true);
cc.setWriteThrough(true);
cc.setLoadPreviousValue(true);
c.setCacheConfiguration(cc);
c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
return c;
}
Aggregations