use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class VersionedPutPruneJobTest method setup.
@Before
public void setup() throws Exception {
socketStoreMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
final int numServers = 4;
servers = new VoldemortServer[numServers];
int[][] currentPartitionMap = { { 0, 4 }, { 2, 6 }, { 1, 5 }, { 3, 7 } };
cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, currentPartitionMap, socketStoreFactory, true, null, "test/common/voldemort/config/single-store-322.xml", new Properties());
StringReader reader = new StringReader(VoldemortTestConstants.getSingleStore322Xml());
StoreDefinition storeDef = new StoreDefinitionsMapper().readStoreList(reader).get(0);
currentRoutingPlan = new BaseStoreRoutingPlan(cluster, storeDef);
String bootStrapUrl = "";
for (VoldemortServer server : servers) {
Node node = server.getIdentityNode();
socketStoreMap.put(node.getId(), ServerTestUtils.getSocketStore(socketStoreFactory, "test", node.getHost(), node.getSocketPort(), RequestFormatType.PROTOCOL_BUFFERS, false, true));
bootStrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
}
testEntries = ServerTestUtils.createRandomKeyValueString(100);
int[][] oldPartitionMap = { { 3, 6 }, { 1, 4 }, { 7, 2 }, { 5, 0 } };
oldRoutingPlan = new BaseStoreRoutingPlan(ServerTestUtils.getLocalCluster(numServers, oldPartitionMap), storeDef);
SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootStrapUrl));
storeClient = factory.getStoreClient("test");
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class ClientRequestExecutorPoolTest method testRememberedExceptionsBeyondTime.
@Test
public void testRememberedExceptionsBeyondTime() throws Exception {
final int CURRENT_CONNECTION_TIMEOUT = 50;
ClientRequestExecutorPool timeoutPool = new ClientRequestExecutorPool(2, maxConnectionsPerNode, CURRENT_CONNECTION_TIMEOUT, CURRENT_CONNECTION_TIMEOUT, IDLE_CONNECTION_TIMEOUT_MS, 32 * 1024, false, true, new String());
ConnectException connectEx = new ConnectException("Connect exception");
UnreachableStoreException unreachableEx = new UnreachableStoreException("test Exception", connectEx);
final int COUNT = 10;
for (int i = 0; i < COUNT; i++) {
timeoutPool.internalGetQueuedPool().reportException(dest1, unreachableEx);
}
Thread.sleep(CURRENT_CONNECTION_TIMEOUT);
// Get all exceptions but 1.
for (int i = 0; i < COUNT - 1; i++) {
try {
timeoutPool.internalGetQueuedPool().checkout(dest1);
fail("should have thrown an exception");
} catch (Exception ex) {
}
}
Thread.sleep(CURRENT_CONNECTION_TIMEOUT + 1);
// should not fail
timeoutPool.checkout(dest1);
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class ClientRequestExecutorPoolTest method testCloseWithOutstandingQueue.
@Test
public void testCloseWithOutstandingQueue() {
final int MAX_CONNECTIONS = 2;
ClientRequestExecutorPool execPool = new ClientRequestExecutorPool(2, MAX_CONNECTIONS, CONNECTION_TIMEOUT_MS, SOCKET_TIMEOUT_MS, IDLE_CONNECTION_TIMEOUT_MS, 32 * 1024, false, true, new String());
// will always wait in the queue.
for (int i = 0; i < MAX_CONNECTIONS; i++) {
execPool.checkout(dest1);
}
for (int j = 0; j < 2; j++) {
GetClientRequest clientRequest = new GetClientRequest("sampleStore", new RequestFormatFactory().getRequestFormat(dest1.getRequestFormatType()), RequestRoutingType.ROUTED, new ByteArray(new byte[] { 1, 2, 3 }), null);
final AtomicInteger cancelledEvents = new AtomicInteger(0);
NonblockingStoreCallback callback = new NonblockingStoreCallback() {
@Override
public void requestComplete(Object result, long requestTime) {
if (result instanceof UnreachableStoreException)
cancelledEvents.incrementAndGet();
else
fail("The request must have failed with UnreachableException" + result);
}
};
int queuedRequestCount = 20;
for (int i = 0; i < queuedRequestCount; i++) {
execPool.submitAsync(dest1, clientRequest, callback, 5000, "get");
}
int outstandingQueue = execPool.internalGetQueuedPool().getRegisteredResourceRequestCount(dest1);
assertEquals("Queued request count should match", queuedRequestCount, outstandingQueue);
// Now reset the queue, the outstanding requests should fail with
// UnreachableStoreException
execPool.close(dest1);
outstandingQueue = execPool.internalGetQueuedPool().getRegisteredResourceRequestCount(dest1);
assertEquals("Queued request should have been cleared", 0, outstandingQueue);
// CancelledEvents should be
assertEquals("All Queuedrequest must have been cancelled.", queuedRequestCount, cancelledEvents.get());
}
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class ZoneCountWriteTest method setup.
@Before
public void setup() throws IOException {
storeDef = storeDefs.get(0);
Integer zoneCountWrite = 1;
// override
storeDef = new StoreDefinition(storeDef.getName(), storeDef.getType(), storeDef.getDescription(), storeDef.getKeySerializer(), storeDef.getValueSerializer(), storeDef.getTransformsSerializer(), storeDef.getRoutingPolicy(), storeDef.getRoutingStrategyType(), storeDef.getReplicationFactor(), storeDef.getPreferredReads(), storeDef.getRequiredReads(), storeDef.getPreferredWrites(), storeDef.getRequiredWrites(), storeDef.getViewTargetStoreName(), storeDef.getValueTransformation(), storeDef.getZoneReplicationFactor(), storeDef.getZoneCountReads(), zoneCountWrite, storeDef.getRetentionDays(), storeDef.getRetentionScanThrottleRate(), storeDef.getRetentionFrequencyDays(), storeDef.getSerializerFactory(), storeDef.getHintedHandoffStrategyType(), storeDef.getHintPrefListSize(), storeDef.getOwners(), storeDef.getMemoryFootprintMB());
storeDefs.set(0, storeDef);
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, storeDefs, new Properties());
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
vservers.put(nodeId, vs);
}
client = socketStoreClientFactory.getRawStore(storeDef.getName(), null);
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class AvroAddStoreTest method setup.
/**
* This test is to partially test the functionality of SetMetadata feature
* of the VoldemortAdminTool
*/
@Before
public void setup() throws IOException {
// setup cluster
cluster = ClusterTestUtils.getZZZCluster();
oldStores = ClusterTestUtils.getZZZStoreDefsInMemory();
bsURL = cluster.getNodes().iterator().next().getSocketUrl().toString();
for (Node node : cluster.getNodes()) {
SocketStoreFactory ssf = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), TestUtils.createTempDir().getAbsolutePath(), cluster, oldStores, new Properties());
VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
vservers.put(node.getId(), vs);
socketStoreFactories.put(node.getId(), ssf);
}
adminClient = new AdminClient(cluster);
}
Aggregations