use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.
the class ClientRequestExecutorPoolTest method testMachinUpProcessDownThrows.
@Test
public void testMachinUpProcessDownThrows() throws Exception {
int processDownPort = ServerTestUtils.findFreePort();
SocketDestination processDownDest = new SocketDestination("localhost", processDownPort, RequestFormatType.VOLDEMORT_V1);
testConnectionFailure(pool, processDownDest, ConnectException.class);
}
use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.
the class SimpleSocketPoolTest method testSocketPoolLimitSomeTimeout.
@Test
public void testSocketPoolLimitSomeTimeout() throws Exception {
// start a dummy server
AbstractSocketService server = ServerTestUtils.getSocketService(useNio, new ClientRequestHandlerFactory(null), 7666, 50, 50, 1000);
server.start();
final ResourcePoolConfig config = new ResourcePoolConfig().setTimeout(50, TimeUnit.MILLISECONDS).setMaxPoolSize(20);
ResourceFactory<SocketDestination, SocketAndStreams> factory = ResourcePoolTestUtils.getSocketPoolFactory();
final AbstractSocketPoolTest<SocketDestination, SocketAndStreams> test = new AbstractSocketPoolTest<SocketDestination, SocketAndStreams>() {
@Override
protected void doSomethingWithResource(SocketDestination key, SocketAndStreams resource) throws Exception {
Thread.sleep(100);
int random = (int) (Math.random() * 10);
if (random >= 5)
resource.getSocket().close();
}
@Override
protected SocketDestination getRequestKey() throws Exception {
return new SocketDestination("localhost", 7666, RequestFormatType.VOLDEMORT_V1);
}
};
// borrow timeout >> doSomething() no timeout expected
TestStats testStats = test.startTest(factory, config, 50, 200);
assertEquals("We should see some timeoutRequests", true, testStats.timeoutRequests > 0);
server.stop();
}
use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.
the class BaseStreamingClient method cleanupSessions.
/**
* Helper method to Close all open socket connections and checkin back to
* the pool
*
* @param storeNamesToCleanUp List of stores to be cleanedup from the current
* streaming session
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private void cleanupSessions(List<String> storeNamesToCleanUp) {
logger.info("Performing cleanup");
for (String store : storeNamesToCleanUp) {
for (Node node : nodesToStream) {
try {
SocketAndStreams sands = nodeIdStoreToSocketAndStreams.get(new Pair(store, node.getId()));
close(sands.getSocket());
SocketDestination destination = nodeIdStoreToSocketRequest.get(new Pair(store, node.getId()));
streamingSocketPool.checkin(destination, sands);
} catch (Exception ioE) {
logger.error(ioE);
}
}
}
cleanedUp = true;
}
use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.
the class ClientSocketStatsTest method setUp.
@Before
public void setUp() throws Exception {
this.port = ServerTestUtils.findFreePort();
this.dest1 = new SocketDestination("localhost", port, RequestFormatType.VOLDEMORT_V1);
this.dest2 = new SocketDestination("localhost", port + 1, RequestFormatType.VOLDEMORT_V1);
this.masterStats = new ClientSocketStats("");
pool = null;
}
use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.
the class SocketPoolTest method testVariousProtocols.
@Test
public void testVariousProtocols() throws Exception {
for (RequestFormatType type : RequestFormatType.values()) {
SocketDestination dest = new SocketDestination("localhost", port, type);
SocketAndStreams sas = pool.checkout(dest);
assertEquals(type, sas.getRequestFormatType());
}
}
Aggregations