use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.
the class JmhCacheAbstractBenchmark method cacheConfiguration.
/**
* Create cache configuration.
*
* @return Cache configuration.
*/
protected CacheConfiguration cacheConfiguration() {
CacheConfiguration cacheCfg = new CacheConfiguration();
cacheCfg.setName(DEFAULT_CACHE_NAME);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
// Set atomicity mode.
CacheAtomicityMode atomicityMode = enumProperty(PROP_ATOMICITY_MODE, CacheAtomicityMode.class);
if (atomicityMode != null)
cacheCfg.setAtomicityMode(atomicityMode);
// Set write synchronization mode.
CacheWriteSynchronizationMode writeSyncMode = enumProperty(PROP_WRITE_SYNC_MODE, CacheWriteSynchronizationMode.class);
if (writeSyncMode != null)
cacheCfg.setWriteSynchronizationMode(writeSyncMode);
// Set backups.
cacheCfg.setBackups(intProperty(PROP_BACKUPS));
return cacheCfg;
}
use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.
the class IgniteCacheTxIteratorSelfTest method checkModes.
/**
* @throws Exception if failed.
*/
public void checkModes(int gridCnt) throws Exception {
startGrids(gridCnt);
try {
for (CacheMode mode : CacheMode.values()) {
for (CacheAtomicityMode atomMode : CacheAtomicityMode.values()) {
if (mode == CacheMode.PARTITIONED) {
// Near cache makes sense only for partitioned cache.
checkTxCache(CacheMode.PARTITIONED, atomMode, true, false);
}
checkTxCache(CacheMode.PARTITIONED, atomMode, false, true);
checkTxCache(CacheMode.PARTITIONED, atomMode, false, false);
}
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.
the class GridSqlQueryParser method processExtraParam.
/**
* @param name Param name.
* @param val Param value.
* @param res Table params to update.
*/
private static void processExtraParam(String name, String val, GridSqlCreateTable res) {
assert !F.isEmpty(name);
switch(name) {
case PARAM_TEMPLATE:
ensureNotEmpty(name, val);
res.templateName(val);
break;
case PARAM_BACKUPS:
ensureNotEmpty(name, val);
int backups = parseIntParam(PARAM_BACKUPS, val);
if (backups < 0)
throw new IgniteSQLException("\"" + PARAM_BACKUPS + "\" cannot be negative: " + backups, IgniteQueryErrorCode.PARSING);
res.backups(backups);
break;
case PARAM_ATOMICITY:
ensureNotEmpty(name, val);
CacheAtomicityMode mode;
if (CacheAtomicityMode.TRANSACTIONAL.name().equalsIgnoreCase(val))
mode = CacheAtomicityMode.TRANSACTIONAL;
else if (CacheAtomicityMode.ATOMIC.name().equalsIgnoreCase(val))
mode = CacheAtomicityMode.ATOMIC;
else
throw new IgniteSQLException("Invalid value of \"" + PARAM_ATOMICITY + "\" parameter " + "(should be either TRANSACTIONAL or ATOMIC): " + val, IgniteQueryErrorCode.PARSING);
res.atomicityMode(mode);
break;
default:
throw new IgniteSQLException("Unsupported parameter: " + name, IgniteQueryErrorCode.PARSING);
}
}
use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.
the class IgniteClientReconnectCacheTest method testReconnectOperationInProgress.
/**
* @throws Exception If failed.
*/
public void testReconnectOperationInProgress() throws Exception {
clientMode = true;
IgniteEx client = startGrid(SRV_CNT);
client.events().localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event evt) {
if (evt.type() == EVT_CLIENT_NODE_DISCONNECTED)
info("Client disconnected: " + evt);
else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED)
info("Client reconnected: " + evt);
return true;
}
}, EVT_CLIENT_NODE_DISCONNECTED, EVT_CLIENT_NODE_RECONNECTED);
IgniteInClosure<IgniteCache<Object, Object>> putOp = new CI1<IgniteCache<Object, Object>>() {
@Override
public void apply(IgniteCache<Object, Object> cache) {
cache.put(1, 1);
}
};
IgniteInClosure<IgniteCache<Object, Object>> getOp = new CI1<IgniteCache<Object, Object>>() {
@Override
public void apply(IgniteCache<Object, Object> cache) {
cache.get(1);
}
};
IgniteInClosure<IgniteCache<Object, Object>> getAllOp = new CI1<IgniteCache<Object, Object>>() {
@Override
public void apply(IgniteCache<Object, Object> cache) {
cache.getAll(F.asSet(1, 2));
}
};
int cnt = 0;
for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) {
for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setName("cache-" + cnt++);
ccfg.setWriteSynchronizationMode(syncMode);
if (syncMode != FULL_ASYNC) {
Class<?> cls = (ccfg.getAtomicityMode() == ATOMIC) ? GridNearAtomicUpdateResponse.class : GridNearTxPrepareResponse.class;
log.info("Test cache put [atomicity=" + atomicityMode + ", syncMode=" + syncMode + ']');
checkOperationInProgressFails(client, ccfg, cls, putOp);
client.destroyCache(ccfg.getName());
}
log.info("Test cache get [atomicity=" + atomicityMode + ", syncMode=" + syncMode + ']');
checkOperationInProgressFails(client, ccfg, GridNearSingleGetResponse.class, getOp);
checkOperationInProgressFails(client, ccfg, GridNearGetResponse.class, getAllOp);
client.destroyCache(ccfg.getName());
}
}
}
Aggregations