use of voldemort.utils.ByteArray in project voldemort by voldemort.
the class AbstractRequestFormatTest method testPutRequests.
@Test
public void testPutRequests() throws Exception {
testPutRequest(new ByteArray(), new byte[0], null, new VectorClock(), null, true);
testPutRequest(TestUtils.toByteArray("hello"), "world".getBytes(), null, new VectorClock(), null, false);
testPutRequest(TestUtils.toByteArray("hello"), "world".getBytes(), null, new VectorClock(), ObsoleteVersionException.class, true);
}
use of voldemort.utils.ByteArray in project voldemort by voldemort.
the class QueryKeyResultTest method testStandardCtor.
@Test
public void testStandardCtor() {
ByteArray key = new ByteArray("key".getBytes());
List<Versioned<byte[]>> values = new ArrayList<Versioned<byte[]>>(0);
Versioned<byte[]> value1 = TestUtils.getVersioned(TestUtils.randomBytes(10), 1, 1, 1);
values.add(value1);
Versioned<byte[]> value2 = TestUtils.getVersioned(TestUtils.randomBytes(10), 1, 1, 2);
values.add(value2);
QueryKeyResult queryKeyResult = new QueryKeyResult(key, values);
assertTrue(queryKeyResult.hasValues());
assertEquals(values, queryKeyResult.getValues());
assertFalse(queryKeyResult.hasException());
assertEquals(null, queryKeyResult.getException());
}
use of voldemort.utils.ByteArray in project voldemort by voldemort.
the class StreamingClientTest method testStreaming.
@Test
public void testStreaming() {
Props property = new Props();
property.put("streaming.platform.bootstrapURL", SERVER_LOCAL_URL + serverPorts[0]);
StreamingClientConfig config = new StreamingClientConfig(property);
BaseStreamingClient streamer = new BaseStreamingClient(config);
streamer.initStreamingSession(TEST_STORE_NAME, new Callable<Object>() {
@Override
public Object call() throws Exception {
return null;
}
}, new Callable<Object>() {
@Override
public Object call() throws Exception {
return null;
}
}, true);
for (int i = 0; i < NUM_KEYS_1; i++) {
String key = i + "";
String value = key;
Versioned<byte[]> outputValue = Versioned.value(value.getBytes());
// adminClient.streamingPut(new ByteArray(key.getBytes()),
// outputValue);
streamer.streamingPut(new ByteArray(key.getBytes()), outputValue);
}
streamer.commitToVoldemort();
streamer.closeStreamingSession();
assertEquals(verifyKeysExist(nodeIdOnWhichToVerifyKey), true);
}
use of voldemort.utils.ByteArray in project voldemort by voldemort.
the class AbstractZonedRebalanceTest method populateData.
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();
}
}
use of voldemort.utils.ByteArray in project voldemort by voldemort.
the class OfflineStateTest method testSlopStreaming.
private boolean testSlopStreaming() {
final List<Versioned<Slop>> entrySet = ServerTestUtils.createRandomSlops(0, 10000, testStoreName, "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
Iterator<Versioned<Slop>> slopIterator = entrySet.iterator();
try {
getAdminClient().streamingOps.updateSlopEntries(0, slopIterator);
} catch (VoldemortException e) {
return false;
}
// check updated values
Iterator<Versioned<Slop>> entrysetItr = entrySet.iterator();
while (entrysetItr.hasNext()) {
Versioned<Slop> versioned = entrysetItr.next();
Slop nextSlop = versioned.getValue();
Store<ByteArray, byte[], byte[]> store = getStore(0, nextSlop.getStoreName());
if (nextSlop.getOperation().equals(Slop.Operation.PUT)) {
return store.get(nextSlop.getKey(), null).size() != 0;
} else if (nextSlop.getOperation().equals(Slop.Operation.DELETE)) {
return store.get(nextSlop.getKey(), null).size() == 0;
}
}
return false;
}
Aggregations