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(); }
public static RemoteCache<String,String> getDataCache() { // Create a configuration for a locally-running server ConfigurationBuilder builder = new ConfigurationBuilder(); builder .addServer().host("127.0.0.1").port(11222) .marshaller(UTF8StringMarshaller.class); RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); final RemoteCache<String, String> cache = cacheManager.getCache(); cache.clear(); return cache; }
public static ConfigurationBuilder createConfigBuilder(String hostName, int port, String protocolVersion) { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host(hostName).port(port).protocolVersion(protocolVersion).addJavaSerialWhiteList(".*"); return builder; }
public InfinispanSessionLegacyConverter (String cacheName) throws Exception { //legacy serialization _legacyManager = new RemoteCacheManager(); _legacyCache = _legacyManager.getCache(cacheName); //new protobuf based String host = System.getProperty("host", "127.0.0.1"); _verbose = Boolean.getBoolean("verbose"); Properties properties = new Properties(); ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); clientBuilder.withProperties(properties).addServer().host(host).marshaller(new ProtoStreamMarshaller()); _protoManager = new RemoteCacheManager(clientBuilder.build()); FileDescriptorSource fds = new FileDescriptorSource(); fds.addProtoFiles("/session.proto"); SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(_protoManager); serCtx.registerProtoFiles(fds); serCtx.registerMarshaller(new SessionDataMarshaller()); _protoCache = _protoManager.getCache(cacheName); }
@Before public void setUp() throws Exception { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host("127.0.0.1") .marshaller(new ProtoStreamMarshaller()) .nearCache().mode(NearCacheMode.INVALIDATED).cacheNamePattern("indexed").maxEntries(10); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(builder.build()); remoteCache = remoteCacheManager.getCache("indexed"); //initialize server-side serialization context RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); metadataCache.put("sample_bank_account/bank.proto", Util.getResourceAsString("/sample_bank_account/bank.proto", getClass().getClassLoader())); assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX)); //initialize client-side serialization context MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManager)); }
private RemoteCacheManager createRemoteCache(Map<String, String> properties) { String username = properties.get(USERNAME); String password = properties.get(PASSWORD); String realm = properties.get(REALM); String host = properties.get(HOST); String port = properties.get(PORT); try { ConfigurationBuilder builder = getMaybeSecurityBuilder(username, password, realm) .addServer() .host(host) .port(Integer.parseInt(port)) .marshaller(new ProtoStreamMarshaller()) .marshaller(marshaller); return new RemoteCacheManager(builder.build()); } catch (Exception e) { throw new InfinispanException(MessageFormat.format("Error trying to connect to server <{0}:{1}>", host, port), e); } }
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); }
private RemoteCacheManager createRemoteCache(Map<String, String> properties) { String username = properties.get(USERNAME); String password = properties.get(PASSWORD); String realm = properties.get(REALM); String host = properties.get(HOST); String port = properties.get(PORT); try { ConfigurationBuilder builder = getMaybeSecurityBuilder(username, password, realm) .addServer() .host(host) .port(Integer.parseInt(port)) .marshaller(new ProtoStreamMarshaller()) .marshaller(marshaller); return new RemoteCacheManager(builder.build()); } catch (Exception e) { throw new InfinispanException(MessageFormat.format("Error trying to connect to server <{0}:{1}>", host, port), e); } }
private ConfigurationBuilder getConfigurationBuilder(Properties userProperties) { ConfigurationBuilder builder = new ConfigurationBuilder(); InputStream is; if (userProperties != null && !userProperties.isEmpty()) { this.properties = userProperties; builder.withProperties(userProperties); } else if ((is = findPropertiesFile()) != null) { Properties fileProperties = new Properties(); try { fileProperties.load(is); this.properties = fileProperties; builder.withProperties(fileProperties); } catch (IOException e) { throw new CacheException("Unable to load properties from `hotrod-client.properties`", e); } } else { builder.addServer().host("127.0.0.1").port(11222); } return builder; }
@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); } }
public InfinispanRemoteCacheManager(KiWiConfiguration configuration) { this.configuration = configuration; Configuration remoteCfg = new ConfigurationBuilder() .addServer() .host(configuration.getClusterAddress()) .port(configuration.getClusterPort()) .marshaller(new CustomJBossMarshaller()) .socketTimeout(configuration.getClusterTimeout()) .connectionTimeout(configuration.getClusterTimeout()) .build(); cacheManager = new RemoteCacheManager(remoteCfg); log.info("initialised Infinispan remote cache manager (servers: {})", configuration.getClusterAddress()); }