@Override public Void call() throws Exception { GridCacheAdapter dataCache = dataCache(attacker); try (GridNearTxLocal tx = dataCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { dataCache.put(DATA_KEY, 0); txStartLatch.countDown(); txCommitLatch.await(); tx.commit(); } return null; } });
@Override public Boolean call() throws Exception { boolean retVal; try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, items.size())).get(); if (idx != null) { checkRemoved(idx); Map<QueueItemKey, T> putMap = new HashMap<>(); for (T item : items) { putMap.put(itemKey(idx), item); idx++; } cache.putAll(putMap); retVal = true; } else retVal = false; tx.commit(); return retVal; } } });
@Override public Object call() throws Exception { try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new RemoveProcessor(id, rmvIdx)).get(); if (idx != null) { checkRemoved(idx); cache.remove(itemKey(idx)); } tx.commit(); } return null; } });
@Override public Boolean call() throws Exception { boolean retVal; try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, 1)).get(); if (idx != null) { checkRemoved(idx); cache.getAndPut(itemKey(idx), item); retVal = true; } else retVal = false; tx.commit(); return retVal; } } });
@Override public T call() throws Exception { T retVal; while (true) { try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new PollProcessor(id)).get(); if (idx != null) { checkRemoved(idx); retVal = (T)cache.getAndRemove(itemKey(idx)); if (retVal == null) { // Possible if data was lost. tx.commit(); continue; } } else retVal = null; tx.commit(); return retVal; } } } });
@Override public Boolean call() throws Exception { boolean retVal; try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, items.size())).get(); if (idx != null) { checkRemoved(idx); Map<QueueItemKey, T> putMap = new HashMap<>(); for (T item : items) { putMap.put(itemKey(idx), item); idx++; } cache.putAll(putMap); retVal = true; } else retVal = false; tx.commit(); return retVal; } } });
@Override public Object call() throws Exception { try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new RemoveProcessor(id, rmvIdx)).get(); if (idx != null) { checkRemoved(idx); cache.remove(itemKey(idx)); } tx.commit(); } return null; } });
@Override public Boolean call() throws Exception { boolean retVal; try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, 1)).get(); if (idx != null) { checkRemoved(idx); cache.getAndPut(itemKey(idx), item); retVal = true; } else retVal = false; tx.commit(); return retVal; } } });
@Override public T call() throws Exception { T retVal; while (true) { try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { Long idx = (Long)cache.invoke(queueKey, new PollProcessor(id)).get(); if (idx != null) { checkRemoved(idx); retVal = (T)cache.getAndRemove(itemKey(idx)); if (retVal == null) { // Possible if data was lost. tx.commit(); continue; } } else retVal = null; tx.commit(); return retVal; } } } });