@SuppressWarnings("unchecked") public List<StoreDefinition> getRebalancingSourceStores() { // acquire read lock readLock.lock(); try { return (List<StoreDefinition>) metadataCache.get(REBALANCING_SOURCE_STORES_XML) .getValue(); } finally { readLock.unlock(); } }
public boolean getSlopStreamingEnabledUnlocked() { return Boolean.parseBoolean(metadataCache.get(SLOP_STREAMING_ENABLED_KEY) .getValue() .toString()); }
public boolean getQuotaEnforcingEnabledUnlocked() { return Boolean.parseBoolean(metadataCache.get(QUOTA_ENFORCEMENT_ENABLED_KEY) .getValue() .toString()); }
public RebalancerState getRebalancerState() { // acquire read lock readLock.lock(); try { return (RebalancerState) metadataCache.get(REBALANCING_STEAL_INFO).getValue(); } finally { readLock.unlock(); } }
public UpdateElementById(VListKey<K> key, Versioned<E> element) { _key = key; _element = element.getValue(); _version = element.getVersion(); }
public static void writeResults(DataOutputStream outputStream, List<Versioned<byte[]>> values) throws IOException { outputStream.writeInt(values.size()); for(Versioned<byte[]> v: values) { byte[] clock = ((VectorClock) v.getVersion()).toBytes(); byte[] value = v.getValue(); outputStream.writeInt(clock.length + value.length); outputStream.write(clock); outputStream.write(value); } }
@Override public void put(K key, Versioned<byte[]> value, byte[] transforms) throws VoldemortException { try { getInnerStore().put(key, new Versioned<byte[]>(IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(value.getValue()))), value.getVersion()), transforms); } catch(IOException e) { throw new VoldemortException(e); } }
public static int getResultsSize(List<Versioned<byte[]>> values) { int size = 4; for(Versioned<byte[]> v: values) { size += 4; size += ((VectorClock) v.getVersion()).sizeInBytes(); size += v.getValue().length; } return size; }
private static List<StoreDefinition> getStoreDefinitions(AdminClient adminClient, int nodeId) { Versioned<List<StoreDefinition>> storeDefs = null; if(nodeId >= 0) { storeDefs = adminClient.metadataMgmtOps.getRemoteStoreDefList(nodeId); } else { storeDefs = adminClient.metadataMgmtOps.getRemoteStoreDefList(); } return storeDefs.getValue(); }
/** * @param versioned Versioned value with version information and value * itself */ public HashedValue(Versioned<byte[]> versioned) { innerVersion = versioned.getVersion(); valueHash = new FnvHashFunction().hash(versioned.getValue()); }
/** * Get the ver * * @param id * @return */ public Versioned<E> getVersionedById(int id) { Versioned<VListNode<E>> listNode = getListNode(id); if(listNode == null) throw new IndexOutOfBoundsException(); return new Versioned<E>(listNode.getValue().getValue(), listNode.getVersion()); }
@Override public List<Versioned<V>> get(K key, T transforms) throws VoldemortException { List<Versioned<byte[]>> found = store.get(keyToBytes(key), (transformsSerializer != null && transforms != null) ? transformsSerializer.toBytes(transforms) : null); List<Versioned<V>> results = new ArrayList<Versioned<V>>(found.size()); for(Versioned<byte[]> versioned: found) results.add(new Versioned<V>(valueSerializer.toObject(versioned.getValue()), versioned.getVersion())); return results; }
public static VProto.Versioned.Builder encodeVersioned(Versioned<byte[]> versioned) { return VProto.Versioned.newBuilder() .setValue(ByteString.copyFrom(versioned.getValue())) .setVersion(ProtoUtils.encodeClock(versioned.getVersion())); }
private Versioned<byte[]> incremented(Versioned<byte[]> versioned, int nodeId) { return new Versioned<byte[]>(versioned.getValue(), ((VectorClock) versioned.getVersion()).incremented(nodeId, time.getMilliseconds())); }
@Override public void verifyConnection(Node node) throws UnreachableStoreException, VoldemortException { Integer returnNodeId = Integer.parseInt(getAdminClient().metadataMgmtOps.getRemoteMetadata(node.getId(), MetadataStore.NODE_ID_KEY) .getValue()); if(returnNodeId != node.getId()) { throw new VoldemortException("Incorrect node id " + returnNodeId + " returned from node " + node.getId()); } }
@Test public void testGetAll() { Versioned<String> r0 = storeClient.get("a"); assertEquals("1", r0.getValue()); rebalance(); Map<String, Versioned<String>> res = storeClient.getAll(ImmutableList.of("a", "b")); assertTrue("getAll() contains a", res.containsKey("a")); assertTrue("getAll() contains b", res.containsKey("b")); assertEquals("getAll() returns correct value #1", "1", res.get("a").getValue()); assertEquals("getAll() returns correct value #2", "2", res.get("b").getValue()); } }
private void validateQuota(String storeName){ AdminClient adminClient = getAdminClient(); Versioned<String> value = adminClient.quotaMgmtOps.getQuota(storeName, QuotaType.STORAGE_SPACE); assertEquals("Default storage quota does not match", Long.toString(defaultStoreQuota), value.getValue()); }
@Test public void testAllUp() { try { List<Versioned<String>> versioneds = client.get("K1", null); assertEquals(versioneds.get(0).getValue(), "V1"); } catch(InsufficientOperationalNodesException e) { fail("Failed with exception: " + e); } }
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); } }