Search in sources :

Example 1 with RemoteCacheManager

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<>();
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) Marshaller(org.infinispan.avro.client.Marshaller)

Example 2 with RemoteCacheManager

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;
    }
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager)

Example 3 with RemoteCacheManager

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);
    }
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager)

Example 4 with RemoteCacheManager

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;
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager)

Example 5 with RemoteCacheManager

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();
}
Also used : SerializationContext(org.infinispan.protostream.SerializationContext) ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) UserMarshaller(org.infinispan.protostream.sampledomain.marshallers.UserMarshaller) ProtoStreamMarshaller(org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller) GenderMarshaller(org.infinispan.protostream.sampledomain.marshallers.GenderMarshaller)

Aggregations

RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)9 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)5 ProtoStreamMarshaller (org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller)2 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)2 SerializationContext (org.infinispan.protostream.SerializationContext)2 GenderMarshaller (org.infinispan.protostream.sampledomain.marshallers.GenderMarshaller)2 UserMarshaller (org.infinispan.protostream.sampledomain.marshallers.UserMarshaller)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Properties (java.util.Properties)1 Collectors (java.util.stream.Collectors)1 Marshaller (org.infinispan.avro.client.Marshaller)1 Configuration (org.infinispan.client.hotrod.configuration.Configuration)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 HotRodServer (org.infinispan.server.hotrod.HotRodServer)1 HotRodServerConfiguration (org.infinispan.server.hotrod.configuration.HotRodServerConfiguration)1 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)1