use of voldemort.StaticStoreClientFactory in project voldemort by voldemort.
the class Benchmark method initializeStore.
@SuppressWarnings("unchecked")
public void initializeStore(Props benchmarkProps) throws Exception {
this.numThreads = benchmarkProps.getInt(THREADS, MAX_WORKERS);
this.numConnectionsPerNode = benchmarkProps.getInt(NUM_CONNECTIONS_PER_NODE, MAX_CONNECTIONS_PER_NODE);
this.numIterations = benchmarkProps.getInt(ITERATIONS, 1);
this.statusIntervalSec = benchmarkProps.getInt(INTERVAL, 0);
this.verbose = benchmarkProps.getBoolean(VERBOSE, false);
this.verifyRead = benchmarkProps.getBoolean(VERIFY, false);
this.ignoreNulls = benchmarkProps.getBoolean(IGNORE_NULLS, false);
int clientZoneId = benchmarkProps.getInt(CLIENT_ZONE_ID, -1);
if (benchmarkProps.containsKey(URL)) {
// Remote benchmark
if (!benchmarkProps.containsKey(STORE_NAME)) {
throw new VoldemortException("Missing storename");
}
String socketUrl = benchmarkProps.getString(URL);
String storeName = benchmarkProps.getString(STORE_NAME);
ClientConfig clientConfig = new ClientConfig().setMaxThreads(numThreads).setMaxTotalConnections(numThreads).setMaxConnectionsPerNode(numConnectionsPerNode).setRoutingTimeout(1500, TimeUnit.MILLISECONDS).setSocketTimeout(1500, TimeUnit.MILLISECONDS).setConnectionTimeout(500, TimeUnit.MILLISECONDS).setRequestFormatType(RequestFormatType.VOLDEMORT_V3).setBootstrapUrls(socketUrl);
if (clientZoneId >= 0) {
clientConfig.setClientZoneId(clientZoneId);
}
SocketStoreClientFactory socketFactory = new SocketStoreClientFactory(clientConfig);
this.storeClient = socketFactory.getStoreClient(storeName);
StoreDefinition storeDef = getStoreDefinition(socketFactory, storeName);
this.keyType = findKeyType(storeDef);
benchmarkProps.put(Benchmark.KEY_TYPE, this.keyType);
this.factory = socketFactory;
} else {
// Local benchmark
localMode = true;
String storageEngineClass = benchmarkProps.getString(STORAGE_CONFIGURATION_CLASS);
this.keyType = benchmarkProps.getString(KEY_TYPE, STRING_KEY_TYPE);
Serializer serializer = findKeyType(this.keyType);
Store<Object, Object, Object> store = null;
VoldemortConfig voldemortConfig;
if (benchmarkProps.containsKey(LOCAL_SERVER_PROPERTIES)) {
File homeDir = TestUtils.createTempDir();
File configDir = new File(homeDir, "config");
configDir.mkdir();
FileUtils.copyFile(new File(benchmarkProps.get(LOCAL_SERVER_PROPERTIES)), new File(configDir, "server.properties"));
voldemortConfig = VoldemortConfig.loadFromVoldemortHome(homeDir.getAbsolutePath());
} else {
voldemortConfig = ServerTestUtils.getVoldemortConfig();
}
StorageConfiguration conf = (StorageConfiguration) ReflectUtils.callConstructor(ReflectUtils.loadClass(storageEngineClass), new Object[] { voldemortConfig });
StorageEngine<ByteArray, byte[], byte[]> engine = conf.getStore(TestUtils.makeStoreDefinition(DUMMY_DB), TestUtils.makeSingleNodeRoutingStrategy());
if (conf.getType().compareTo(ViewStorageConfiguration.TYPE_NAME) == 0) {
engine = new ViewStorageEngine(STORE_NAME, engine, new StringSerializer(), new StringSerializer(), serializer, new StringSerializer(), null, BenchmarkViews.loadTransformation(benchmarkProps.getString(VIEW_CLASS).trim()));
}
store = SerializingStore.wrap(engine, serializer, new StringSerializer(), new IdentitySerializer());
this.factory = new StaticStoreClientFactory(store);
this.storeClient = factory.getStoreClient(store.getName());
}
this.storeInitialized = true;
}
Aggregations