Search in sources :

Example 6 with RestServerHelper

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);
    });
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestServerHelper(org.infinispan.rest.helper.RestServerHelper)

Example 7 with RestServerHelper

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));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestServerHelper(org.infinispan.rest.helper.RestServerHelper)

Aggregations

RestServerHelper (org.infinispan.rest.helper.RestServerHelper)7 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)5 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)4 RestClient (org.infinispan.client.rest.RestClient)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 Test (org.testng.annotations.Test)2 Level (org.apache.logging.log4j.Level)1 PatternLayout (org.apache.logging.log4j.core.layout.PatternLayout)1 RestCacheClient (org.infinispan.client.rest.RestCacheClient)1 RestResponse (org.infinispan.client.rest.RestResponse)1 RestClientConfiguration (org.infinispan.client.rest.configuration.RestClientConfiguration)1 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1 TestResourceTracker (org.infinispan.commons.test.TestResourceTracker)1 StringLogAppender (org.infinispan.commons.test.skip.StringLogAppender)1 PrivateGlobalConfigurationBuilder (org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 BasicAuthenticator (org.infinispan.rest.authentication.impl.BasicAuthenticator)1 RestServerConfiguration (org.infinispan.rest.configuration.RestServerConfiguration)1 RestServerConfigurationBuilder (org.infinispan.rest.configuration.RestServerConfigurationBuilder)1