public Version putSysStore(K key, V value) { Version version = null; try { if(logger.isDebugEnabled()) { logger.debug("Invoking Put for key : " + key + " on store name : " + this.storeName); } Versioned<V> versioned = getSysStore(key); if(versioned == null) versioned = Versioned.value(value, new VectorClock()); else versioned.setObject(value); this.sysStore.put(key, versioned, null); version = versioned.getVersion(); } catch(Exception e) { if(logger.isDebugEnabled()) { logger.debug("Exception caught during putSysStore: " + e); } } return version; }
public void run() { boolean done = false; while(!done) { try { byte[] key = Integer.toString(index).getBytes(); List<Versioned<byte[]>> found = store.get(key, null); if(found.size() > 1) { throw new RuntimeException("Found multiple versions: " + found); } else if(found.size() == 1) { Versioned<byte[]> versioned = found.get(0); byte[] valueBytes = Integer.toString(MultithreadedStressTest.this.value.getAndIncrement()) .getBytes(); versioned.setObject(valueBytes); store.put(key, versioned, null); done = true; } else if(found.size() == 0) { throw new RuntimeException("No values found!"); } } catch(ObsoleteVersionException e) { obsoletes.getAndIncrement(); } finally { isDone.countDown(); } } } });
versionedValue.setObject("New Value !!!"); System.out.println("************* original version : " + versionedValue.getVersion()); Version putVersion = storeClient.put("a", versionedValue);
versioned = Versioned.value(requestWrapper.getRawValue(), new VectorClock()); else versioned.setObject(requestWrapper.getRawValue());
@Override public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) { if(numCalls > 0) { // TODO jko maybe delete this if unnecessary Versioned<Map<String, Object>> nextNodeMap = storeClient.get(_key.mapValue()); if(nextNodeMap == null) throw new ObsoleteVersionException("possible concurrent modification"); _listNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()), nextNodeMap.getVersion()); } VListNode<E> nodeValue = _listNode.getValue(); _listNode.setObject(new VListNode<E>(nodeValue.getValue(), nodeValue.getId(), _newId, nodeValue.getNextId(), true)); Map<String, Object> nextNodeMap = _listNode.getValue().mapValue(); storeClient.put(_key.mapValue(), nextNodeMap); numCalls++; }