Package org.infinispan.client.hotrod.configuration

Examples of org.infinispan.client.hotrod.configuration.ConfigurationBuilder


    *
    * @param start whether or not to start the RemoteCacheManager
    * @throws HotRodClientException if such a file cannot be found in the classpath
    */
   public RemoteCacheManager(boolean start) {
      ConfigurationBuilder builder = new ConfigurationBuilder();
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      builder.classLoader(cl);
      InputStream stream = FileLookupFactory.newInstance().lookupFile(HOTROD_CLIENT_PROPERTIES, cl);
      if (stream == null) {
         log.couldNotFindPropertiesFile(HOTROD_CLIENT_PROPERTIES);
      } else {
         try {
            builder.withProperties(loadFromStream(stream));
         } finally {
            Util.close(stream);
         }
      }
      this.configuration = builder.build();
      if (start) start();
   }
View Full Code Here


    *
    * @param start whether or not to start the RemoteCacheManager.
    */
   @Deprecated
   public RemoteCacheManager(String host, int port, boolean start, ClassLoader classLoader) {
      this(new ConfigurationBuilder().classLoader(classLoader).addServer().host(host).port(port).build(), start);
   }
View Full Code Here

    * The given string should have the following structure: "host1:port2;host:port2...". Every host:port defines a
    * server.
    */
   @Deprecated
   public RemoteCacheManager(String servers, boolean start, ClassLoader classLoader) {
      this(new ConfigurationBuilder().classLoader(classLoader).addServers(servers).build(), start);
   }
View Full Code Here

      InputStream stream = null;
      try {
         stream = config.openStream();
         Properties properties = loadFromStream(stream);
         configuration = new ConfigurationBuilder().classLoader(classLoader).withProperties(properties).build();
      } catch (IOException e) {
         throw new HotRodClientException("Could not read URL:" + config, e);
      } finally {
         try {
            if (stream != null)
View Full Code Here

            .startHotRodServer(cacheManager, port));
   }

   private void createHotRodCache(HotRodServer server) {
      hotrod = server;
      hotrodClient = new RemoteCacheManager(new ConfigurationBuilder()
            .addServers("localhost:" + hotrod.getPort())
            .marshaller(marshaller)
            .build());
      hotrodCache = cacheName.isEmpty()
            ? hotrodClient.<K, V>getCache()
View Full Code Here

         .trustStoreFileName(trustStoreFileName)
         .trustStorePassword("secret".toCharArray());
      hotrodServer.start(serverBuilder.build(), cacheManager);
      log.info("Started server on port: " + hotrodServer.getPort());

      ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
      clientBuilder
         .addServer()
            .host("127.0.0.1")
            .port(hotrodServer.getPort())
            .socketTimeout(3000)
         .connectionPool()
            .maxActive(1)
         .ssl()
            .enabled(sslClient)
            .keyStoreFileName(keyStoreFileName)
            .keyStorePassword("secret".toCharArray())
            .trustStoreFileName(trustStoreFileName)
            .trustStorePassword("secret".toCharArray())
          .connectionPool()
             .timeBetweenEvictionRuns(2000);
      remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
      defaultRemote = remoteCacheManager.getCache();
   }
View Full Code Here

@Test(testName = "client.hotrod.ConfigurationTest", groups = "functional" )
public class ConfigurationTest {

   public void testConfiguration() {
      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder
         .addServer()
            .host("host1")
            .port(11222)
         .addServer()
            .host("host2")
            .port(11222)
         .asyncExecutorFactory()
            .factoryClass(SomeAsyncExecutorFactory.class)
         .balancingStrategy(SomeRequestBalancingStrategy.class)
         .connectionPool()
            .maxActive(100)
            .maxTotal(150)
            .maxWait(1000)
            .maxIdle(20)
            .minIdle(10)
            .exhaustedAction(ExhaustedAction.WAIT)
            .numTestsPerEvictionRun(5)
            .testOnBorrow(true)
            .testOnReturn(true)
            .testWhileIdle(false)
            .minEvictableIdleTime(12000)
            .timeBetweenEvictionRuns(15000)
         .connectionTimeout(100)
         .consistentHashImpl(1, SomeCustomConsistentHashV1.class)
         .socketTimeout(100)
         .tcpNoDelay(false)
         .pingOnStartup(false)
         .keySizeEstimate(128)
         .valueSizeEstimate(1024)
         .transportFactory(SomeTransportfactory.class);

      Configuration configuration = builder.build();
      validateConfiguration(configuration);

      ConfigurationBuilder newBuilder = new ConfigurationBuilder();
      newBuilder.read(configuration);
      Configuration newConfiguration = newBuilder.build();
      validateConfiguration(newConfiguration);
   }
View Full Code Here

   protected InfinispanHotrodQueryable queryable;
   protected Configuration configuration;

   @Init
   public void init() {
      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.connectionPool().maxActive(maxConnectionsServer).maxTotal(maxConnectionsTotal);
      for (String server : servers.split(";")) {
         Matcher matcher = ADDRESS_PATTERN.matcher(server);
         if (!matcher.matches()) {
            log.error("Could not parse server address from " + server);
            continue;
         }
         String v6host = matcher.group(2);
         String v4host = matcher.group(3);
         String host = v6host != null ? v6host : v4host;
         String portString = matcher.group(4);
         int port = portString == null
               ? ConfigurationProperties.DEFAULT_HOTROD_PORT
               : Integer.parseInt(portString);

         serverHostnames.add(host);
         builder.addServer().host(host).port(port);
      }
      if (enableQuery) {
         queryable = new InfinispanHotrodQueryable(this);
         ProtoStreamMarshaller marshaller = new ProtoStreamMarshaller();
         builder.marshaller(marshaller);
         SerializationContext context = marshaller.getSerializationContext();
         queryable.registerProtofilesLocal(context);
         // remote registration has to be delayed until we have running servers

         // register marshallers
         for (RegisteredClass rc : classes) {
            try {
               context.registerMarshaller(rc.clazz, rc.getMarshaller());
            } catch (Exception e) {
               throw new IllegalArgumentException("Could not instantiate marshaller for " + rc.clazz, e);
            }
         }
      }
      configuration = builder.build();
   }
View Full Code Here

      this.NAME_OF_SHARES = stockName;
      this.sharesTrend = new SharesTrend(stockName, initialValue);
      KEY_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));

      //configure the HotRod client and retrieve the cache
      Configuration config = new ConfigurationBuilder().addServer().host(SERVER_HOST).port(SERVER_PORT).build();
      rcm = new RemoteCacheManager(config);
      cache = rcm.getCache();
   }
View Full Code Here

    * @param props      other properties
    * @param start      whether or not to start the manager on return from the constructor.
    */
   @Deprecated
   public RemoteCacheManager(Marshaller marshaller, Properties props, boolean start) {
      this(new ConfigurationBuilder().classLoader(Thread.currentThread().getContextClassLoader()).withProperties(props).marshaller(marshaller.getClass()).build(), start);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.client.hotrod.configuration.ConfigurationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.