public VoldemortException mapResponseCodeToError(int responseCode, String message) { // 200 range response code is okay! if(responseCode >= 200 && responseCode < 300) return null; else if(responseCode == HttpURLConnection.HTTP_CONFLICT) throw new ObsoleteVersionException(message); else throw new UnknownFailure("Unknown failure occured in HTTP operation: " + responseCode + " - " + message); }
inserted++; } catch(ObsoleteVersionException e) { e.printStackTrace();
} catch(ObsoleteVersionException e) { logger.info("Why are we seeing this at all here ?? "); e.printStackTrace();
@Override public synchronized void put(K key, Versioned<V> value, T transforms) throws VoldemortException { StoreUtils.assertValidKey(key); List<Versioned<V>> items = map.get(key); // If we have no value, add the current value if(items == null) { items = new ArrayList<Versioned<V>>(); } // Check for existing versions - remember which items to // remove in case of success List<Versioned<V>> itemsToRemove = new ArrayList<Versioned<V>>(items.size()); for(Versioned<V> versioned: items) { Occurred occurred = value.getVersion().compare(versioned.getVersion()); if(occurred == Occurred.BEFORE) { throw new ObsoleteVersionException("Obsolete version for key '" + key + "': " + value.getVersion()); } else if(occurred == Occurred.AFTER) { itemsToRemove.add(versioned); } } items.removeAll(itemsToRemove); items.add(value); map.put(key, items); }
private void populateData(Cluster cluster, StoreDefinition storeDef) throws Exception { // Create SocketStores for each Node first Map<Integer, Store<ByteArray, byte[], byte[]>> storeMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>(); for(Node node: cluster.getNodes()) { storeMap.put(node.getId(), getSocketStore(storeDef.getName(), node.getHost(), node.getSocketPort())); } BaseStoreRoutingPlan storeInstance = new BaseStoreRoutingPlan(cluster, storeDef); for(Entry<String, String> entry: testEntries.entrySet()) { ByteArray keyBytes = new ByteArray(ByteUtils.getBytes(entry.getKey(), "UTF-8")); List<Integer> preferenceNodes = storeInstance.getReplicationNodeList(keyBytes.get()); // Go over every node for(int nodeId: preferenceNodes) { try { storeMap.get(nodeId) .put(keyBytes, new Versioned<byte[]>(ByteUtils.getBytes(entry.getValue(), "UTF-8")), null); } catch(ObsoleteVersionException e) { logger.info("Why are we seeing this at all here ?? "); e.printStackTrace(); } } } // close all socket stores for(Store<ByteArray, byte[], byte[]> store: storeMap.values()) { store.close(); } }
public E setById(int id, Versioned<E> element) { VListKey<K> key = new VListKey<K>(_key, id); UpdateElementById<K, E> updateElementAction = new UpdateElementById<K, E>(key, element); if(!_storeClient.applyUpdate(updateElementAction)) throw new ObsoleteVersionException("update failed"); return updateElementAction.getResult(); }
} catch(ObsoleteVersionException e) { logger.info("Why are we seeing this at all here ?? "); e.printStackTrace();
/** * Put the given value to the appropriate id in the stack, using the version * of the current list node identified by that id. * * @param id * @param element element to set * @return element that was replaced by the new element * @throws ObsoleteVersionException when an update fails */ public E setById(final int id, final E element) { VListKey<K> key = new VListKey<K>(_key, id); UpdateElementById<K, E> updateElementAction = new UpdateElementById<K, E>(key, element); if(!_storeClient.applyUpdate(updateElementAction)) throw new ObsoleteVersionException("update failed"); return updateElementAction.getResult(); }
Occurred occurred = value.getVersion().compare(version); if(occurred == Occurred.BEFORE) throw new ObsoleteVersionException("Attempt to put version " + value.getVersion() + " which is superceeded by " + version } catch(SQLException e) { if(e.getErrorCode() == MYSQL_ERR_DUP_KEY || e.getErrorCode() == MYSQL_ERR_DUP_ENTRY) { throw new ObsoleteVersionException("Key or value already used."); } else { throw new PersistenceFailureException("Fix me!", e);
Occurred occurred = value.getVersion().compare(curr.getVersion()); if(occurred == Occurred.BEFORE) { throw new ObsoleteVersionException("Key " + new String(hexCodec.encode(key.get())) + " "
Occurred occurred = value.getVersion().compare(versioned.getVersion()); if(occurred == Occurred.BEFORE) throw new ObsoleteVersionException("Obsolete version for key '" + key + "': " + value.getVersion()); else if(occurred == Occurred.AFTER)
throw new ObsoleteVersionException("A successor version " + clock + " to this " + value.getVersion() + " exists for key " + key); } else if(value.getVersion().compare(clock) == Occurred.CONCURRENTLY) { throw new ObsoleteVersionException("Concurrent Operation not allowed on Metadata.");
@Override /** * FIXME There is a problem here.. Since the versioning is on the file level, SystemStoreClient.put() * will throw OVE, on the insert of the second key, value pair.Ideally, the version should be persisted * along with the entries in the file too.. */ public void put(ByteArray key, Versioned<byte[]> value, byte[] transforms) throws VoldemortException { StoreUtils.assertValidKey(key); // Validate the Vector clock VectorClock clock = readVersion(); if(clock != null) { if(value.getVersion().compare(clock) == Occurred.BEFORE) { throw new ObsoleteVersionException("A successor version " + clock + " to this " + value.getVersion() + " exists for the current file : " + getName()); } else if(value.getVersion().compare(clock) == Occurred.CONCURRENTLY) { throw new ObsoleteVersionException("Concurrent Operation not allowed on Metadata."); } } // Update the cache copy this.metadataMap.put(new String(key.get()), new String(value.getValue())); // Flush the data to the file this.flushData(); // Persist the new Vector clock writeVersion((VectorClock) value.getVersion()); }
Occurred occurred = value.getVersion().compare(curr.getVersion()); if(occurred == Occurred.BEFORE) throw new ObsoleteVersionException("Key " + new String(hexCodec.encode(key.get())) + " "
throw new VoldemortException("Bad request: " + e.getMessage(), e); } else if(httpErrorStatus == PRECONDITION_FAILED.getCode()) { throw new ObsoleteVersionException(e.getMessage()); } else if(httpErrorStatus == REQUEST_TIMEOUT.getCode() || httpErrorStatus == INTERNAL_SERVER_ERROR.getCode()) {
@Override public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) { Versioned<Map<String, Object>> nodeMap = storeClient.get(_key.mapValue()); if(nodeMap == null) throw new IndexOutOfBoundsException("invalid id " + _key.getId()); Version version = (_version != null) ? _version : nodeMap.getVersion(); VListNode<E> listNode = VListNode.valueOf(nodeMap.getValue()); if(!listNode.isStable()) { throw new ObsoleteVersionException("node " + _key.getId() + " not stable."); } _result = listNode.getValue(); VListNode<E> newNode = new VListNode<E>(_element, listNode.getId(), listNode.getPreviousId(), listNode.getNextId(), true); storeClient.put(_key.mapValue(), new Versioned<Map<String, Object>>(newNode.mapValue(), version)); }
throw new ObsoleteVersionException("cannot add when list node is not stable"); Versioned<Map<String, Object>> nextNodeMap = storeClient.get(nextKey.mapValue()); if(nextNodeMap == null) throw new ObsoleteVersionException("possible concurrent modification"); nextNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()), nextNodeMap.getVersion()); if(!nextNode.getValue().isStable()) { throw new ObsoleteVersionException("cannot add when list node is not stable"); throw new ObsoleteVersionException("unable to update node");
@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++; }