use of org.infinispan.rest.helper.RestServerHelper in project infinispan by infinispan.
the class BaseRestSearchTest method createCacheManagers.
@Override
protected void createCacheManagers() throws Exception {
// global config
GlobalConfigurationBuilder globalCfg = GlobalConfigurationBuilder.defaultClusteredBuilder();
globalCfg.serialization().addContextInitializer(RestTestSCI.INSTANCE);
// test cache config
ConfigurationBuilder builder = getConfigBuilder();
builder.statistics().enabled(true);
// create a 'default' config which is not indexed
ConfigurationBuilder defaultBuilder = new ConfigurationBuilder();
// start cache managers + default cache
createClusteredCaches(getNumNodes(), globalCfg, defaultBuilder, isServerMode(), "default");
// start rest sever for each cache manager
cacheManagers.forEach(cm -> {
RestServerHelper restServer = new RestServerHelper(cm);
restServer.start(TestResourceTracker.getCurrentTestShortName());
restServers.add(restServer);
RestClientConfigurationBuilder clientConfigurationBuilder = new RestClientConfigurationBuilder();
clientConfigurationBuilder.addServer().host(restServer.getHost()).port(restServer.getPort());
clients.add(RestClient.forConfiguration(clientConfigurationBuilder.build()));
});
client = clients.get(0);
cacheClient = client.cache(CACHE_NAME);
// register protobuf schema
String protoFileContents = Util.getResourceAsString(PROTO_FILE_NAME, getClass().getClassLoader());
registerProtobuf(protoFileContents);
// start indexed test cache that depends on the protobuf schema
cacheManagers.forEach(cm -> {
cm.defineConfiguration(CACHE_NAME, builder.build());
cm.getCache(CACHE_NAME);
});
}
use of org.infinispan.rest.helper.RestServerHelper in project infinispan by infinispan.
the class MultiNodeRestTest method createCacheManagers.
@Override
protected void createCacheManagers() throws Throwable {
createClusteredCaches(getMembers(), GlobalConfigurationBuilder.defaultClusteredBuilder(), new ConfigurationBuilder(), true);
cacheManagers.forEach(cm -> {
RestServerHelper restServer = new RestServerHelper(cm);
restServer.start(TestResourceTracker.getCurrentTestShortName());
restServers.add(restServer);
});
RestClientConfigurationBuilder clientConfigurationBuilder = new RestClientConfigurationBuilder();
restServers.forEach(s -> clientConfigurationBuilder.addServer().host(s.getHost()).port(s.getPort()));
this.client = RestClient.forConfiguration(clientConfigurationBuilder.build());
// Register the proto schema before starting the caches
String protoFileContents = Util.getResourceAsString(getProtoFile(), getClass().getClassLoader());
registerProtobuf(protoFileContents);
cacheManagers.forEach(cm -> {
getCacheConfigs().forEach((name, configBuilder) -> cm.createCache(name, configBuilder.build()));
});
cacheClients = getCacheConfigs().keySet().stream().collect(Collectors.toMap(Function.identity(), client::cache));
}
Aggregations