@Test public void testGetAllWithBinaryData() throws Exception { Store<ByteArray, byte[], byte[]> store = getStore(); List<ByteArray> keys = Lists.newArrayList(); List<byte[]> values = Lists.newArrayList(); // The Byte 0x8c is interesting, because if you use GetContent method of // MimeBodyPart it gets converted to 0xc2 and 0x8c // This thread tracks this question // http://stackoverflow.com/questions/23023583/mimebodypart-getcontent-corrupts-binary-data byte[] interestingByte = new byte[] {(byte) 0x8c}; ByteArray interestingKey = new ByteArray(interestingByte); keys.add(interestingKey); values.add(interestingByte); // Add all possible byte values byte[] allPossibleBytes = getAllPossibleBytes(); ByteArray allPossibleKey = new ByteArray(allPossibleBytes); keys.add(allPossibleKey); values.add(allPossibleBytes); assertEquals(keys.size(), values.size()); int count = keys.size(); for (int i = 0; i < count; i++) { VectorClock vc = getClock(0, 0); store.put(keys.get(i), new Versioned<byte[]>(values.get(i), vc), null); } Map<ByteArray, List<Versioned<byte[]>>> result = store.getAll(keys, null); assertGetAllValues(keys, values, result); }
@Override @Test public void testFetchedEqualsPut() throws Exception { System.out.println(" Testing Fetchhed equals put "); ByteArray key = getKey(); Store<ByteArray, byte[], byte[]> store = getStore(); VectorClock clock = getClock(1, 1, 2, 3, 3, 4); byte[] value = getValue(); System.out.println("Value chosen : " + value); List<Versioned<byte[]>> resultList = store.get(key, null); assertNotNull("Null result list obtained from a get request", resultList); assertEquals("Store not empty at start!", 0, resultList.size()); Versioned<byte[]> versioned = new Versioned<byte[]>(value, clock); store.put(key, versioned, null); List<Versioned<byte[]>> found = store.get(key, null); assertEquals("Should only be one version stored.", 1, found.size()); System.out.println("individual bytes"); System.out.println("input"); printBytes(versioned.getValue()); System.out.println("found"); printBytes(found.get(0).getValue()); assertTrue("Values not equal!", valuesEqual(versioned.getValue(), found.get(0).getValue())); }
@Test public void testUpdate() { final HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE); Iterator<Pair<ByteArray, Versioned<byte[]>>> iterator = new AbstractIterator<Pair<ByteArray, Versioned<byte[]>>>() { final Iterator<Entry<ByteArray, byte[]>> entrySetItr = entrySet.entrySet().iterator(); @Override protected Pair<ByteArray, Versioned<byte[]>> computeNext() { while (entrySetItr.hasNext()) { Entry<ByteArray, byte[]> entry = entrySetItr.next(); return new Pair<ByteArray, Versioned<byte[]>>( entry.getKey(), new Versioned<byte[]>(entry.getValue())); } return endOfData(); } }; getAdminClient().updateEntries(0, testStoreName, iterator, null); // check updated values Store<ByteArray, byte[]> store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { assertNotSame("entry should be present at store", 0, store.get(entry.getKey()).size()); assertEquals( "entry value should match", new String(entry.getValue()), new String(store.get(entry.getKey()).get(0).getValue())); } }
@Test public void testFetchPartitionKeys() { HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE); List<Integer> fetchPartitionsList = Arrays.asList(0, 2); // insert it into server-0 store int fetchPartitionKeyCount = 0; Store<ByteArray, byte[]> store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { store.put(entry.getKey(), new Versioned<byte[]>(entry.getValue())); if (isKeyPartition(entry.getKey(), 0, testStoreName, fetchPartitionsList)) { fetchPartitionKeyCount++; } } Iterator<ByteArray> fetchIt = getAdminClient().fetchKeys(0, testStoreName, fetchPartitionsList, null, false); // check values int count = 0; while (fetchIt.hasNext()) { assertEquals( "Fetched key should belong to asked partitions", true, isKeyPartition(fetchIt.next(), 0, testStoreName, fetchPartitionsList)); count++; } // assert all keys for asked partitions are returned. assertEquals("All keys for asked partitions should be received", fetchPartitionKeyCount, count); }
@Test public void testRecoverData() { // use store with replication 2, required write 2 for this test. String testStoreName = "test-recovery-data"; HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE); // insert it into server-0 store Store<ByteArray, byte[]> store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { store.put(entry.getKey(), new Versioned<byte[]>(entry.getValue())); } // assert server 1 is empty store = getStore(1, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { assertSame("entry should NOT be present at store", 0, store.get(entry.getKey()).size()); } // recover all data adminClient.restoreDataFromReplications(1, 2); // assert server 1 has all entries for its partitions store = getStore(1, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { ByteArray key = entry.getKey(); assertSame("entry should be present for key " + key, 1, store.get(entry.getKey()).size()); assertEquals( "entry value should match", new String(entry.getValue()), new String(store.get(entry.getKey()).get(0).getValue())); } }
@Ignore @Test public void testHintedHandoff() throws Exception { Set<Integer> failedNodes = getFailedNodes(); Multimap<Integer, ByteArray> failedKeys = populateStore(failedNodes); Map<ByteArray, byte[]> dataInSlops = Maps.newHashMap(); Set<ByteArray> slopKeys = makeSlopKeys(failedKeys, Slop.Operation.PUT); for (Store<ByteArray, Slop, byte[]> slopStore : slopStores.values()) { Map<ByteArray, List<Versioned<Slop>>> res = slopStore.getAll(slopKeys, null); for (Map.Entry<ByteArray, List<Versioned<Slop>>> entry : res.entrySet()) { Slop slop = entry.getValue().get(0).getValue(); dataInSlops.put(slop.getKey(), slop.getValue()); if (logger.isTraceEnabled()) logger.trace(slop); } } for (Map.Entry<Integer, ByteArray> failedKey : failedKeys.entries()) { byte[] expected = keyValues.get(failedKey.getValue()).get(); byte[] actual = dataInSlops.get(failedKey.getValue()); assertNotNull("data should be stored in the slop", actual); assertEquals("correct should be stored in slop", 0, ByteUtils.compare(actual, expected)); } }
public void addRedirectingSocketStore(int nodeId, Store<ByteArray, byte[], byte[]> store) { Pair<String, Integer> key = Pair.create(store.getName(), nodeId); Store<ByteArray, byte[], byte[]> found = this.redirectingSocketStores.putIfAbsent(key, store); if (found != null) throw new VoldemortException( "Store '" + store.getName() + "' for node " + nodeId + " has already been initialized."); }
protected void initializeMetadataVersions(List<StoreDefinition> storeDefs) { Store<ByteArray, byte[], byte[]> versionStore = storeRepository.getLocalStore( SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name()); Properties props = new Properties(); try { boolean isPropertyAdded = false; ByteArray metadataVersionsKey = new ByteArray(SystemStoreConstants.VERSIONS_METADATA_KEY.getBytes()); List<Versioned<byte[]>> versionList = versionStore.get(metadataVersionsKey, null); VectorClock newClock = null; if (versionList != null && versionList.size() > 0) { byte[] versionsByteArray = versionList.get(0).getValue(); if (versionsByteArray != null) { props.load(new ByteArrayInputStream(versionsByteArray)); } newClock = (VectorClock) versionList.get(0).getVersion(); newClock = newClock.incremented(0, System.currentTimeMillis()); } else { newClock = new VectorClock(); } // Check if version exists for cluster.xml if (!props.containsKey(SystemStoreConstants.CLUSTER_VERSION_KEY)) { props.setProperty(SystemStoreConstants.CLUSTER_VERSION_KEY, "0"); isPropertyAdded = true; } // Check if version exists for stores.xml if (!props.containsKey(SystemStoreConstants.STORES_VERSION_KEY)) { props.setProperty(SystemStoreConstants.STORES_VERSION_KEY, "0"); isPropertyAdded = true; } // Check if version exists for each store for (StoreDefinition def : storeDefs) { if (!props.containsKey(def.getName())) { props.setProperty(def.getName(), "0"); isPropertyAdded = true; } } if (isPropertyAdded) { StringBuilder finalVersionList = new StringBuilder(); for (String propName : props.stringPropertyNames()) { finalVersionList.append(propName + "=" + props.getProperty(propName) + "\n"); } versionStore.put( metadataVersionsKey, new Versioned<byte[]>(finalVersionList.toString().getBytes(), newClock), null); } } catch (Exception e) { logger.error("Error while intializing metadata versions ", e); } }
public void close() { VoldemortException exception = null; for (Store<?, ?, ?> store : innerStores.values()) { try { store.close(); } catch (VoldemortException e) { exception = e; } } if (exception != null) throw exception; }
@Test @Ignore public void testDeleteHandoff() throws Exception { populateStore(Sets.<Integer>newHashSet()); Map<ByteArray, Version> versions = Maps.newHashMap(); for (ByteArray key : keyValues.keySet()) versions.put(key, store.get(key, null).get(0).getVersion()); Set<Integer> failedNodes = getFailedNodes(); Multimap<Integer, ByteArray> failedKeys = ArrayListMultimap.create(); for (ByteArray key : keysToNodes.keySet()) { Iterable<Integer> nodes = keysToNodes.get(key); for (int i = 0; i < REPLICATION_FACTOR; i++) { int node = Iterables.get(nodes, i); if (failedNodes.contains(node)) { failedKeys.put(node, key); break; } } } for (Map.Entry<Integer, ByteArray> failedKey : failedKeys.entries()) { try { store.delete(failedKey.getValue(), versions.get(failedKey.getValue())); } catch (Exception e) { if (logger.isTraceEnabled()) logger.trace(e, e); } } Set<ByteArray> slopKeys = makeSlopKeys(failedKeys, Slop.Operation.DELETE); Set<ByteArray> keysInSlops = Sets.newHashSet(); for (Store<ByteArray, Slop, byte[]> slopStore : slopStores.values()) { Map<ByteArray, List<Versioned<Slop>>> res = slopStore.getAll(slopKeys, null); for (Map.Entry<ByteArray, List<Versioned<Slop>>> entry : res.entrySet()) { Slop slop = entry.getValue().get(0).getValue(); keysInSlops.add(slop.getKey()); if (logger.isTraceEnabled()) logger.trace(slop); } } for (Map.Entry<Integer, ByteArray> failedKey : failedKeys.entries()) assertTrue( "delete operation for " + failedKey.getValue() + " should be handed off", keysInSlops.contains(failedKey.getValue())); }
/** * Performs a back-door proxy get to {@link * voldemort.client.rebalance.RebalancePartitionsInfo#getDonorId() getDonorId} * * @param key Key * @param donorNodeId donor node id * @throws ProxyUnreachableException if donor node can't be reached */ private List<Versioned<byte[]>> proxyGet(ByteArray key, int donorNodeId, byte[] transform) { Node donorNode = metadata.getCluster().getNodeById(donorNodeId); checkNodeAvailable(donorNode); long startNs = System.nanoTime(); try { Store<ByteArray, byte[], byte[]> redirectingStore = getRedirectingSocketStore(getName(), donorNodeId); List<Versioned<byte[]>> values = redirectingStore.get(key, transform); recordSuccess(donorNode, startNs); return values; } catch (UnreachableStoreException e) { recordException(donorNode, startNs, e); throw new ProxyUnreachableException("Failed to reach proxy node " + donorNode, e); } }
/** @throws IOException */ @Test public void testFetchAndUpdate() throws IOException { HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE); List<Integer> fetchAndUpdatePartitionsList = Arrays.asList(0, 2); // insert it into server-0 store int fetchPartitionKeyCount = 0; Store<ByteArray, byte[]> store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { store.put(entry.getKey(), new Versioned<byte[]>(entry.getValue())); if (isKeyPartition(entry.getKey(), 0, testStoreName, fetchAndUpdatePartitionsList)) { fetchPartitionKeyCount++; } } // assert that server1 is empty. store = getStore(1, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) assertEquals("server1 should be empty at start.", 0, store.get(entry.getKey()).size()); // do fetch And update call server1 <-- server0 AdminClient client = getAdminClient(); int id = client.migratePartitions(0, 1, testStoreName, fetchAndUpdatePartitionsList, null); client.waitForCompletion(1, id, 60, TimeUnit.SECONDS); // check values int count = 0; store = getStore(1, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { if (isKeyPartition(entry.getKey(), 0, testStoreName, fetchAndUpdatePartitionsList)) { assertEquals( "server1 store should contain fetchAndupdated partitions.", 1, store.get(entry.getKey()).size()); assertEquals( "entry value should match", new String(entry.getValue()), new String(store.get(entry.getKey()).get(0).getValue())); count++; } } // assert all keys for asked partitions are returned. assertEquals("All keys for asked partitions should be received", fetchPartitionKeyCount, count); }
public void registerSystemEngine(StorageEngine<ByteArray, byte[], byte[]> engine) { Cluster cluster = this.metadata.getCluster(); storeRepository.addStorageEngine(engine); /* Now add any store wrappers that are enabled */ Store<ByteArray, byte[], byte[]> store = engine; if (voldemortConfig.isVerboseLoggingEnabled()) store = new LoggingStore<ByteArray, byte[], byte[]>( store, cluster.getName(), SystemTime.INSTANCE); if (voldemortConfig.isMetadataCheckingEnabled()) store = new InvalidMetadataCheckingStore(metadata.getNodeId(), store, metadata); if (voldemortConfig.isStatTrackingEnabled()) { StatTrackingStore statStore = new StatTrackingStore(store, this.storeStats); store = statStore; if (voldemortConfig.isJmxEnabled()) { MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); ObjectName name = null; if (this.voldemortConfig.isEnableJmxClusterName()) name = JmxUtils.createObjectName( metadata.getCluster().getName() + "." + JmxUtils.getPackageName(store.getClass()), store.getName()); else name = JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()), store.getName()); synchronized (mbeanServer) { if (mbeanServer.isRegistered(name)) JmxUtils.unregisterMbean(mbeanServer, name); JmxUtils.registerMbean( mbeanServer, JmxUtils.createModelMBean(new StoreStatsJmx(statStore.getStats())), name); } } } storeRepository.addLocalStore(store); }
@Override @After public void tearDown() throws Exception { super.tearDown(); for (VoldemortServer server : servers) { ServerTestUtils.stopVoldemortServer(server); } store.close(); }
@Override @Test public void testGetVersions() throws Exception { List<ByteArray> keys = getKeys(2); ByteArray key = keys.get(0); byte[] value = getValue(); VectorClock vc = getClock(0, 0); Store<ByteArray, byte[], byte[]> store = getStore(); store.put(key, Versioned.value(value, vc), null); List<Versioned<byte[]>> versioneds = store.get(key, null); List<Version> versions = store.getVersions(key); assertEquals(1, versioneds.size()); assertTrue(versions.size() > 0); for (int i = 0; i < versions.size(); i++) assertEquals(versioneds.get(0).getVersion(), versions.get(i)); assertEquals(0, store.getVersions(keys.get(1)).size()); }
@Test public void testAllUp() { try { List<Versioned<String>> versioneds = client.get("AB", null); assertEquals(versioneds.get(0).getValue(), "AB"); } catch (InsufficientOperationalNodesException e) { fail("Failed with exception: " + e); } }
public void unregisterSystemEngine(StorageEngine<ByteArray, byte[], byte[]> engine) { String storeName = engine.getName(); Store<ByteArray, byte[], byte[]> store = storeRepository.removeLocalStore(storeName); if (store != null) { if (voldemortConfig.isJmxEnabled()) { MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); if (voldemortConfig.isEnableRebalanceService()) { ObjectName name = null; if (this.voldemortConfig.isEnableJmxClusterName()) name = JmxUtils.createObjectName( metadata.getCluster().getName() + "." + JmxUtils.getPackageName(RedirectingStore.class), store.getName()); else name = JmxUtils.createObjectName( JmxUtils.getPackageName(RedirectingStore.class), store.getName()); synchronized (mbeanServer) { if (mbeanServer.isRegistered(name)) JmxUtils.unregisterMbean(mbeanServer, name); } } if (voldemortConfig.isStatTrackingEnabled()) { ObjectName name = null; if (this.voldemortConfig.isEnableJmxClusterName()) name = JmxUtils.createObjectName( metadata.getCluster().getName() + "." + JmxUtils.getPackageName(store.getClass()), store.getName()); else name = JmxUtils.createObjectName( JmxUtils.getPackageName(store.getClass()), store.getName()); synchronized (mbeanServer) { if (mbeanServer.isRegistered(name)) JmxUtils.unregisterMbean(mbeanServer, name); } } } if (voldemortConfig.isServerRoutingEnabled()) { this.storeRepository.removeRoutedStore(storeName); for (Node node : metadata.getCluster().getNodes()) this.storeRepository.removeNodeStore(storeName, node.getId()); } } storeRepository.removeStorageEngine(storeName); // engine.truncate(); why truncate here when unregister? Isn't close // good enough? engine.close(); }
private Message handleGetVersion(GetRequest request, Store<ByteArray, byte[]> store) { VProto.GetVersionResponse.Builder response = VProto.GetVersionResponse.newBuilder(); try { List<Version> versions = store.getVersions(ProtoUtils.decodeBytes(request.getKey())); for (Version version : versions) response.addVersions(ProtoUtils.encodeClock(version)); } catch (VoldemortException e) { response.setError(ProtoUtils.encodeError(getErrorMapper(), e)); } return response.build(); }
@Before public void setup() throws IOException { byte[] bytes1 = {(byte) 'A', (byte) 'B'}; byte[] bytes2 = {(byte) 'C', (byte) 'D'}; List<StoreDefinition> stores = ClusterTestUtils.getZZZ322StoreDefs("memory"); StoreDefinition storeDef = stores.get(0); cluster = ClusterTestUtils.getZZZCluster(); ClientConfig clientConfig = new ClientConfig(); clientConfig.setBootstrapUrls(cluster.getNodeById(0).getSocketUrl().toString()); clientConfig.getZoneAffinity().setEnableGetOpZoneAffinity(true); clientConfig.setClientZoneId(clientZoneId); SocketStoreClientFactory socketStoreClientFactory = new SocketStoreClientFactory(clientConfig); for (Integer nodeId : cluster.getNodeIds()) { SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024); VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs( true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties()); VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster); vservers.put(nodeId, vs); socketStoreFactories.put(nodeId, socketStoreFactory); Store<ByteArray, byte[], byte[]> store = vs.getStoreRepository().getLocalStore(storeDef.getName()); Node node = cluster.getNodeById(nodeId); VectorClock version1 = new VectorClock(); version1.incrementVersion(0, System.currentTimeMillis()); VectorClock version2 = version1.incremented(0, System.currentTimeMillis()); if (node.getZoneId() == clientZoneId) { store.put(new ByteArray(bytes1), new Versioned<byte[]>(bytes1, version1), null); } else { store.put(new ByteArray(bytes1), new Versioned<byte[]>(bytes2, version2), null); } } client = socketStoreClientFactory.getRawStore(storeDef.getName(), null); }
@Override @Test public void testGetAll() throws Exception { Store<ByteArray, byte[], byte[]> store = getStore(); int putCount = 10; List<ByteArray> keys = getKeys(putCount); List<byte[]> values = getValues(putCount); assertEquals(putCount, values.size()); for (int i = 0; i < putCount; i++) { VectorClock vc = getClock(0, 0); store.put(keys.get(i), new Versioned<byte[]>(values.get(i), vc), null); } int countForGet = putCount / 2; List<ByteArray> keysForGet = keys.subList(0, countForGet); List<byte[]> valuesForGet = values.subList(0, countForGet); Map<ByteArray, List<Versioned<byte[]>>> result = store.getAll(keysForGet, null); assertGetAllValues(keysForGet, valuesForGet, result); }
// check the basic rebalanceNode call. @Test public void testRebalanceNode() { HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE); List<Integer> fetchAndUpdatePartitionsList = Arrays.asList(0, 2); // insert it into server-0 store int fetchPartitionKeyCount = 0; Store<ByteArray, byte[]> store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { store.put(entry.getKey(), new Versioned<byte[]>(entry.getValue())); if (isKeyPartition(entry.getKey(), 0, testStoreName, fetchAndUpdatePartitionsList)) { fetchPartitionKeyCount++; } } List<Integer> rebalancePartitionList = Arrays.asList(1, 3); RebalancePartitionsInfo stealInfo = new RebalancePartitionsInfo( 1, 0, rebalancePartitionList, new ArrayList<Integer>(0), Arrays.asList(testStoreName), 0); int asyncId = adminClient.rebalanceNode(stealInfo); assertNotSame("Got a valid rebalanceAsyncId", -1, asyncId); getAdminClient().waitForCompletion(1, asyncId, 120, TimeUnit.SECONDS); // assert data is copied correctly store = getStore(1, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { if (isKeyPartition(entry.getKey(), 1, testStoreName, rebalancePartitionList)) { assertSame("entry should be present at store", 1, store.get(entry.getKey()).size()); assertEquals( "entry value should match", new String(entry.getValue()), new String(store.get(entry.getKey()).get(0).getValue())); } } }
private VProto.PutResponse handlePut(VProto.PutRequest request, Store<ByteArray, byte[]> store) { VProto.PutResponse.Builder response = VProto.PutResponse.newBuilder(); try { ByteArray key = ProtoUtils.decodeBytes(request.getKey()); Versioned<byte[]> value = ProtoUtils.decodeVersioned(request.getVersioned()); store.put(key, value); } catch (VoldemortException e) { response.setError(ProtoUtils.encodeError(getErrorMapper(), e)); } return response.build(); }
@After public void tearDown() { client.close(); for (VoldemortServer vs : this.vservers.values()) { vs.stop(); } for (SocketStoreFactory ssf : this.socketStoreFactories.values()) { ssf.close(); } ClusterTestUtils.reset(); }
@Test public void testTruncate() throws Exception { HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE); // insert it into server-0 store Store<ByteArray, byte[]> store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { store.put(entry.getKey(), new Versioned<byte[]>(entry.getValue())); } // do truncate request getAdminClient().truncate(0, testStoreName); store = getStore(0, testStoreName); for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) { assertEquals("Deleted key should be missing.", 0, store.get(entry.getKey()).size()); } }
@Test public void testLocalZonePartialDownSufficientReads() { // turn off one node in same zone as client so that reads can still // complete this.vservers.get(cluster.getNodeIdsInZone(clientZoneId).iterator().next()).stop(); try { client.get("AB", null); } catch (InsufficientOperationalNodesException e) { fail("Failed with exception: " + e); } }
@JmxOperation( description = "Clean all rebalancing server/cluster states from this node.", impact = MBeanOperationInfo.ACTION) public void cleanAllRebalancingState() { for (String key : OPTIONAL_KEYS) { if (!key.equals(NODE_ID_KEY)) innerStore.delete(key, getVersions(new ByteArray(ByteUtils.getBytes(key, "UTF-8"))).get(0)); } init(getNodeId()); }
private VProto.GetResponse handleGet(VProto.GetRequest request, Store<ByteArray, byte[]> store) { VProto.GetResponse.Builder response = VProto.GetResponse.newBuilder(); try { List<Versioned<byte[]>> values = store.get(ProtoUtils.decodeBytes(request.getKey())); for (Versioned<byte[]> versioned : values) response.addVersioned(ProtoUtils.encodeVersioned(versioned)); } catch (VoldemortException e) { response.setError(ProtoUtils.encodeError(getErrorMapper(), e)); } return response.build(); }
@Test public void testLocalZoneDown() { for (Integer nodeId : cluster.getNodeIdsInZone(clientZoneId)) { this.vservers.get(nodeId).stop(); } try { client.get("AB", null); fail("Did not fail fast"); } catch (InsufficientOperationalNodesException e) { } }
@Test public void testGetWithBinaryData() throws Exception { Store<ByteArray, byte[], byte[]> store = getStore(); byte[] allPossibleBytes = getAllPossibleBytes(); ByteArray key = new ByteArray(allPossibleBytes); VectorClock vc = getClock(0, 0); Versioned<byte[]> versioned = new Versioned<byte[]>(allPossibleBytes, vc); store.put(key, versioned, null); List<Versioned<byte[]>> found = store.get(key, null); assertEquals("Should only be one version stored.", 1, found.size()); System.out.println("individual bytes"); System.out.println("input"); printBytes(versioned.getValue()); System.out.println("found"); printBytes(found.get(0).getValue()); assertTrue("Values not equal!", valuesEqual(versioned.getValue(), found.get(0).getValue())); }
private Versioned<String> getInnerValue(String key) throws VoldemortException { List<Versioned<String>> values = innerStore.get(key); if (values.size() > 1) throw new VoldemortException( "Inconsistent metadata found: expected 1 version but found " + values.size() + " for key:" + key); if (values.size() > 0) return values.get(0); throw new VoldemortException("No metadata found for required key:" + key); }