public MarketUpdater(String stockName, float initialValue) { this.NAME_OF_SHARES = stockName; this.sharesTrend = new SharesTrend(stockName, initialValue); KEY_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); //configure the HotRod client and retrieve the cache Configuration config = new ConfigurationBuilder().addServer().host(SERVER_HOST).port(SERVER_PORT).build(); rcm = new RemoteCacheManager(config); cache = rcm.getCache(); }
Configuration build = new ConfigurationBuilder().addServer().host(infinispanAddress).build(); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(build);
@Before public void setUp() { if (rcm1 == null) { Configuration conf = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()) .port(server1.getHotrodEndpoint().getPort()).build(); Configuration conf2 = new ConfigurationBuilder().addServer().host(server2.getHotrodEndpoint().getInetAddress().getHostName()) .port(server2.getHotrodEndpoint().getPort()).build(); rcm1 = new RemoteCacheManager(conf); rcm2 = new RemoteCacheManager(conf2); } }
@Before public void setUp() { if (rcm1 == null) { Configuration conf = new ConfigurationBuilder().addServer() .host(server1.getHotrodEndpoint().getInetAddress().getHostName()) .port(server1.getHotrodEndpoint().getPort()).build(); rcm1 = new RemoteCacheManager(conf); jcacheProvider = Caching.getCachingProvider(cachingProvider); cacheManager = jcacheProvider.getCacheManager(); mBeanServer = ManagementFactory.getPlatformMBeanServer(); } }
private <K, V> RemoteCache<K, V> getRemoteCache(HotRodServer hotRodServer) { org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(clientBuilder.addServer().host("localhost").port(hotRodServer.getPort()).build()); return remoteCacheManager.getCache(CACHE_NAME); }
@Before public void setUp() { if (rcm1 == null) { Configuration conf = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()) .port(server1.getHotrodEndpoint().getPort()).build(); rcm1 = new RemoteCacheManager(conf); } }
@Override protected RemoteCacheManager createRemoteCacheManager() throws IOException { return new RemoteCacheManager(new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServer().host("localhost").port(hotRodServer.getPort()) .build()); }
@Before public void setUp() { if (rcm1 == null) { provider = new MBeanServerConnectionProvider(server1.getHotrodEndpoint().getInetAddress().getHostName(), SERVER1_MGMT_PORT); Configuration conf = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()).port(server1 .getHotrodEndpoint().getPort()).build(); Configuration conf2 = new ConfigurationBuilder().addServer() .host(server1.getHotrodEndpoint("hotrodconnector2").getInetAddress().getHostName()) .port(server1.getHotrodEndpoint("hotrodconnector2").getPort()).build(); rcm1 = new RemoteCacheManager(conf); rcm2 = new RemoteCacheManager(conf2); } }
@Before public void setUp() throws Exception { Configuration conf = new ConfigurationBuilder().addServer().host(server2.getHotrodEndpoint().getInetAddress().getHostName()).port(server2 .getHotrodEndpoint().getPort()).build(); cache = new RemoteCacheManager(conf).getCache(); }
@Before public void setUp() { if (managers == null) { Configuration conf; managers = new ArrayList<>(); for (RemoteInfinispanServer server : getServers()) { conf = new ConfigurationBuilder().addServer().host(server.getHotrodEndpoint().getInetAddress().getHostName()) .port(server.getHotrodEndpoint().getPort()).build(); managers.add(new RemoteCacheManager(conf, true)); } } for (RemoteCacheManager rcm : managers) { rcm.getCache().clear(); rcm.getCache(CACHE_NAME).clear(); rcm.getCache(CACHE_NAME_TX).clear(); } }
/** * Refresh the resources for each test */ @Before public void setUp() { if (conf1 == null || conf2 == null) { conf1 = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()) .port(server1.getHotrodEndpoint().getPort()).build(); conf2 = new ConfigurationBuilder().addServer().host(server2.getHotrodEndpoint().getInetAddress().getHostName()) .port(server2.getHotrodEndpoint().getPort()).build(); } rcm1 = new RemoteCacheManager(conf1); rcm2 = new RemoteCacheManager(conf2); src1 = rcm1.getCache("streamingTestCache").streaming(); src2 = rcm2.getCache("streamingTestCache").streaming(); }
@Before public void setUp() throws Exception { if (provider == null) { // initialize just once provider = new MBeanServerConnectionProvider(server1.getHotrodEndpoint().getInetAddress().getHostName(), SERVER1_MGMT_PORT); provider2 = new MBeanServerConnectionProvider(server2.getHotrodEndpoint().getInetAddress().getHostName(), SERVER2_MGMT_PORT); Configuration conf = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()).port(server1 .getHotrodEndpoint().getPort()).build(); manager = new RemoteCacheManager(conf); distCache = manager.getCache(); mc = new MemcachedClient("UTF-8", server1.getMemcachedEndpoint().getInetAddress() .getHostName(), server1.getMemcachedEndpoint().getPort(), 10000); rest = new RESTHelper(); rest.addServer(server1.getRESTEndpoint().getInetAddress().getHostName(), server1.getRESTEndpoint().getContextPath()); } resetCacheStatistics(); distCache.clear(); }
@Override protected void setup() throws Exception { super.setup(); hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager); port = hotrodServer.getPort(); remoteCacheManager = new RemoteCacheManager( new org.infinispan.client.hotrod.configuration.ConfigurationBuilder().addServer().host("localhost").port(port).build()); remoteCacheManager.start(); GlobalComponentRegistry gcr = TestingUtil.extractGlobalComponentRegistry(cacheManager); interpreter = gcr.getComponent(Interpreter.class); }
/** * Test for read-only attribute of store - if true, no entries will be written into store */ @Test @WithRunningServer({@RunningServer(name = CONTAINER_LOCAL)}) public void testReadOnly() throws Exception { Configuration conf = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()).port(server1 .getHotrodEndpoint().getPort()).build(); rcm1 = new RemoteCacheManager(conf); RemoteCache<String, String> rc1 = rcm1.getCache(READONLY_CACHE_NAME); // put 3 keys, one entry is evicted, but not stored Set<String> allKeys = new HashSet<>(); for (int i = 1; i < 4; i++) { String key = "k"+i; rc1.put(key, "v"+i); allKeys.add(key); } assertEquals(0, server2.getCacheManager(LOCAL_CACHE_MANAGER).getDefaultCache().getNumberOfEntriesInMemory()); assertEquals(2, server1.getCacheManager(LOCAL_CACHE_MANAGER).getCache(READONLY_CACHE_NAME).getNumberOfEntries()); assertEquals(2, server1.getCacheManager(LOCAL_CACHE_MANAGER).getCache(READONLY_CACHE_NAME).getNumberOfEntriesInMemory()); Set<String> storedKeys = rc1.keySet(); allKeys.removeAll(storedKeys); for (String key : allKeys) assertNull(rc1.get(key)); for (String key : storedKeys) { int i = Integer.parseInt(key.substring(1)); assertEquals("v"+i, rc1.get(key)); } }
@Test @Category(Unstable.class) // ISPN-8291 public void testHotRodConnectionCount() throws Exception { // get number of current local/global connections int initialLocal = getNumberOfLocalConnections(provider, hotRodTransportMBean); int initialGlobal = getNumberOfGlobalConnections(provider, hotRodTransportMBean); assertEquals("Number of global connections obtained from node1 and node2 is not the same", initialGlobal, getNumberOfGlobalConnections(provider2, hotRodTransportMBean)); // create another RCM and use it Configuration conf = new ConfigurationBuilder() .addServer() .host(server1.getHotrodEndpoint().getInetAddress().getHostAddress()) .port(server1.getHotrodEndpoint().getPort()).build(); RemoteCacheManager manager2 = new RemoteCacheManager(conf); manager2.getCache().put("key", "value"); // local connections increase by 1, global (in both nodes) by 2 (because we have distributed cache with 2 nodes, both nodes are accessed) assertEquals(initialLocal + 1, getNumberOfLocalConnections(provider, hotRodTransportMBean)); assertEquals(initialGlobal + 2, getNumberOfGlobalConnections(provider, hotRodTransportMBean)); assertEquals(initialGlobal + 2, getNumberOfGlobalConnections(provider2, hotRodTransportMBean)); }