private VectorClock makeDenseClock() { // FIXME This is a temporary workaround for System store client not // being able to do a second insert. We simply generate a super // clock that will trump what is on storage // But this will not work, if the nodes are ever removed or re-assigned. // To complicate the issue further, SystemStore uses one clock for all // keys in a file. When you remove nodes, go delete, all version files from the disk // otherwise return VectorClockUtils.makeClockWithCurrentTime(currentCluster.getNodeIds()); }
void streamingPut(ByteArray key, Versioned<byte[]> value) { if(overwrite) { VectorClock denseClock = VectorClockUtils.makeClockWithCurrentTime(dstServerIds); Versioned<byte[]> updatedValue = new Versioned<byte[]>(value.getValue(), denseClock); dstStreamingClient.streamingPut(key, updatedValue); } else { dstStreamingClient.streamingPut(key, value); } entriesForkLifted++; if(entriesForkLifted % progressOps == 0) { logger.info(workName + " fork lifted " + entriesForkLifted + " entries successfully"); } }
public static void setQuota(String storeName, QuotaType type, StoreRepository repository, Set<Integer> nodeIds, long lquota) { FileBackedCachingStorageEngine quotaStore = getQuotaStore(repository); String quotaKey = makeQuotaKey(storeName, QuotaType.STORAGE_SPACE); ByteArray keyArray = convertToByteArray(quotaKey); List<Versioned<byte[]>> existingValue = quotaStore.get(keyArray, null); String quotaValue = Long.toString(lquota); ByteArray valueArray = convertToByteArray(quotaValue); VectorClock newClock = VectorClockUtils.makeClockWithCurrentTime(nodeIds); Versioned<byte[]> newValue = new Versioned<byte[]>(valueArray.get(), newClock); quotaStore.put(keyArray, newValue, null); } }
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()); } } }
@Test public void testClusterWithDifferentStateFails() throws IOException { Cluster localCluster = ServerTestUtils.getLocalCluster(1); VoldemortConfig config = getVoldemortConfig(new Properties()); server = new VoldemortServer(config, localCluster); server.start(); final int UPDATED_NODE_ID = 3; Node oldNode = localCluster.getNodes().iterator().next(); // For single local node, host matcher is not used. config.setNodeIdImplementation(new NodeIdHostMatcher(UPDATED_NODE_ID)); Cluster updatedCluster = ServerTestUtils.getLocalCluster(UPDATED_NODE_ID + 1); oldAdminClient = new AdminClient(localCluster); try { oldAdminClient.metadataMgmtOps.updateRemoteCluster(oldNode.getId(), updatedCluster, VectorClockUtils.makeClockWithCurrentTime(localCluster.getNodeIds())); Assert.fail("Invalid node id should have failed"); } catch(VoldemortException ex) { // Expected, ignore } }
VectorClockUtils.makeClockWithCurrentTime(localCluster.getNodeIds()));