use of org.apache.ignite.cache.CacheWriteSynchronizationMode in project ignite by apache.
the class GridDhtAtomicAbstractUpdateFuture method addWriteEntry.
/**
* @param affAssignment Affinity assignment.
* @param entry Entry to map.
* @param val Value to write.
* @param entryProcessor Entry processor.
* @param ttl TTL (optional).
* @param conflictExpireTime Conflict expire time (optional).
* @param conflictVer Conflict version (optional).
* @param addPrevVal If {@code true} sends previous value to backups.
* @param prevVal Previous value.
* @param updateCntr Partition update counter.
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
final void addWriteEntry(AffinityAssignment affAssignment, GridDhtCacheEntry entry, @Nullable CacheObject val, EntryProcessor<Object, Object, Object> entryProcessor, long ttl, long conflictExpireTime, @Nullable GridCacheVersion conflictVer, boolean addPrevVal, @Nullable CacheObject prevVal, long updateCntr) {
AffinityTopologyVersion topVer = updateReq.topologyVersion();
List<ClusterNode> affNodes = affAssignment.get(entry.partition());
// Client has seen that rebalancing finished, it is safe to use affinity mapping.
List<ClusterNode> dhtNodes = updateReq.affinityMapping() ? affNodes : cctx.dht().topology().nodes(entry.partition(), affAssignment, affNodes);
if (dhtNodes == null)
dhtNodes = affNodes;
if (log.isDebugEnabled())
log.debug("Mapping entry to DHT nodes [nodes=" + U.nodeIds(dhtNodes) + ", entry=" + entry + ']');
CacheWriteSynchronizationMode syncMode = updateReq.writeSynchronizationMode();
addDhtKey(entry.key(), dhtNodes);
for (int i = 0; i < dhtNodes.size(); i++) {
ClusterNode node = dhtNodes.get(i);
UUID nodeId = node.id();
if (!nodeId.equals(cctx.localNodeId())) {
GridDhtAtomicAbstractUpdateRequest updateReq = mappings.get(nodeId);
if (updateReq == null) {
updateReq = createRequest(node.id(), futId, writeVer, syncMode, topVer, ttl, conflictExpireTime, conflictVer);
mappings.put(nodeId, updateReq);
}
updateReq.addWriteValue(entry.key(), val, entryProcessor, ttl, conflictExpireTime, conflictVer, addPrevVal, prevVal, updateCntr);
}
}
}
use of org.apache.ignite.cache.CacheWriteSynchronizationMode in project ignite by apache.
the class GridDhtAtomicAbstractUpdateFuture method addNearWriteEntries.
/**
* @param nearNode Near node.
* @param readers Entry readers.
* @param entry Entry.
* @param val Value.
* @param entryProcessor Entry processor..
* @param ttl TTL for near cache update (optional).
* @param expireTime Expire time for near cache update (optional).
*/
final void addNearWriteEntries(ClusterNode nearNode, GridDhtCacheEntry.ReaderId[] readers, GridDhtCacheEntry entry, @Nullable CacheObject val, EntryProcessor<Object, Object, Object> entryProcessor, long ttl, long expireTime) {
assert readers != null;
CacheWriteSynchronizationMode syncMode = updateReq.writeSynchronizationMode();
addNearKey(entry.key(), readers);
AffinityTopologyVersion topVer = updateReq.topologyVersion();
for (int i = 0; i < readers.length; i++) {
GridDhtCacheEntry.ReaderId reader = readers[i];
if (nearNode.id().equals(reader.nodeId()))
continue;
GridDhtAtomicAbstractUpdateRequest updateReq = mappings.get(reader.nodeId());
if (updateReq == null) {
ClusterNode node = cctx.discovery().node(reader.nodeId());
// Node left the grid.
if (node == null) {
try {
entry.removeReader(reader.nodeId(), -1L);
} catch (GridCacheEntryRemovedException ignore) {
// Assume hold entry lock.
assert false;
}
continue;
}
updateReq = createRequest(node.id(), futId, writeVer, syncMode, topVer, ttl, expireTime, null);
mappings.put(node.id(), updateReq);
addedReader = true;
}
updateReq.addNearWriteValue(entry.key(), val, entryProcessor, ttl, expireTime);
}
}
use of org.apache.ignite.cache.CacheWriteSynchronizationMode in project ignite by apache.
the class AbstractDataTypesCoverageTest method parameters.
/**
* @return Test parameters.
*/
@Parameterized.Parameters(name = "atomicityMode={1}, cacheMode={2}, ttlFactory={3}, backups={4}," + " evictionFactory={5}, onheapCacheEnabled={6}, writeSyncMode={7}, persistenceEnabled={8}, useBinaryArrays={9}")
public static Collection parameters() {
Set<Object[]> params = new HashSet<>();
Object[] baseParamLine = { null, CacheAtomicityMode.ATOMIC, CacheMode.PARTITIONED, null, 2, null, false, CacheWriteSynchronizationMode.FULL_SYNC, false, DFLT_IGNITE_USE_BINARY_ARRAYS };
Object[] paramLine = null;
for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[1] = atomicityMode;
params.add(paramLine);
}
for (CacheMode cacheMode : CacheMode.values()) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[2] = cacheMode;
params.add(paramLine);
}
assert paramLine != null;
if ((paramLine[1]) != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) {
for (Factory ttlFactory : TTL_FACTORIES) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[3] = ttlFactory;
params.add(paramLine);
}
}
for (int backups : new int[] { 0, 1, 2 }) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[4] = backups;
params.add(paramLine);
}
for (Factory evictionFactory : EVICTION_FACTORIES) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[5] = evictionFactory;
params.add(paramLine);
}
for (Boolean onheapCacheEnabled : BOOLEANS) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[6] = onheapCacheEnabled;
params.add(paramLine);
}
for (CacheWriteSynchronizationMode writeSyncMode : CacheWriteSynchronizationMode.values()) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[7] = writeSyncMode;
params.add(paramLine);
}
for (boolean persistenceEnabled : BOOLEANS) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[8] = persistenceEnabled;
params.add(paramLine);
}
for (boolean useTypedArrays : BOOLEANS) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[9] = useTypedArrays;
params.add(paramLine);
}
for (Object[] pLine : params) pLine[0] = UUID.randomUUID();
return params;
}
use of org.apache.ignite.cache.CacheWriteSynchronizationMode 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.CacheWriteSynchronizationMode in project ignite by apache.
the class TxPessimisticDeadlockDetectionTest method testDeadlocksPartitionedNear.
/**
* @throws Exception If failed.
*/
@Test
public void testDeadlocksPartitionedNear() throws Exception {
for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
doTestDeadlocks(createCache(PARTITIONED, syncMode, true), ORDINAL_START_KEY);
doTestDeadlocks(createCache(PARTITIONED, syncMode, true), CUSTOM_START_KEY);
}
}
Aggregations