@Override public void accept(RemoteStoreConfigurationBuilder builder) { builder.remoteCacheName(this.remoteCacheName) .socketTimeout(this.socketTimeout) .tcpNoDelay(this.tcpNoDelay) ; for (Supplier<OutboundSocketBinding> bindingDependency : this.bindings) { OutboundSocketBinding binding = bindingDependency.get(); builder.addServer().host(binding.getUnresolvedDestinationAddress()).port(binding.getDestinationPort()); } } }
@Override public void inject(SecurityRealm value) { builder.remoteSecurity().ssl().sslContext(value.getSSLContext()); } };
protected PersistenceConfigurationBuilder createCacheStoreConfig(String cacheName, int port, PersistenceConfigurationBuilder persistence) { persistence.addStore(RemoteStoreConfigurationBuilder.class) .remoteCacheName(cacheName) .hotRodWrapping(true) .addServer() .host("localhost") .port(port); return persistence; }
private void configureRemoteActionTokenCacheStore(ConfigurationBuilder builder, boolean async) { String jdgServer = config.get("remoteStoreHost", "localhost"); Integer jdgPort = config.getInt("remoteStorePort", 11222); builder.persistence() .passivation(false) .addStore(RemoteStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false) .purgeOnStartup(false) .preload(true) .shared(true) .remoteCacheName(InfinispanConnectionProvider.ACTION_TOKEN_CACHE) .rawValues(true) .forceReturnValues(false) .marshaller(KeycloakHotRodMarshallerFactory.class.getName()) .protocolVersion(getHotrodVersion()) .addServer() .host(jdgServer) .port(jdgPort) .async() .enabled(async); }
private CacheDefinitionBuilder addNewCache() { if (configurationBuilder == null) configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC); if (remotePort != null) { RemoteStoreConfigurationBuilder store = configurationBuilder.persistence().addStore(RemoteStoreConfigurationBuilder.class); store.hotRodWrapping(true) .remoteCacheName(name).protocolVersion(protocolVersion).shared(true) .addServer().host("localhost").port(remotePort); if (builder.trustStoreFileName != null) { store.remoteSecurity().ssl().enable().trustStoreFileName(builder.trustStoreFileName).trustStorePassword(builder.trustStorePassword); } if (builder.keyStoreFileName != null) { store.remoteSecurity().ssl().keyStoreFileName(builder.keyStoreFileName).keyStorePassword(builder.keyStorePassword); } } builder.addCache(name, configurationBuilder); return new CacheDefinitionBuilder(builder); } }
.persistence() .addStore(RemoteStoreConfigurationBuilder.class) .remoteCacheName(REMOTE_CACHE) .remoteSecurity(); remoteSecurity .ssl().enable() .keyStoreFileName(cl.getResource("keystore_client.jks").getPath()) .keyStorePassword("secret".toCharArray()) .trustStoreFileName(cl.getResource("ca.jks").getPath()) .trustStorePassword("secret".toCharArray()) .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); remoteSecurity .authentication().enable() .saslMechanism("EXTERNAL"); RemoteStore remoteStore = new RemoteStore(); remoteStore.init(createContext(builder.build()));
@Override protected PersistenceConfigurationBuilder createCacheStoreConfig(PersistenceConfigurationBuilder persistence, boolean preload) { localCacheManager = TestCacheManagerFactory.createCacheManager(hotRodCacheConfiguration()); hrServer = HotRodClientTestingUtil.startHotRodServer(localCacheManager); persistence .addStore(RemoteStoreConfigurationBuilder.class) .remoteCacheName(BasicCacheContainer.DEFAULT_CACHE_NAME) .preload(preload) .addServer() .host("localhost") .port(hrServer.getPort()); return persistence; }
private void parseServer(XMLExtendedStreamReader reader, RemoteServerConfigurationBuilder builder) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { ParseUtils.requireNoNamespaceAttribute(reader, i); String value = replaceProperties(reader.getAttributeValue(i)); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case HOST: builder.host(value); break; case PORT: builder.port(Integer.parseInt(value)); break; default: throw ParseUtils.unexpectedAttribute(reader, i); } } ParseUtils.requireNoContent(reader); }
switch (attribute) { case EXHAUSTED_ACTION: { builder.exhaustedAction(ExhaustedAction.valueOf(value)); break; builder.maxActive(Integer.parseInt(value)); break; builder.maxIdle(Integer.parseInt(value)); break; builder.maxTotal(Integer.parseInt(value)); break; builder.minEvictableIdleTime(Long.parseLong(value)); break; builder.minIdle(Integer.parseInt(value)); break; builder.testWhileIdle(Boolean.parseBoolean(value)); break; builder.timeBetweenEvictionRuns(Long.parseLong(value)); break;
public void testRemoteCacheStore() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <persistence>\n" + " <remote-store xmlns=\"urn:infinispan:config:store:remote:"+ Version.getSchemaVersion() + "\" >\n" + " <remote-server host=\"one\" />\n" + " <remote-server host=\"two\" />\n" + " <connection-pool max-active=\"10\" exhausted-action=\"CREATE_NEW\" />\n" + " <async-executor>\n" + " <property name=\"maxThreads\">4</property>" + " </async-executor>\n" + " <write-behind/>\n" + " </remote-store>\n" + " </persistence>\n" + " </local-cache>\n" + "</cache-container>" ); RemoteStoreConfiguration store = (RemoteStoreConfiguration) buildCacheManagerWithCacheStore(config); assert store.servers().size() == 2; assert store.connectionPool().exhaustedAction() == ExhaustedAction.CREATE_NEW; assert store.asyncExecutorFactory().properties().getIntProperty("maxThreads", 0) == 4; assert store.async().enabled(); }
private void parseServers(XMLExtendedStreamReader reader, RemoteStoreConfigurationBuilder builder) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case SERVER: { parseServer(reader, builder.addServer()); break; } default: throw ParseUtils.unexpectedElement(reader); } } }
@Test(expectedExceptions = CacheConfigurationException.class) public void testSegmentedWithUnsupportedVersion() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.persistence() .addStore(RemoteStoreConfigurationBuilder.class) .segmented(true) .protocolVersion(ProtocolVersion.PROTOCOL_VERSION_21); cb.build(); }
private void parseRemoteStore(final XMLExtendedStreamReader reader, PersistenceConfigurationBuilder persistenceBuilder, ClassLoader classLoader) throws XMLStreamException { RemoteStoreConfigurationBuilder builder = new RemoteStoreConfigurationBuilder(persistenceBuilder); parseRemoteStoreAttributes(reader, builder, classLoader); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case ASYNC_TRANSPORT_EXECUTOR: { parseAsyncTransportExecutor(reader, builder.asyncExecutorFactory(), classLoader); break; } case CONNECTION_POOL: { parseConnectionPool(reader, builder.connectionPool()); break; } case SERVERS: { parseServers(reader, builder); break; } default: { Parser60.parseCommonStoreChildren(reader, builder); break; } } } persistenceBuilder.addStore(builder); }
@Override protected void compareStoreConfiguration(String name, StoreConfiguration beforeStore, StoreConfiguration afterStore) { super.compareStoreConfiguration(name, beforeStore, afterStore); RemoteStoreConfiguration before = (RemoteStoreConfiguration) beforeStore; RemoteStoreConfiguration after = (RemoteStoreConfiguration) afterStore; AssertJUnit.assertEquals("Wrong connection pool for " + name + " configuration.", before.connectionPool(), after.connectionPool()); } }
private void configureRemoteCacheStore(ConfigurationBuilder builder, boolean async, String cacheName, boolean sessionCache) { String jdgServer = config.get("remoteStoreHost", "localhost"); Integer jdgPort = config.getInt("remoteStorePort", 11222); builder.persistence() .passivation(false) .addStore(RemoteStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false) .purgeOnStartup(false) .preload(false) .shared(true) .remoteCacheName(cacheName) .rawValues(true) .forceReturnValues(false) .marshaller(KeycloakHotRodMarshallerFactory.class.getName()) .protocolVersion(getHotrodVersion()) .addServer() .host(jdgServer) .port(jdgPort) // .connectionPool() // .maxActive(100) // .exhaustedAction(ExhaustedAction.CREATE_NEW) .async() .enabled(async); }
@BeforeClass public void setup() throws Exception { ConfigurationBuilder serverBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); serverCacheManager = TestCacheManagerFactory .createCacheManager(hotRodCacheConfiguration(serverBuilder)); serverCache = serverCacheManager.getCache(); sourceServer = HotRodClientTestingUtil.startHotRodServer(serverCacheManager); remoteSourceCacheManager = HotRodClientTestingUtil.getRemoteCacheManager(sourceServer); remoteSourceCacheManager.start(); remoteSourceCache = remoteSourceCacheManager.getCache(); ConfigurationBuilder clientBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); clientBuilder.persistence().addStore(RemoteStoreConfigurationBuilder.class) .hotRodWrapping(true) .addServer() .host(sourceServer.getHost()) .port(sourceServer.getPort()); targetCacheManager = TestCacheManagerFactory .createCacheManager(hotRodCacheConfiguration(clientBuilder)); targetCache = targetCacheManager.getCache(); targetServer = HotRodClientTestingUtil.startHotRodServer(targetCacheManager); remoteTargetCacheManager = HotRodClientTestingUtil.getRemoteCacheManager(targetServer); remoteTargetCacheManager.start(); remoteTargetCache = remoteTargetCacheManager.getCache(); }
@Override public void accept(RemoteStoreConfigurationBuilder builder) { builder.remoteCacheName(this.remoteCacheName) .socketTimeout(this.socketTimeout) .tcpNoDelay(this.tcpNoDelay) ; for (Supplier<OutboundSocketBinding> bindingDependency : this.bindings) { OutboundSocketBinding binding = bindingDependency.get(); builder.addServer().host(binding.getUnresolvedDestinationAddress()).port(binding.getDestinationPort()); } } }
@BeforeClass public void setup() throws Exception { ConfigurationBuilder serverBuilder = hotRodCacheConfiguration( TestCacheManagerFactory.getDefaultCacheConfiguration(false)); sourceContainer = TestCacheManagerFactory.createCacheManager(serverBuilder); sourceServerCache = sourceContainer.getCache(); sourceServer = HotRodClientTestingUtil.startHotRodServer(sourceContainer); ConfigurationBuilder targetConfigurationBuilder = hotRodCacheConfiguration( TestCacheManagerFactory.getDefaultCacheConfiguration(false)); targetConfigurationBuilder.persistence().addStore(RemoteStoreConfigurationBuilder.class).hotRodWrapping(true).addServer().host("localhost").port(sourceServer.getPort()); targetContainer = TestCacheManagerFactory.createCacheManager(targetConfigurationBuilder); targetServerCache = targetContainer.getCache(); targetServer = HotRodClientTestingUtil.startHotRodServer(targetContainer); sourceRemoteCacheManager = new RemoteCacheManager( new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServers("localhost:" + sourceServer.getPort()).build()); sourceRemoteCacheManager.start(); sourceRemoteCache = sourceRemoteCacheManager.getCache(); targetRemoteCacheManager = new RemoteCacheManager( new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServers("localhost:" + sourceServer.getPort()).build()); targetRemoteCacheManager.start(); }
@BeforeClass public void setup() throws Exception { ConfigurationBuilder serverBuilder = hotRodCacheConfiguration( TestCacheManagerFactory.getDefaultCacheConfiguration(false)); sourceContainer = TestCacheManagerFactory.createCacheManager(serverBuilder); sourceServerCache = sourceContainer.getCache(); sourceServer = TestHelper.startHotRodServer(sourceContainer); ConfigurationBuilder targetConfigurationBuilder = hotRodCacheConfiguration( TestCacheManagerFactory.getDefaultCacheConfiguration(false)); targetConfigurationBuilder.persistence().addStore(RemoteStoreConfigurationBuilder.class).hotRodWrapping(true).addServer().host("localhost").port(sourceServer.getPort()); targetContainer = TestCacheManagerFactory.createCacheManager(targetConfigurationBuilder); targetServerCache = targetContainer.getCache(); targetServer = TestHelper.startHotRodServer(targetContainer); sourceRemoteCacheManager = new RemoteCacheManager( new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServers("localhost:" + sourceServer.getPort()).build()); sourceRemoteCacheManager.start(); sourceRemoteCache = sourceRemoteCacheManager.getCache(); targetRemoteCacheManager = new RemoteCacheManager( new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServers("localhost:" + sourceServer.getPort()).build()); targetRemoteCacheManager.start(); targetRemoteCache = targetRemoteCacheManager.getCache(); }