@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(OutboundSocketBinding value) { try { builder.addServer().host(value.getResolvedDestinationAddress().getHostAddress()).port(value.getDestinationPort()); } catch (UnknownHostException e) { throw InfinispanMessages.MESSAGES.failedToInjectSocketBinding(e, value); } } };
@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()); } } }
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); }
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 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); }
@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; }
.addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); remoteSecurity .authentication().enable()
@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(); }
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); } }
@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 = TestCacheManagerFactory.getDefaultCacheConfiguration(false); serverBuilder.memory().size(100) .expiration().wakeUpInterval(10L); serverCacheManager = TestCacheManagerFactory.createCacheManager( hotRodCacheConfiguration(serverBuilder)); serverCache = serverCacheManager.getCache(); hrServer = HotRodClientTestingUtil.startHotRodServer(serverCacheManager); ConfigurationBuilder clientBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); clientBuilder.persistence().addStore(RemoteStoreConfigurationBuilder.class) .rawValues(true) .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); clientCacheManager = TestCacheManagerFactory.createCacheManager(clientBuilder); clientCache = clientCacheManager.getCache(); org.infinispan.client.hotrod.configuration.ConfigurationBuilder rcmBuilder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); rcmBuilder.addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); remoteCacheManager = new RemoteCacheManager(rcmBuilder.build()); remoteCacheManager.start(); remoteCache = remoteCacheManager.getCache(); }
@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(); }
@Override protected AdvancedLoadWriteStore createStore() throws Exception { ConfigurationBuilder localBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); localBuilder.memory().evictionType(EvictionType.COUNT).size(WRITE_DELETE_BATCH_MAX_ENTRIES) .expiration().wakeUpInterval(10L); localCacheManager = TestCacheManagerFactory.createCacheManager( new GlobalConfigurationBuilder().defaultCacheName(REMOTE_CACHE), hotRodCacheConfiguration(localBuilder)); localCacheManager.getCache(REMOTE_CACHE); TestingUtil.replaceComponent(localCacheManager, TimeService.class, timeService, true); localCacheManager.getCache(REMOTE_CACHE).getAdvancedCache().getComponentRegistry().rewire(); hrServer = HotRodClientTestingUtil.startHotRodServer(localCacheManager); ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); RemoteStoreConfigurationBuilder storeConfigurationBuilder = builder .persistence() .addStore(RemoteStoreConfigurationBuilder.class) .rawValues(true) .remoteCacheName(REMOTE_CACHE); storeConfigurationBuilder .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); RemoteStore remoteStore = new RemoteStore(); remoteStore.init(createContext(builder.build())); return remoteStore; }
@Override protected AdvancedLoadWriteStore createStore() throws Exception { ConfigurationBuilder localBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); localBuilder.memory().evictionType(EvictionType.COUNT).size(WRITE_DELETE_BATCH_MAX_ENTRIES).expiration().wakeUpInterval(10L); // Set it to dist so it has segments localBuilder.clustering().cacheMode(CacheMode.DIST_SYNC); GlobalConfigurationBuilder globalConfig = new GlobalConfigurationBuilder().clusteredDefault(); globalConfig.globalJmxStatistics().defaultCacheName(REMOTE_CACHE); localCacheManager = TestCacheManagerFactory.createClusteredCacheManager( globalConfig, hotRodCacheConfiguration(localBuilder)); localCacheManager.getCache(REMOTE_CACHE); TestingUtil.replaceComponent(localCacheManager, TimeService.class, timeService, true); localCacheManager.getCache(REMOTE_CACHE).getAdvancedCache().getComponentRegistry().rewire(); hrServer = HotRodClientTestingUtil.startHotRodServer(localCacheManager); // In case if the server has to unmarshall the value, make sure to use the same marshaller hrServer.setMarshaller(getMarshaller()); ConfigurationBuilder builder = TestCacheManagerFactory .getDefaultCacheConfiguration(false); RemoteStoreConfigurationBuilder storeConfigurationBuilder = builder .persistence() .addStore(RemoteStoreConfigurationBuilder.class) .remoteCacheName(REMOTE_CACHE); storeConfigurationBuilder .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); RemoteStore remoteStore = new RemoteStore(); remoteStore.init(createContext(builder.build())); return remoteStore; }