@Override public Configuration get() { ConfigurationBuilder builder = new ConfigurationBuilder() .marshaller(new HotRodMarshaller(this.module.get())) .connectionTimeout(this.connectionTimeout) .keySizeEstimate(this.keySizeEstimate)
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); } }
public synchronized void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws Exception { if (cache!=null) return; // already initialized. this.keyClass = keyClass; this.persistentClass = persistentClass; String host = properties.getProperty(ISPN_CONNECTION_STRING_KEY, getConf().get(ISPN_CONNECTION_STRING_KEY, ISPN_CONNECTION_STRING_DEFAULT)); conf.set(ISPN_CONNECTION_STRING_KEY, host); properties.setProperty(ISPN_CONNECTION_STRING_KEY, host); LOG.info("Connecting client to "+host); Marshaller<T> marshaller = new Marshaller<>(persistentClass); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServers(host); builder.marshaller(marshaller); cacheManager = new RemoteCacheManager(builder.build()); cacheManager.start(); cache = cacheManager.getCache(persistentClass.getSimpleName()); qf = org.infinispan.avro.hotrod.Search.getQueryFactory(cache); createSchema(); toPut = new HashMap<>(); }
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 void buildScriptCacheManager() throws ResourceException { try { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServers(remoteServerList); builder.marshaller(new GenericJBossMarshaller()); handleSecurity(builder); // note this object is expensive, so there needs to only one // instance for the JVM, in this case one per RA instance. this.scriptCacheManager = new RemoteCacheManager(builder.build()); this.scriptCacheManager.start(); } catch (Throwable e) { throw new ResourceException(e); } }
public RemoteCacheManager build() { ConfigurationBuilder builder = new ConfigurationBuilder() .classLoader( HotRodClientBuilder.class.getClassLoader() ) .withProperties( config.getClientProperties() ) .marshaller( this.marshaller ); if ( platform != null && !TransactionMode.NONE.equals( transactionMode ) ) { builder.transaction().transactionMode( transactionMode ); builder.transaction().transactionManagerLookup( new TransactionManagerLookupDelegator( platform ) ); } return new RemoteCacheManager( builder.build() ); }
private RemoteCacheManager createManager() { ConfigurationBuilder cfgBuild = ITestUtils.createConfigBuilder(server.getHotrodEndpoint().getInetAddress().getHostName(), server.getHotrodEndpoint().getPort()); cfgBuild.marshaller(clientMarshaller); return new RemoteCacheManager(cfgBuild.build()); } }
private void buildCacheManager() throws ResourceException { try { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServers(remoteServerList); builder.marshaller(new ProtoStreamMarshaller()); handleSecurity(builder); // note this object is expensive, so there needs to only one // instance for the JVM, in this case one per RA instance. this.cacheManager = new RemoteCacheManager(builder.build()); // register default marshellers /* SerializationContext ctx = ProtoStreamMarshaller.getSerializationContext(this.cacheManager); FileDescriptorSource fds = new FileDescriptorSource(); ctx.registerProtoFiles(fds); */ this.cacheManager.start(); this.ctx = ProtoStreamMarshaller.getSerializationContext(this.cacheManager); } catch (Throwable e) { throw new ResourceException(e); } }
private Configuration createRemoteCacheManagerConfiguration() { ConfigurationBuilder config = new ConfigurationBuilder(); for (RemoteInfinispanServer server : getServers()) { config.addServer() .host(server.getHotrodEndpoint().getInetAddress().getHostName()) .port(server.getHotrodEndpoint().getPort()); } config.marshaller(IdMarshaller.class.getName()); return config.build(); }
@Override public Configuration get() { ConfigurationBuilder builder = new ConfigurationBuilder() .marshaller(new HotRodMarshaller(this.module.get())) .connectionTimeout(this.connectionTimeout) .keySizeEstimate(this.keySizeEstimate)
private void createHotRodCache(HotRodServer server) { hotrod = server; hotrodClient = new RemoteCacheManager(new ConfigurationBuilder() .addServers("localhost:" + hotrod.getPort()) .addJavaSerialWhiteList(".*Person.*", ".*CustomEvent.*") .marshaller(marshaller) .build()); hotrodCache = cacheName.isEmpty() ? hotrodClient.getCache() : hotrodClient.getCache(cacheName); }
private RemoteCacheManager createRemoteCacheManager(Marshaller marshaller) { org.infinispan.client.hotrod.configuration.ConfigurationBuilder builder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); builder.addServer().host("localhost").port(hotRodServer.getPort()); if (marshaller != null) { builder.marshaller(marshaller); } return new RemoteCacheManager(builder.build()); }
.marshaller(new GenericJBossMarshaller(Thread.currentThread().getContextClassLoader()))
private ConfigurationBuilder createRemoteCacheManagerConfigurationBuilder() { ConfigurationBuilder config = new ConfigurationBuilder(); addServers(config); config.balancingStrategy("org.infinispan.server.test.client.hotrod.HotRodTestRequestBalancingStrategy") .forceReturnValues(true) .tcpNoDelay(false) .tcpKeepAlive(true) .marshaller("org.infinispan.server.test.client.hotrod.HotRodTestMarshaller") .asyncExecutorFactory().factoryClass("org.infinispan.server.test.client.hotrod.HotRodTestExecutorFactory") .addExecutorProperty("infinispan.client.hotrod.default_executor_factory.pool_size", "20") .addExecutorProperty("infinispan.client.hotrod.default_executor_factory.queue_size", "200000") .keySizeEstimate(128) .valueSizeEstimate(1024); return config; }
@Test public void testAttributeQuery() throws Exception { builder.marshaller(new ProtoStreamMarshaller()); manager = new RemoteCacheManager(builder.build()); RemoteCache<Integer, Object> cache = manager.getCache(INDEXED_CACHE);
@Test public void testEmptyConfiguration() throws Exception { ConfigurationBuilder confBuilder = new ConfigurationBuilder(); addServers(confBuilder); RemoteCacheManager rcm = new RemoteCacheManager(confBuilder.build()); RemoteCache rc = rcm.getCache(testCache); ConfigurationBuilder builder = new ConfigurationBuilder(); addServers(builder); builder.balancingStrategy("org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy") .forceReturnValues(false) .tcpNoDelay(true) .transportFactory("org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory") .marshaller("org.infinispan.commons.marshall.jboss.GenericJBossMarshaller") .asyncExecutorFactory().factoryClass("org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory") .addExecutorProperty("infinispan.client.hotrod.default_executor_factory.pool_size", "10") .addExecutorProperty("infinispan.client.hotrod.default_executor_factory.queue_size", "100000") .keySizeEstimate(64) .valueSizeEstimate(512); Configuration defaultConf = builder.build(); assertEqualConfiguration(defaultConf, rc); }