@Override public RemoteCacheManager get() { Configuration configuration = this.configuration.get(); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration); remoteCacheManager.start(); InfinispanLogger.ROOT_LOGGER.remoteCacheContainerStarted(this.name); return remoteCacheManager; }
@Override public void cleanup() { remoteIspnManager.stop(); remoteIspnManager = null; }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setTcpKeepAlive(boolean)}. * * @throws Exception */ @Test public final void setTcpKeepAliveShouldOverrideDefaultTcpKeepAlive() throws Exception { final boolean expectedTcpKeepAlive = false; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setTcpNoDelay(expectedTcpKeepAlive); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setTcpKeepAlive(" + expectedTcpKeepAlive + ") should have overridden property 'tcpNoDelay'. However, it didn't.", String.valueOf(expectedTcpKeepAlive), remoteCacheManager.getConfiguration().properties().get(TCP_KEEP_ALIVE)); objectUnderTest.destroy(); }
/** * Test method for {@link org.infinispan.spring.provider.SpringRemoteCacheManager#start()}. * * @throws IOException */ @Test public final void startShouldStartTheNativeRemoteCacheManager() throws IOException { final RemoteCacheManager nativeCacheManager = new RemoteCacheManager(true); final SpringRemoteCacheManager objectUnderTest = new SpringRemoteCacheManager( nativeCacheManager); objectUnderTest.start(); assertTrue("Calling start() on SpringRemoteCacheManager should start the enclosed " + "Infinispan RemoteCacheManager. However, it is still not running.", nativeCacheManager.isStarted()); }
/** * Test method for {@link org.infinispan.spring.provider.SpringRemoteCacheManager#stop()}. * * @throws IOException */ @Test public final void stopShouldStopTheNativeRemoteCacheManager() throws IOException { final RemoteCacheManager nativeCacheManager = new RemoteCacheManager(true); final SpringRemoteCacheManager objectUnderTest = new SpringRemoteCacheManager( nativeCacheManager); objectUnderTest.stop(); assertFalse("Calling stop() on SpringRemoteCacheManager should stop the enclosed " + "Infinispan RemoteCacheManager. However, it is still running.", nativeCacheManager.isStarted()); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManager#getNativeCacheManager()}. * * @throws IOException */ @Test public final void getNativeCacheShouldReturnTheRemoteCacheManagerSuppliedAtConstructionTime() throws IOException { final RemoteCacheManager nativeCacheManager = new RemoteCacheManager(true); final SpringRemoteCacheManager objectUnderTest = new SpringRemoteCacheManager( nativeCacheManager); final RemoteCacheManager nativeCacheManagerReturned = objectUnderTest.getNativeCacheManager(); assertSame( "getNativeCacheManager() should have returned the RemoteCacheManager supplied at construction time. However, it retuned a different one.", nativeCacheManager, nativeCacheManagerReturned); } }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManager#getCacheNames()}. */ @Test(expectedExceptions = UnsupportedOperationException.class) public final void getCacheNamesShouldThrowAnUnsupportedOperationException() { final RemoteCacheManager nativeCacheManager = new RemoteCacheManager(true); final SpringRemoteCacheManager objectUnderTest = new SpringRemoteCacheManager( nativeCacheManager); nativeCacheManager.stop(); objectUnderTest.getCacheNames(); }
public void testHotRodCodec() throws Exception { Cache<byte[], byte[]> cache = cacheManager.getCache(); RemoteCache<String, String> remoteCache = remoteCacheManager.getCache(); remoteCache.put("k1", "v1"); GenericJBossMarshaller marshaller = new GenericJBossMarshaller(); byte[] k1 = marshaller.objectToByteBuffer("k1"); assertTrue(cache.containsKey(k1)); String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME); Map<String, String> response = interpreter.execute(sessionId, "get --codec=hotrod k1;"); assertEquals("v1", response.get(ResultKeys.OUTPUT.toString())); interpreter.execute(sessionId, "put --codec=hotrod k2 v2;"); String v2 = remoteCache.get("k2"); assertEquals("v2", v2); }
@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(); }
cacheContainer = new RemoteCacheManager( (org.infinispan.client.hotrod.configuration.Configuration)containerConf, true cacheContainer = new RemoteCacheManager(builder.build(), true); cacheContainer = new DefaultCacheManager(new org.infinispan.configuration.cache.ConfigurationBuilder().build());
private void testHotRodCodecWithCache(String cacheName) throws Exception { RemoteCache<String, String> remoteCache = remoteCacheManager.getCache(cacheName); remoteCache.put("k1", "v1"); String sessionId = interpreter.createSessionId(cacheName); Map<String, String> response = interpreter.execute(sessionId, "get --codec=hotrod k1;"); assertEquals("v1", response.get(ResultKeys.OUTPUT.toString())); assertInterpreter(interpreter.execute(sessionId, "remove --codec=hotrod k1;")); String v1 = remoteCache.get("k1"); assertNull(v1); assertInterpreter(interpreter.execute(sessionId, "put --codec=hotrod k2 v2;")); String v2 = remoteCache.get("k2"); assertEquals("v2", v2); assertInterpreter(interpreter.execute(sessionId, "evict --codec=hotrod k2;")); v2 = remoteCache.get("k2"); assertNull(v2); }
protected void initialize(String login, String password) { Configuration config = getRemoteCacheManagerConfig(login, password); remoteCacheManager = new RemoteCacheManager(config, true); remoteCache = remoteCacheManager.getCache(TEST_CACHE_NAME); }
Configuration config = new ConfigurationBuilder().addServer() .host("127.0.0.1").port(9999).build(); RemoteCacheManager cacheManager = new RemoteCacheManager(config); RemoteCache<String, String> cache = cacheManager.getCache("dumpster"); System.out.println(cache.get("K")); // V
public TestCluster build() { List<HotRodServer> hotRodServers = new ArrayList<>(); List<EmbeddedCacheManager> embeddedCacheManagers = new ArrayList<>(); for (int i = 0; i < numMembers; i++) { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.transport().defaultTransport().clusterName(name); EmbeddedCacheManager clusteredCacheManager = createClusteredCacheManager(gcb, getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC)); caches.entrySet().forEach(entry -> clusteredCacheManager.defineConfiguration(entry.getKey(), entry.getValue().build())); embeddedCacheManagers.add(clusteredCacheManager); hotRodServers.add(HotRodClientTestingUtil.startHotRodServer(clusteredCacheManager, hotRodBuilder)); } int port = hotRodServers.get(0).getPort(); org.infinispan.client.hotrod.configuration.ConfigurationBuilder build = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); build.addServer().port(port).host("localhost"); if (trustStoreFileName != null) { build.security().ssl().enable().trustStoreFileName(trustStoreFileName).trustStorePassword(trustStorePassword); } if (keyStoreFileName != null) { build.security().ssl().keyStoreFileName(keyStoreFileName).keyStorePassword(keyStorePassword); } return new TestCluster(hotRodServers, embeddedCacheManagers, new RemoteCacheManager(build.build())); }
Configuration configuration = new ConfigurationBuilder().maxRetries(2).build(); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration);
@BeforeClass protected void setup() throws Exception { cacheManager = TestCacheManagerFactory.createServerModeCacheManager(); ClassWhiteList classWhiteList = cacheManager.getClassWhiteList(); classWhiteList.addRegexps(".*"); cacheManager.defineConfiguration(CACHE_NAME, getIndexCacheConfiguration().build()); RestServerConfigurationBuilder builder = new RestServerConfigurationBuilder(); int restPort = findFreePort(); builder.port(restPort); restServer = new RestServer(); restServer.start(builder.build(), cacheManager); restClient = new HttpClient(); hotRodServer = startHotRodServer(cacheManager); remoteCacheManager = createRemoteCacheManager(); remoteCache = remoteCacheManager.getCache(CACHE_NAME); restEndpoint = String.format("http://localhost:%s/rest/%s", restServer.getPort(), CACHE_NAME); }
@BeforeClass protected void setup() throws Exception { cacheManager = TestCacheManagerFactory.createServerModeCacheManager(); cacheManager.defineConfiguration(DEFAULT_CACHE_NAME, getDefaultCacheConfiguration().build()); cacheManager.defineConfiguration(MARSHALLED_CACHE_NAME, getMarshalledCacheConfiguration().build()); cacheManager.defineConfiguration(STRING_CACHE_NAME, getStringsCacheConfiguration().build()); RestServerConfigurationBuilder builder = new RestServerConfigurationBuilder(); builder.port(findFreePort()); restServer = new RestServer(); restServer.start(builder.build(), cacheManager); restClient = new HttpClient(); hotRodServer = startHotRodServer(cacheManager); defaultRemoteCache = createRemoteCacheManager(IdentityMarshaller.INSTANCE).getCache(DEFAULT_CACHE_NAME); defaultMarshalledRemoteCache = createRemoteCacheManager(null).getCache(MARSHALLED_CACHE_NAME); stringRemoteCache = createRemoteCacheManager(new UTF8StringMarshaller()).getCache(STRING_CACHE_NAME); }
@Override public void afterPropertiesSet() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManager(false); cacheManager.getCache(remoteCacheName); hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host("localhost").port(hotrodServer.getPort()); remoteCacheManager = new RemoteCacheManager(builder.build()); }
private void testHotRodEncodingWithCache(String cacheName) throws Exception { RemoteCache<String, String> remoteCache = remoteCacheManager.getCache(cacheName); remoteCache.put("k1", "v1"); String sessionId = interpreter.createSessionId(cacheName); interpreter.execute(sessionId, "encoding hotrod;"); Map<String, String> response = interpreter.execute(sessionId, "get k1;"); assertEquals("v1", response.get(ResultKeys.OUTPUT.toString())); assertInterpreter(interpreter.execute(sessionId, "put k2 v2;")); String v2 = remoteCache.get("k2"); assertEquals("v2", v2); }