use of org.infinispan.client.hotrod.configuration.ConfigurationBuilder in project gora by apache.
the class InfinispanClient method initialize.
public synchronized void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws Exception {
if (cache != null)
// already initialized.
return;
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<>();
}
use of org.infinispan.client.hotrod.configuration.ConfigurationBuilder in project camel by apache.
the class InfinispanManager method start.
@Override
public void start() throws Exception {
cacheContainer = configuration.getCacheContainer();
if (cacheContainer == null) {
String uri = configuration.getConfigurationUri();
if (uri != null && camelContext != null) {
uri = camelContext.resolvePropertyPlaceholders(uri);
}
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().classLoader(Thread.currentThread().getContextClassLoader());
if (uri != null) {
configurationBuilder.withProperties(InfinispanUtil.loadProperties(camelContext, uri));
}
cacheContainer = new RemoteCacheManager(configurationBuilder.addServers(configuration.getHost()).build(), true);
isManagedCacheContainer = true;
}
}
use of org.infinispan.client.hotrod.configuration.ConfigurationBuilder in project camel by apache.
the class InfinispanContinuousQueryIT method doPreSetup.
@Override
protected void doPreSetup() throws IOException {
ConfigurationBuilder builder = new ConfigurationBuilder().addServer().host("localhost").port(11222).marshaller(new ProtoStreamMarshaller());
manager = new RemoteCacheManager(builder.build());
RemoteCache<String, String> metadataCache = manager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("sample_bank_account/bank.proto", Util.read(InfinispanContinuousQueryIT.class.getResourceAsStream("/sample_bank_account/bank.proto")));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(manager));
SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(manager);
serCtx.registerProtoFiles(FileDescriptorSource.fromResources("/sample_bank_account/bank.proto"));
serCtx.registerMarshaller(new UserMarshaller());
serCtx.registerMarshaller(new GenderMarshaller());
// pre-load data
cache = manager.getCache("remote_query");
cache.clear();
}
use of org.infinispan.client.hotrod.configuration.ConfigurationBuilder in project camel by apache.
the class InfinispanRemoteQueryProducerIT method doPreSetup.
@Override
protected void doPreSetup() throws IOException {
ConfigurationBuilder builder = new ConfigurationBuilder().addServer().host("localhost").port(11222).marshaller(new ProtoStreamMarshaller());
manager = new RemoteCacheManager(builder.build());
RemoteCache<String, String> metadataCache = manager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("sample_bank_account/bank.proto", Util.read(InfinispanRemoteQueryProducerIT.class.getResourceAsStream("/sample_bank_account/bank.proto")));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(manager));
SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(manager);
serCtx.registerProtoFiles(FileDescriptorSource.fromResources("/sample_bank_account/bank.proto"));
serCtx.registerMarshaller(new UserMarshaller());
serCtx.registerMarshaller(new GenderMarshaller());
}
use of org.infinispan.client.hotrod.configuration.ConfigurationBuilder in project hazelcast-simulator by hazelcast.
the class InfinispanDriver method startVendorInstance.
@Override
public void startVendorInstance() throws Exception {
String workerType = get("WORKER_TYPE");
if ("javaclient".equals(workerType)) {
Properties hotrodProperties = new Properties();
hotrodProperties.setProperty("infinispan.client.hotrod.server_list", get("server_list"));
Configuration configuration = new ConfigurationBuilder().withProperties(hotrodProperties).build();
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration);
this.cacheContainer = remoteCacheManager;
remoteCacheManager.start();
} else {
DefaultCacheManager defaultCacheManager = new DefaultCacheManager("infinispan.xml");
this.cacheContainer = defaultCacheManager;
defaultCacheManager.start();
HotRodServerConfiguration hotRodServerConfiguration = new HotRodServerConfigurationBuilder().host(get("PRIVATE_ADDRESS")).port(11222).build();
this.hotRodServer = new HotRodServer();
hotRodServer.start(hotRodServerConfiguration, defaultCacheManager);
}
}
Aggregations