// Start a cache manager as usual EmbeddedCacheManager cacheManager; try (InputStream in = ClassLoader.getSystemResourceAsStream("infinispan.xml")) { cacheManager = new DefaultCacheManager(in); } // Start a server to allow remote access to the cache manager HotRodServerConfiguration serverConfig = new HotRodServerConfigurationBuilder() .host("127.0.0.1").port(9999).build(); HotRodServer server = new HotRodServer(); server.start(serverConfig, cacheManager); // Start the example cache Cache<String, String> cache = cacheManager.getCache("dumpster", true); cache.put("K", "V"); System.out.println(cache.get("K")); // V
@Test(expectedExceptions = CacheConfigurationException.class) public void testTopologyConflict() { int basePort = serverPort(); hotRodServer1 = startHotRodServer(cacheManagers.get(0), basePort, new HotRodServerConfigurationBuilder()); hotRodServer2 = startHotRodServer(cacheManagers.get(0), basePort + 50, new HotRodServerConfigurationBuilder()); }
@Override public List<HotRodServer> initServers() { HotRodServerConfigurationBuilder configuration = new HotRodServerConfigurationBuilder().port(0); return Arrays.asList(HotRodTestingUtil.startHotRodServer(new DefaultCacheManager(), configuration)); }
protected HotRodServer createHotRodServer() { HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder(); serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler()); return HotRodClientTestingUtil.startHotRodServer(cacheManager, serverBuilder); }
public static HotRodServer startHotRodServer(EmbeddedCacheManager manager, int port, int idleTimeout, String proxyHost, int proxyPort, long delay, String defaultCacheName) { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.proxyHost(proxyHost).proxyPort(proxyPort).idleTimeout(idleTimeout).defaultCacheName(defaultCacheName); return startHotRodServer(manager, port, delay, builder); }
public void testSharedContainer(Method m) { int basePort = serverPort(); hotRodServer1 = startHotRodServer(cacheManagers.get(0), basePort, new HotRodServerConfigurationBuilder().name("1")); hotRodServer2 = startHotRodServer(cacheManagers.get(0), basePort + 50, new HotRodServerConfigurationBuilder().name("2")); hotRodClient1 = new HotRodClient("127.0.0.1", hotRodServer1.getPort(), cacheName, 60, (byte) 20); hotRodClient2 = new HotRodClient("127.0.0.1", hotRodServer2.getPort(), cacheName, 60, (byte) 20); hotRodClient1.put(k(m), 0, 0, v(m)); assertSuccess(hotRodClient2.get(k(m), 0), v(m)); }
@Override public List<HotRodServer> initServers() { HotRodServerConfigurationBuilder configuration = new HotRodServerConfigurationBuilder().port(0); configuration.ssl() .enable() .keyStoreFileName(KEYSTORE_LOCATION) .keyStorePassword(PASSWORD) .trustStoreFileName(TRUSTSTORE_LOCATION) .trustStorePassword(PASSWORD); return Arrays.asList(HotRodTestingUtil.startHotRodServer(new DefaultCacheManager(), configuration)); }
public static HotRodServerConfigurationBuilder getDefaultHotRodConfiguration() { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); int port = serverPort(); builder.host(host()).port(port).proxyHost(host()).proxyPort(port); return builder; }
@Override public HotRodServer createStartHotRodServer(EmbeddedCacheManager cacheManager) { SimpleServerAuthenticationProvider ssap = new SimpleServerAuthenticationProvider(); ssap.addUser("user", "realm", "password".toCharArray()); HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.authentication().enable().addAllowedMech("CRAM-MD5").serverAuthenticationProvider(ssap) .serverName("localhost").addMechProperty(Sasl.POLICY_NOANONYMOUS, "true"); return startHotRodServer(cacheManager, HotRodTestingUtil.serverPort(), 0, builder); }
@BeforeClass public void setupRemoteCacheFactory() { HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder(); serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler()); hotrodServer = HotRodTestingUtil.startHotRodServer(cacheManager, ServerTestingUtil.findFreePort(), serverBuilder); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host("localhost").port(hotrodServer.getPort()); remoteCacheManager = new RemoteCacheManager(builder.build()); }
@BeforeClass public void setupRemoteCacheFactory() { HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder(); serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler()); hotrodServer = HotRodTestingUtil.startHotRodServer(cacheManager, ServerTestingUtil.findFreePort(), serverBuilder); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host("localhost").port(hotrodServer.getPort()); remoteCacheManager = new RemoteCacheManager(builder.build()); }
public void testMutatePortAndHost() { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.host("foo").port(1234); assertHostPort(builder.build(), "foo", 1234); builder.host("bar").port(4321); assertHostPort(builder.build(), "bar", 4321); }
@Override protected HotRodServer createStartHotRodServer(EmbeddedCacheManager cacheManager) { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.proxyHost(host()).proxyPort(serverPort()).idleTimeout(0); builder.ssl().enable() .keyStoreFileName(keyStoreFileName) .keyStorePassword("secret".toCharArray()) .keyStoreType("pkcs12") .trustStoreFileName(trustStoreFileName) .trustStorePassword("secret".toCharArray()) .trustStoreType("pkcs12"); return startHotRodServer(cacheManager, serverPort(), -1, builder); }
public void testLazyLoadTopology() { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.topologyStateTransfer(false).topologyReplTimeout(43000); withClusteredServer(builder, (cfg, distSyncTimeout) -> { assertEquals(cfg.clustering().remoteTimeout(), 43000); assertTrue(cfg.clustering().stateTransfer().fetchInMemoryState()); ClusterLoaderConfiguration clcfg = ((ClusterLoaderConfiguration) cfg.persistence().stores().get(0)); assertNotNull(clcfg); assertEquals(clcfg.remoteCallTimeout(), 43000); }); }
public void testServerStartWithSslAndCertPasswd() { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.host(host()).port(serverPort()).idleTimeout(0); builder.ssl().enable().keyStoreFileName(keyStoreFileName).keyStorePassword("secret".toCharArray()) .keyStoreType("pkcs12") .keyStoreCertificatePassword("secret2".toCharArray()).trustStoreFileName(trustStoreFileName) .trustStorePassword("secret".toCharArray()).trustStoreType("pkcs12"); Stoppable.useCacheManager(createCacheManager(hotRodCacheConfiguration()), cm -> Stoppable.useServer(new HotRodServer(), server -> { server.start(builder.build(), cm); assertNotNull(server.getConfiguration().ssl().keyStoreCertificatePassword()); } )); }
@Override public void afterPropertiesSet() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManager(HotRodTestingUtil.hotRodCacheConfiguration()); cacheManager.defineConfiguration(remoteCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(remoteBackupCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(customCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); HotRodServerConfigurationBuilder hcb = new HotRodServerConfigurationBuilder(); hcb.port(15233); hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager, hcb); }
@Override public void afterPropertiesSet() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManager(HotRodTestingUtil.hotRodCacheConfiguration()); cacheManager.defineConfiguration(remoteCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(remoteBackupCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(customCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); HotRodServerConfigurationBuilder hcb = new HotRodServerConfigurationBuilder(); hcb.port(15233); hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager, hcb); }
@Override public void afterPropertiesSet() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManager(HotRodTestingUtil.hotRodCacheConfiguration()); cacheManager.defineConfiguration(remoteCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(remoteBackupCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(customCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); HotRodServerConfigurationBuilder hcb = new HotRodServerConfigurationBuilder(); hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager, 15233, hcb); }
@Override public void afterPropertiesSet() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManager(HotRodTestingUtil.hotRodCacheConfiguration()); cacheManager.defineConfiguration(remoteCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(remoteBackupCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); cacheManager.defineConfiguration(customCacheName, HotRodTestingUtil.hotRodCacheConfiguration().build()); HotRodServerConfigurationBuilder hcb = new HotRodServerConfigurationBuilder(); hcb.port(15233); hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager, hcb); }
public void testUserDefinedTimeouts() { HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder(); builder.topologyLockTimeout(26000).topologyReplTimeout(31000); withClusteredServer(builder, (cfg, distSyncTimeout) -> { assertEquals(cfg.locking().lockAcquisitionTimeout(), 26000); assertEquals(cfg.clustering().remoteTimeout(), 31000); assertTrue(cfg.clustering().stateTransfer().fetchInMemoryState()); assertEquals(cfg.clustering().stateTransfer().timeout(), 31000 + distSyncTimeout); assertTrue(cfg.persistence().stores().isEmpty()); }); }