@Override public NodeValue<K, V> clone() { return new NodeValue<K, V>(nodeId, key, value); }
protected void insertNodeValue(Node node, ByteArray key, List<Versioned<byte[]>> value) { if(value.size() == 0) { Versioned<byte[]> versioned = new Versioned<byte[]>(null); nodeValues.add(new NodeValue<ByteArray, byte[]>(node.getId(), key, versioned)); } else { for(Versioned<byte[]> versioned: value) nodeValues.add(new NodeValue<ByteArray, byte[]>(node.getId(), key, versioned)); } }
private void fillRepairReadsValues(final List<NodeValue<ByteArray, byte[]>> nodeValues, final ByteArray key, Node node, List<Versioned<byte[]>> fetched) { if(repairReads) { if(fetched.size() == 0) nodeValues.add(nullValue(node, key)); else { for(Versioned<byte[]> f: fetched) nodeValues.add(new NodeValue<ByteArray, byte[]>(node.getId(), key, f)); } } }
private void setMetadataVersion(int nodeId, Versioned<byte[]> value) { ByteArray keyArray = getKeyArray(); NodeValue<ByteArray, byte[]> nodeKeyValue = new NodeValue<ByteArray, byte[]>(nodeId, keyArray, value); storeOps.putNodeKeyValue(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name(), nodeKeyValue); }
private NodeValue<ByteArray, byte[]> nullValue(Node node, ByteArray key) { return new NodeValue<ByteArray, byte[]>(node.getId(), key, new Versioned<byte[]>(null)); }
public void setQuotaForNode(String storeName, QuotaType quotaType, Integer nodeId, Long quota) { ByteArray keyArray = QuotaUtils.getByteArrayKey(storeName, quotaType); VectorClock clock = makeDenseClock(); byte[] valueArray = ByteUtils.getBytes(quota.toString(), "UTF8"); Versioned<byte[]> value = new Versioned<byte[]>(valueArray, clock); NodeValue<ByteArray, byte[]> nodeKeyValue = new NodeValue<ByteArray, byte[]>(nodeId, keyArray, value); storeOps.putNodeKeyValue(SystemStoreConstants.SystemStoreName.voldsys$_store_quotas.name(), nodeKeyValue); }
if(keyValue.getValues().isEmpty()) { Versioned<byte[]> versioned = new Versioned<byte[]>(null); nodeValues.add(new NodeValue<ByteArray, byte[]>(nodeId, keyValue.getKey(), versioned)); nodeValues.add(new NodeValue<ByteArray, byte[]>(nodeId, keyValue.getKey(), value)); logger.debug("No key-value returned from node with id:" + nodeId); Versioned<byte[]> versioned = new Versioned<byte[]>(null); nodeValues.add(new NodeValue<ByteArray, byte[]>(nodeId, keyAsByteArray, versioned));
public static NodeValue<ByteArray, byte[]> createNodeValue(int nodeId, Version version) { ByteArray key = new ByteArray(new byte[]{54, 52, 49, 57, 52, 54, 51, 51}); byte[] value = new byte[]{69,119,105,119,83,71,80,113,108,108,119,86,67,120,103,111}; Versioned<byte[]> versioned = new Versioned<byte[]>(value, version); return new NodeValue<ByteArray, byte[]>(nodeId, key, versioned); }
/** * Testing helper method to construct node-values out of thin air. * * @param nodeId The node ID * @param value The value (an integer) * @param version The version (vector of integers passed to getClock()) * @return */ private NodeValue<String, Integer> getValue(int nodeId, int value, int[] version) { return new NodeValue<String, Integer>(nodeId, Integer.toString(value), new Versioned<Integer>(value, getClock(version))); }
Versioned<byte[]> versioned = Versioned.value(v.getVersioned().getValue(), ((VectorClock) v.getVersion()).clone()); toReadRepair.add(new NodeValue<ByteArray, byte[]>(v.getNodeId(), v.getKey(), versioned));
Versioned<byte[]> versioned = Versioned.value(v.getVersioned().getValue(), ((VectorClock) v.getVersion()).clone()); toReadRepair.add(new NodeValue<ByteArray, byte[]>(v.getNodeId(), v.getKey(), versioned));
public void setGetPutQuotasForEachServer() throws Exception { Properties adminProperties = new Properties(); adminProperties.setProperty("max_connections", "2"); adminClient = new AdminClient(cluster, new AdminClientConfig().setMaxConnectionsPerNode(2)); Map<Pair<Integer, QuotaType>, Integer> throughPutMap = new HashMap<Pair<Integer, QuotaType>, Integer>(); // Set Node0 Quota throughPutMap.put(new Pair<Integer, QuotaType>(0, QuotaType.PUT_THROUGHPUT), 5); throughPutMap.put(new Pair<Integer, QuotaType>(0, QuotaType.GET_THROUGHPUT), 20); // Set Node1 Quota throughPutMap.put(new Pair<Integer, QuotaType>(1, QuotaType.PUT_THROUGHPUT), 2); throughPutMap.put(new Pair<Integer, QuotaType>(1, QuotaType.GET_THROUGHPUT), 20); for(Entry<Pair<Integer, QuotaType>, Integer> throughPut: throughPutMap.entrySet()) { int nodeId = throughPut.getKey().getFirst(); QuotaType type = throughPut.getKey().getSecond(); int value = throughPut.getValue(); VectorClock clock = VectorClockUtils.makeClockWithCurrentTime(cluster.getNodeIds()); NodeValue<ByteArray, byte[]> operationValue = new NodeValue<ByteArray, byte[]>(nodeId, new ByteArray(getKeyBytes(type)), new Versioned<byte[]>(ByteUtils.getBytes(Integer.toString(value), encodingType), clock)); try { adminClient.storeOps.putNodeKeyValue(quotaStoreName, operationValue); } catch(Exception e) { throw new Exception("Exception when setting put quota for node " + nodeId + " Operation " + type + "." + e.getMessage()); } } }
losingClock.getTimestamp() + 1); srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(nodeList.get(0), new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock))); srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(nodeList.get(1), new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"),
losingClock.getTimestamp() + 1); srcAdminClient.storeOps.putNodeKeyValue(PRIMARY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock))); srcAdminClient.storeOps.putNodeKeyValue(PRIMARY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"),
losingClock.getTimestamp() + 1); srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(nodeList.get(0), new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock))); srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(nodeList.get(1), new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"),
private void populateSlops(List<Versioned<Slop>> slops) { for(Versioned<Slop> slop: slops) { VectorClock clock = TestUtils.getClock(1); NodeValue<ByteArray, byte[]> nodeValue = new NodeValue<ByteArray, byte[]>(PURGE_SERVER_ID, slop.getValue() .makeKey(), new Versioned<byte[]>(slopSerializer.toBytes(slop.getValue()), clock)); adminClient.storeOps.putNodeKeyValue("slop", nodeValue); } }
for(int putNode: putNodes) { NodeValue<ByteArray, byte[]> nodeKeyValue; nodeKeyValue = new NodeValue<ByteArray, byte[]>(putNode, baKey, value); adminClient.storeOps.putNodeKeyValue(ConsistencyFixTest.STORE_NAME, nodeKeyValue);
losingClock.getTimestamp() + 1); srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock))); srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"),
NodeValue<ByteArray, byte[]> nodeValue = new NodeValue<ByteArray, byte[]>(0, slop.getValue() .makeKey(),