use of voldemort.client.ClientConfig in project voldemort by voldemort.
the class DynamicTimeoutStoreClientTest method setUp.
/**
* Setup a one node Voldemort cluster with a 'slow' store
* (SlowStorageEngine) with a delay of 500 ms for get and put.
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
int numServers = 1;
servers = new VoldemortServer[numServers];
int[][] partitionMap = { { 0, 2, 4, 6, 1, 3, 5, 7 } };
Properties props = new Properties();
props.setProperty("storage.configs", "voldemort.store.bdb.BdbStorageConfiguration,voldemort.store.slow.SlowStorageConfiguration");
props.setProperty("testing.slow.queueing.get.ms", SLOW_STORE_DELAY);
props.setProperty("testing.slow.queueing.put.ms", SLOW_STORE_DELAY);
cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, // useNio
true, null, STORES_XML, props);
socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
String bootstrapUrl = socketUrl;
ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootstrapUrl).setEnableCompressionLayer(false).setEnableSerializationLayer(false).enableDefaultClient(true).setEnableLazy(false);
String storesXml = FileUtils.readFileToString(new File(STORES_XML), "UTF-8");
ClusterMapper mapper = new ClusterMapper();
this.dynamicTimeoutClient = new DynamicTimeoutStoreClient<ByteArray, byte[]>(STORE_NAME, new SocketStoreClientFactory(clientConfig), 1, storesXml, mapper.writeCluster(cluster));
}
use of voldemort.client.ClientConfig in project voldemort by voldemort.
the class AbstractZonedRebalanceTest method testProxyGetDuringRebalancing.
@Test(timeout = 600000)
public void testProxyGetDuringRebalancing() throws Exception {
logger.info("Starting testProxyGetDuringRebalancing");
try {
Cluster currentCluster = ServerTestUtils.getLocalZonedCluster(4, 2, new int[] { 0, 0, 1, 1 }, new int[][] { { 0, 2, 4 }, { 6 }, { 1, 3, 5 }, { 7 } });
Cluster tmpfinalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 3, Lists.newArrayList(2));
final Cluster finalCluster = UpdateClusterUtils.createUpdatedCluster(tmpfinalCluster, 1, Lists.newArrayList(3));
final List<Integer> serverList = Arrays.asList(0, 1, 2, 3);
Map<String, String> configProps = new HashMap<String, String>();
configProps.put("admin.max.threads", "5");
final Cluster updatedCurrentCluster = startServers(currentCluster, storeDefFileWithReplication, serverList, configProps);
ExecutorService executors = Executors.newFixedThreadPool(2);
final AtomicBoolean rebalancingComplete = new AtomicBoolean(false);
final List<Exception> exceptions = Collections.synchronizedList(new ArrayList<Exception>());
String bootstrapUrl = getBootstrapUrl(updatedCurrentCluster, 0);
int maxParallel = 2;
final ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl, maxParallel, finalCluster);
try {
populateData(currentCluster, rwStoreDefWithReplication);
final SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(getBootstrapUrl(currentCluster, 0)).setEnableLazy(false).setSocketTimeout(120, TimeUnit.SECONDS));
final StoreClient<String, String> storeClientRW = new DefaultStoreClient<String, String>(rwStoreDefWithReplication.getName(), null, factory, 3);
final CountDownLatch latch = new CountDownLatch(2);
// start get operation.
executors.execute(new Runnable() {
@Override
public void run() {
try {
List<String> keys = new ArrayList<String>(testEntries.keySet());
while (!rebalancingComplete.get()) {
// should always able to get values.
int index = (int) (Math.random() * keys.size());
// should get a valid value
try {
Versioned<String> value = storeClientRW.get(keys.get(index));
assertNotSame("StoreClient get() should not return null.", null, value);
assertEquals("Value returned should be good", new Versioned<String>(testEntries.get(keys.get(index))), value);
} catch (Exception e) {
logger.error("Exception in proxy get thread", e);
e.printStackTrace();
exceptions.add(e);
}
}
} catch (Exception e) {
logger.error("Exception in proxy get thread", e);
exceptions.add(e);
} finally {
factory.close();
latch.countDown();
}
}
});
executors.execute(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(500);
rebalanceAndCheck(rebalanceKit.plan, rebalanceKit.controller, Arrays.asList(0, 1, 2, 3));
Thread.sleep(500);
rebalancingComplete.set(true);
checkConsistentMetadata(finalCluster, serverList);
} catch (Exception e) {
exceptions.add(e);
} finally {
// stop servers
try {
stopServer(serverList);
} catch (Exception e) {
throw new RuntimeException(e);
}
latch.countDown();
}
}
});
latch.await();
executors.shutdown();
executors.awaitTermination(300, TimeUnit.SECONDS);
// check No Exception
if (exceptions.size() > 0) {
for (Exception e : exceptions) {
e.printStackTrace();
}
fail("Should not see any exceptions.");
}
} finally {
// stop servers
stopServer(serverList);
}
} catch (AssertionError ae) {
logger.error("Assertion broken in testProxyGetDuringRebalancing ", ae);
throw ae;
}
}
use of voldemort.client.ClientConfig in project voldemort by voldemort.
the class CoordinatorProxyService method getFatClientFactory.
/**
* Create a @SocketStoreClientFactory from the given configPops
*
* @param bootstrapURLs
* @param configProps
* @return
*/
private SocketStoreClientFactory getFatClientFactory(String[] bootstrapURLs, Properties configProps) {
ClientConfig fatClientConfig = new ClientConfig(configProps);
logger.info("Using config: " + fatClientConfig);
fatClientConfig.setBootstrapUrls(bootstrapURLs).setEnableCompressionLayer(false).setEnableSerializationLayer(false).enableDefaultClient(true).setEnableLazy(false);
return new SocketStoreClientFactory(fatClientConfig);
}
use of voldemort.client.ClientConfig in project voldemort by voldemort.
the class CoordinatorProxyService method initialize.
@Override
protected void initialize() {
// Initialize the Voldemort Metadata
ClientConfig clientConfig = new ClientConfig();
clientConfig.setBootstrapUrls(this.coordinatorConfig.getBootstrapURLs());
storeClientFactory = new SocketStoreClientFactory(clientConfig);
try {
initializeAllFatClients();
// Setup the Async Metadata checker
SystemStoreRepository sysRepository = new SystemStoreRepository(clientConfig);
String clusterXml = storeClientFactory.bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
sysRepository.createSystemStores(clientConfig, clusterXml, storeClientFactory.getFailureDetector());
// Create a callback for re-bootstrapping the client
Callable<Void> rebootstrapCallback = new Callable<Void>() {
@Override
public Void call() throws Exception {
initializeAllFatClients();
return null;
}
};
asyncMetadataManager = new AsyncMetadataVersionManager(sysRepository, rebootstrapCallback, null);
schedulerService = new SchedulerService(1, SystemTime.INSTANCE, true);
schedulerService.schedule(asyncMetadataManager.getClass().getName(), asyncMetadataManager, new Date(), this.coordinatorConfig.getMetadataCheckIntervalInMs());
} catch (BootstrapFailureException be) {
/*
* While testing, the cluster may not be up, but we may still need
* to verify if the service deploys. Hence, catch a
* BootstrapFailureException if any, but continue to register the
* Netty service (and listener).
*
* TODO: Modify the coordinator service to be more lazy. If it
* cannot initialize the fat clients during initialization, do this
* when we get an actual request.
*/
}
}
use of voldemort.client.ClientConfig in project voldemort by voldemort.
the class AdminToolUtils method getAdminClient.
/**
* Utility function that constructs AdminClient.
*
* @param url URL pointing to the bootstrap node
* @return Newly constructed AdminClient
*/
public static AdminClient getAdminClient(String url) {
ClientConfig config = new ClientConfig().setBootstrapUrls(url).setConnectionTimeout(5, TimeUnit.SECONDS);
AdminClientConfig adminConfig = new AdminClientConfig().setAdminSocketTimeoutSec(5);
return new AdminClient(adminConfig, config);
}
Aggregations