Search in sources :

Example 1 with RespServerConfigurationBuilder

use of org.infinispan.server.resp.configuration.RespServerConfigurationBuilder in project infinispan by infinispan.

the class RespServerTest method testNoDefaultConfigurationClustered.

public void testNoDefaultConfigurationClustered() {
    GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
    Stoppable.useCacheManager(new DefaultCacheManager(global.build()), cm -> Stoppable.useServer(new RespServer(), ms -> {
        ms.start(new RespServerConfigurationBuilder().build(), cm);
        assertEquals(CacheMode.REPL_SYNC, ms.getCache().getCacheConfiguration().clustering().cacheMode());
    }));
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Test(org.testng.annotations.Test) AssertJUnit.fail(org.testng.AssertJUnit.fail) CacheMode(org.infinispan.configuration.cache.CacheMode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) Stoppable(org.infinispan.server.core.test.Stoppable) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) RespServerConfiguration(org.infinispan.server.resp.configuration.RespServerConfiguration) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder)

Example 2 with RespServerConfigurationBuilder

use of org.infinispan.server.resp.configuration.RespServerConfigurationBuilder in project infinispan by infinispan.

the class RespServerConfigurationParser method parseResp.

private void parseResp(ConfigurationReader reader, ServerConfigurationBuilder serverBuilder) {
    boolean dedicatedSocketBinding = false;
    String securityRealm = null;
    EndpointConfigurationBuilder endpoint = serverBuilder.endpoints().current();
    RespServerConfigurationBuilder builder = endpoint.addConnector(RespServerConfigurationBuilder.class);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        ParseUtils.requireNoNamespaceAttribute(reader, i);
        String value = replaceProperties(reader.getAttributeValue(i));
        Attribute attribute = Attribute.forName(reader.getAttributeName(i));
        switch(attribute) {
            case CACHE:
                {
                    builder.defaultCacheName(value);
                    break;
                }
            case NAME:
                {
                    builder.name(value);
                    break;
                }
            case SOCKET_BINDING:
                {
                    builder.socketBinding(value);
                    builder.startTransport(true);
                    dedicatedSocketBinding = true;
                    break;
                }
            case SECURITY_REALM:
                {
                    securityRealm = value;
                }
            default:
                {
                    ServerConfigurationParser.parseCommonConnectorAttributes(reader, i, serverBuilder, builder);
                }
        }
    }
    if (!dedicatedSocketBinding) {
        builder.socketBinding(endpoint.singlePort().socketBinding()).startTransport(false);
    }
    while (reader.inTag()) {
        Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case AUTHENTICATION:
                {
                    parseAuthentication(reader, serverBuilder, builder.authentication().enable(), securityRealm);
                    break;
                }
            case ENCRYPTION:
                {
                    if (!dedicatedSocketBinding) {
                        throw Server.log.cannotConfigureProtocolEncryptionUnderSinglePort();
                    }
                    parseEncryption(reader, serverBuilder, builder.encryption(), securityRealm);
                    break;
                }
            default:
                {
                    ServerConfigurationParser.parseCommonConnectorElements(reader, builder);
                }
        }
    }
}
Also used : RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) EndpointConfigurationBuilder(org.infinispan.server.configuration.endpoint.EndpointConfigurationBuilder)

Example 3 with RespServerConfigurationBuilder

use of org.infinispan.server.resp.configuration.RespServerConfigurationBuilder in project infinispan by infinispan.

the class RespServerTest method testValidateInvalidExpiration.

@Test(expectedExceptions = CacheConfigurationException.class)
public void testValidateInvalidExpiration() {
    ConfigurationBuilder config = new ConfigurationBuilder();
    config.expiration().lifespan(10);
    Stoppable.useCacheManager(TestCacheManagerFactory.createCacheManager(config), cm -> Stoppable.useServer(new RespServer(), ms -> {
        ms.start(new RespServerConfigurationBuilder().defaultCacheName(cm.getCacheManagerConfiguration().defaultCacheName().get()).build(), cm);
        fail("Server should not start when expiration is enabled");
    }));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Test(org.testng.annotations.Test) AssertJUnit.fail(org.testng.AssertJUnit.fail) CacheMode(org.infinispan.configuration.cache.CacheMode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) Stoppable(org.infinispan.server.core.test.Stoppable) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) RespServerConfiguration(org.infinispan.server.resp.configuration.RespServerConfiguration) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) Test(org.testng.annotations.Test) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest)

Example 4 with RespServerConfigurationBuilder

use of org.infinispan.server.resp.configuration.RespServerConfigurationBuilder in project infinispan by infinispan.

the class RespServerTest method testNoDefaultConfigurationLocal.

public void testNoDefaultConfigurationLocal() {
    GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
    Stoppable.useCacheManager(new DefaultCacheManager(global.build()), cm -> Stoppable.useServer(new RespServer(), ms -> {
        ms.start(new RespServerConfigurationBuilder().build(), cm);
        assertEquals(CacheMode.LOCAL, ms.getCache().getCacheConfiguration().clustering().cacheMode());
    }));
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Test(org.testng.annotations.Test) AssertJUnit.fail(org.testng.AssertJUnit.fail) CacheMode(org.infinispan.configuration.cache.CacheMode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) Stoppable(org.infinispan.server.core.test.Stoppable) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) RespServerConfiguration(org.infinispan.server.resp.configuration.RespServerConfiguration) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder)

Example 5 with RespServerConfigurationBuilder

use of org.infinispan.server.resp.configuration.RespServerConfigurationBuilder in project infinispan by infinispan.

the class RespTestingUtil method startServer.

public static RespServer startServer(EmbeddedCacheManager cacheManager, int port) {
    RespServer server = new RespServer();
    String serverName = TestResourceTracker.getCurrentTestShortName();
    server.start(new RespServerConfigurationBuilder().name(serverName).host(host).port(port).build(), cacheManager);
    return server;
}
Also used : RespServerConfigurationBuilder(org.infinispan.server.resp.configuration.RespServerConfigurationBuilder) RespServer(org.infinispan.server.resp.RespServer)

Aggregations

RespServerConfigurationBuilder (org.infinispan.server.resp.configuration.RespServerConfigurationBuilder)7 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)3 CacheMode (org.infinispan.configuration.cache.CacheMode)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)3 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)3 Stoppable (org.infinispan.server.core.test.Stoppable)3 RespServerConfiguration (org.infinispan.server.resp.configuration.RespServerConfiguration)3 AbstractInfinispanTest (org.infinispan.test.AbstractInfinispanTest)3 TestCacheManagerFactory (org.infinispan.test.fwk.TestCacheManagerFactory)3 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)3 AssertJUnit.fail (org.testng.AssertJUnit.fail)3 Test (org.testng.annotations.Test)3 RespServer (org.infinispan.server.resp.RespServer)2 ArrayList (java.util.ArrayList)1 RestServerConfigurationBuilder (org.infinispan.rest.configuration.RestServerConfigurationBuilder)1 EndpointConfigurationBuilder (org.infinispan.server.configuration.endpoint.EndpointConfigurationBuilder)1 RealmConfiguration (org.infinispan.server.configuration.security.RealmConfiguration)1 ProtocolServerConfiguration (org.infinispan.server.core.configuration.ProtocolServerConfiguration)1 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)1