Search in sources :

Example 1 with ConfigurationBuilder

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

Example 2 with ConfigurationBuilder

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

Example 3 with ConfigurationBuilder

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();
}
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)

Example 4 with ConfigurationBuilder

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());
}
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)

Example 5 with ConfigurationBuilder

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);
    }
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) Configuration(org.infinispan.client.hotrod.configuration.Configuration) HotRodServerConfiguration(org.infinispan.server.hotrod.configuration.HotRodServerConfiguration) HotRodServer(org.infinispan.server.hotrod.HotRodServer) HotRodServerConfiguration(org.infinispan.server.hotrod.configuration.HotRodServerConfiguration) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder) Properties(java.util.Properties)

Aggregations

RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)5 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)5 ProtoStreamMarshaller (org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller)2 SerializationContext (org.infinispan.protostream.SerializationContext)2 GenderMarshaller (org.infinispan.protostream.sampledomain.marshallers.GenderMarshaller)2 UserMarshaller (org.infinispan.protostream.sampledomain.marshallers.UserMarshaller)2 Properties (java.util.Properties)1 Marshaller (org.infinispan.avro.client.Marshaller)1 Configuration (org.infinispan.client.hotrod.configuration.Configuration)1 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 HotRodServer (org.infinispan.server.hotrod.HotRodServer)1 HotRodServerConfiguration (org.infinispan.server.hotrod.configuration.HotRodServerConfiguration)1 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)1