Source:
public byte[] call(final byte[] memento) throws InterruptedException, IdGenerationException { LOG.info("RemoteEMTask commencing..."); final long dataKey = 0; final int dataValue = 1000; final boolean isLocalKey = router.route(dataKey).getFirst(); boolean isSuccess; Pair<Long, Integer> output; output = memoryStore.get(DATA_TYPE, dataKey); LOG.log(Level.INFO, "get({0}): {1}", new Object[]{dataKey, output}); if (output != null) { throw new RuntimeException("Wrong initial state"); } synchronize(); if (!isLocalKey) { isSuccess = memoryStore.put(DATA_TYPE, dataKey, dataValue); LOG.log(Level.INFO, "put({0}): {1}", new Object[]{dataKey, isSuccess}); if (!isSuccess) { throw new RuntimeException("Fail to put data"); } } synchronize(); output = memoryStore.get(DATA_TYPE, dataKey); LOG.log(Level.INFO, "get({0}): {1}", new Object[]{dataKey, output}); if (output == null) { throw new RuntimeException("Fail to get data"); } if (output.getFirst() != dataKey || output.getSecond() != dataValue) { throw new RuntimeException("Fail to get correct data"); } synchronize(); if (!isLocalKey) { output = memoryStore.remove(DATA_TYPE, dataKey); LOG.log(Level.INFO, "remove({0}): {1}", new Object[]{dataKey, output}); if (output == null) { throw new RuntimeException("Fail to remove data"); } if (output.getFirst() != dataKey || output.getSecond() != dataValue) { throw new RuntimeException("Fail to remove correct data"); } } synchronize(); output = memoryStore.get(DATA_TYPE, dataKey); LOG.log(Level.INFO, "get({0}): {1}", new Object[]{dataKey, output}); if (output != null) { throw new RuntimeException("Remove did not work well"); } synchronize(); LOG.info("FINISH task"); return null; }

Target:
public byte[] call(final byte[] memento) throws InterruptedException, IdGenerationException { LOG.info("RemoteEMTask commencing..."); final boolean isLocalKey = router.route(DATA_KEY).getFirst(); boolean isSuccess; Pair<Long, Integer> output; output = memoryStore.get(DATA_TYPE, DATA_KEY); LOG.log(Level.INFO, "get({0}): {1}", new Object[]{DATA_KEY, output}); if (output != null) { throw new RuntimeException("Wrong initial state"); } synchronize(); if (!isLocalKey) { isSuccess = memoryStore.put(DATA_TYPE, DATA_KEY, DATA_VALUE); LOG.log(Level.INFO, "put({0}): {1}", new Object[]{DATA_KEY, isSuccess}); if (!isSuccess) { throw new RuntimeException("Fail to put data"); } } synchronize(); output = memoryStore.get(DATA_TYPE, DATA_KEY); LOG.log(Level.INFO, "get({0}): {1}", new Object[]{DATA_KEY, output}); if (output == null) { throw new RuntimeException("Fail to get data"); } if (output.getFirst() != DATA_KEY || output.getSecond() != DATA_VALUE) { throw new RuntimeException("Fail to get correct data"); } synchronize(); if (!isLocalKey) { output = memoryStore.remove(DATA_TYPE, DATA_KEY); LOG.log(Level.INFO, "remove({0}): {1}", new Object[]{DATA_KEY, output}); if (output == null) { throw new RuntimeException("Fail to remove data"); } if (output.getFirst() != DATA_KEY || output.getSecond() != DATA_VALUE) { throw new RuntimeException("Fail to remove correct data"); } } synchronize(); output = memoryStore.get(DATA_TYPE, DATA_KEY); LOG.log(Level.INFO, "get({0}): {1}", new Object[]{DATA_KEY, output}); if (output != null) { throw new RuntimeException("Remove did not work well"); } synchronize(); return null; }