use of org.infinispan.client.rest.RestURI in project infinispan by infinispan.
the class HttpBenchmark method setup.
@Setup
public void setup() {
RestURI uri = RestURI.create(this.uri);
RestClientConfigurationBuilder builder = uri.toConfigurationBuilder();
client = RestClient.forConfiguration(builder.build());
cache = client.cache(cacheName);
try (RestResponse response = uncheckedAwait(cache.exists())) {
switch(response.getStatus()) {
case RestResponse.OK:
case RestResponse.NO_CONTENT:
break;
case RestResponse.NOT_FOUND:
Util.close(client);
throw new IllegalArgumentException("Could not find cache '" + cacheName + "'");
case RestResponse.UNAUTHORIZED:
Util.close(client);
throw new SecurityException(response.getBody());
default:
Util.close(client);
throw new RuntimeException(response.getBody());
}
}
value = RestEntity.create(MediaType.APPLICATION_OCTET_STREAM, new byte[valueSize]);
keySet = new ArrayList<>(keySetSize);
// We always use the same seed to make things repeatable
Random r = new Random(17);
byte[] keyBytes = new byte[keySize / 2];
for (int i = 0; i < keySetSize; i++) {
r.nextBytes(keyBytes);
String key = Util.toHexString(keyBytes);
keySet.add(key);
cache.put(key, value);
}
nextIndex = new AtomicInteger();
}
Aggregations