use of org.infinispan.client.hotrod.RemoteCacheManager 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.RemoteCacheManager 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.RemoteCacheManager in project camel by apache.
the class InfinispanRemoteAggregationRepository method doStart.
@Override
protected void doStart() throws Exception {
if (maximumRedeliveries < 0) {
throw new IllegalArgumentException("Maximum redelivery retries must be zero or a positive integer.");
}
if (recoveryInterval < 0) {
throw new IllegalArgumentException("Recovery interval must be zero or a positive integer.");
}
if (ObjectHelper.isEmpty(configuration)) {
manager = new RemoteCacheManager();
manager.start();
} else {
manager = new RemoteCacheManager(configuration);
manager.start();
}
if (ObjectHelper.isEmpty(cacheName)) {
cache = manager.getCache();
} else {
cache = manager.getCache(cacheName);
}
}
use of org.infinispan.client.hotrod.RemoteCacheManager in project camel by apache.
the class InfinispanIdempotentRepository method getCache.
private BasicCache<Object, Boolean> getCache() {
if (cache == null) {
// them so force it.
if (InfinispanUtil.isRemote(cacheContainer)) {
RemoteCacheManager manager = InfinispanUtil.asRemote(cacheContainer);
cache = cacheName != null ? manager.getCache(cacheName, true) : manager.getCache(true);
} else {
cache = cacheName != null ? cacheContainer.getCache(cacheName) : cacheContainer.getCache();
}
}
return cache;
}
use of org.infinispan.client.hotrod.RemoteCacheManager 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();
}
Aggregations