use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class Http2Test method shouldUseHTTP1.
@Test
public void shouldUseHTTP1() {
restServer = RestServerHelper.defaultRestServer().start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort()).protocol(HTTP_11);
client = RestClient.forConfiguration(builder.build());
CompletionStage<RestResponse> response = client.cacheManager("default").info();
ResponseAssertion.assertThat(response).isOk();
RestEntity value = RestEntity.create(MediaType.APPLICATION_OCTET_STREAM, "test".getBytes(CharsetUtil.UTF_8));
response = client.cache("defaultcache").put("test", value);
Assertions.assertThat(join(response).getStatus()).isEqualTo(204);
Assertions.assertThat(restServer.getCacheManager().getCache().size()).isEqualTo(1);
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class EndpointInteroperabilityTest method setup.
@BeforeClass
protected void setup() throws Exception {
cacheManager = TestCacheManagerFactory.createServerModeCacheManager();
cacheManager.defineConfiguration(DEFAULT_CACHE_NAME, getDefaultCacheConfiguration().build());
cacheManager.defineConfiguration(MARSHALLED_CACHE_NAME, getMarshalledCacheConfiguration().build());
cacheManager.defineConfiguration(STRING_CACHE_NAME, getStringsCacheConfiguration().build());
RestServerConfigurationBuilder builder = new RestServerConfigurationBuilder();
builder.port(findFreePort());
restServer = new RestServer();
restServer.setServerManagement(new DummyServerManagement(), true);
restServer.start(builder.build(), cacheManager);
RestClientConfigurationBuilder clientBuilder = new RestClientConfigurationBuilder();
RestClientConfiguration configuration = clientBuilder.addServer().host(restServer.getHost()).port(restServer.getPort()).build();
restClient = RestClient.forConfiguration(configuration);
HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder();
serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler());
hotRodServer = startHotRodServer(cacheManager, serverBuilder);
defaultRemoteCache = createRemoteCacheManager(IdentityMarshaller.INSTANCE).getCache(DEFAULT_CACHE_NAME);
defaultMarshalledRemoteCache = createRemoteCacheManager(null).getCache(MARSHALLED_CACHE_NAME);
stringRemoteCache = createRemoteCacheManager(new UTF8StringMarshaller()).getCache(STRING_CACHE_NAME);
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class EndpointsCacheFactory method createRestCache.
private void createRestCache() {
RestServer restServer = startProtocolServer(findFreePort(), p -> {
RestServerConfigurationBuilder builder = new RestServerConfigurationBuilder();
builder.port(p);
rest = new RestServer();
rest.setServerManagement(new DummyServerManagement(), true);
rest.start(builder.build(), cacheManager);
return rest;
});
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort());
restClient = RestClient.forConfiguration(builder.build());
restCacheClient = restClient.cache(cacheName);
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder 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();
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class BaseJsonTest method setup.
@BeforeClass
protected void setup() throws Exception {
cacheManager = TestCacheManagerFactory.createServerModeCacheManager(EndpointITSCI.INSTANCE, new ConfigurationBuilder());
cacheManager.getClassWhiteList().addRegexps(".*");
cacheManager.defineConfiguration(CACHE_NAME, getIndexCacheConfiguration().build());
RestServerConfigurationBuilder builder = new RestServerConfigurationBuilder();
int restPort = findFreePort();
builder.port(restPort);
restServer = new RestServer();
restServer.setServerManagement(new DummyServerManagement(), true);
restServer.start(builder.build(), cacheManager);
restClient = RestClient.forConfiguration(new RestClientConfigurationBuilder().addServer().host(restServer.getHost()).port(restServer.getPort()).build());
restCacheClient = restClient.cache(CACHE_NAME);
hotRodServer = startHotRodServer(cacheManager);
remoteCacheManager = createRemoteCacheManager();
remoteCache = remoteCacheManager.getCache(CACHE_NAME);
}
Aggregations