storeFactory.close();
socketService.stop();
/** * Do HTTP tests ** */
repository.addLocalStore(new InMemoryStorageEngine<ByteArray, byte[], byte[]>(storeName));
HttpService httpService = new HttpService(null,
null,
repository,
RequestFormatType.VOLDEMORT_V0,
numThreads,
8080);
httpService.start();
ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
10000,
TimeUnit.MILLISECONDS);
DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);
HttpParams clientParams = httpClient.getParams();
httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);
HttpProtocolParams.setUserAgent(clientParams, "test-agent");
HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);
HttpConnectionParams.setConnectionTimeout(clientParams, 10000);
connectionManager.setMaxTotal(numThreads);
connectionManager.setDefaultMaxPerRoute(numThreads);
HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);
final HttpStore httpStore = new HttpStore("test",
"localhost",
8080,
httpClient,
new RequestFormatFactory().getRequestFormat(RequestFormatType.VOLDEMORT_V0),
false);
Thread.sleep(400);
PerformanceTest httpWriteTest = new PerformanceTest() {
@Override
public void doOperation(int i) {
byte[] key = String.valueOf(i).getBytes();
httpStore.put(new ByteArray(key), new Versioned<byte[]>(key), null);
}
};
System.out.println("###########################################");
System.out.println("Performing HTTP write test.");
httpWriteTest.run(numRequests, numThreads);
httpWriteTest.printStats();
System.out.println();
PerformanceTest httpReadTest = new PerformanceTest() {
@Override
public void doOperation(int i) {
httpStore.get(new ByteArray(String.valueOf(i).getBytes()), null);
}
};
System.out.println("Performing HTTP read test.");
httpReadTest.run(numRequests, numThreads);
httpReadTest.printStats();
httpService.stop();
VoldemortIOUtils.closeQuietly(httpClient);
}