@Override public void activateService() throws Exception { configuration.refresh(); RiakHttpEntityStoreConfiguration config = configuration.get(); int maxConnections = config.maxConnections().get() == null ? DEFAULT_MAX_CONNECTIONS : config.maxConnections().get(); int timeoutMillis = config.timeout().get(); List<String> urls = config.urls().get(); if (urls.isEmpty()) { urls.add(DEFAULT_URL); } bucketKey = config.bucket().get() == null ? DEFAULT_BUCKET_KEY : config.bucket().get(); HTTPClusterConfig httpClusterConfig = new HTTPClusterConfig(maxConnections); for (String url : urls) { HTTPClientConfig clientConfig = new HTTPClientConfig.Builder().withTimeout(timeoutMillis).withUrl(url).build(); httpClusterConfig.addClient(clientConfig); } riakClient = RiakFactory.newClient(httpClusterConfig); if (!riakClient.listBuckets().contains(bucketKey)) { riakClient.createBucket(bucketKey).execute(); } }
/* * (non-Javadoc) * * @see com.basho.riak.client.itest.ITestBucket#getClient() */ @Override protected IRiakClient getClient() throws RiakException { return RiakFactory.httpClient(Hosts.RIAK_URL); }