4 Replies Latest reply on Dec 15, 2014 4:15 AM by Sang Cheon Park

    RemoteCache data is null when using programmatic server configuration

    Sang Cheon Park Newbie

      Hi,

       

      I started Hotrod server using programmatic configuration and then put some data to cache using RemoteCache.

       

      But in spite of cache does not empty, value is null.

       

      This is my test code.

       

      public static void main(String[] args) {
      
           HotRodServerConfiguration hotrodConfig = new HotRodServerConfigurationBuilder()
                .host("127.0.0.1")
                .port(11222)     
                .workerThreads(100)
                .build();
      
           GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
                .nonClusteredDefault()
                .globalJmxStatistics().enable()
                .build();
      
           Configuration config = new org.infinispan.configuration.cache.ConfigurationBuilder()
                .clustering().cacheMode(CacheMode.LOCAL)
                .jmxStatistics().enable()
                .build();
      
           new HotRodServer().start(hotrodConfig, new DefaultCacheManager(globalConfig, config));
      
           org.infinispan.client.hotrod.configuration.ConfigurationBuilder builder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
           Properties properties = new Properties();
      
           properties.put("infinispan.client.hotrod.server_list", "127.0.0.1:11222");
      
           RemoteCacheManager manager = new RemoteCacheManager(builder.withProperties(properties).build());
           RemoteCache<String, Object> cache = manager.getCache();
      
           cache.put("key1", "value1");
           cache.put("key2", "value2");
           cache.put("key3", "value3");
      
           System.out.println("ProtocolVersion : " + cache.getProtocolVersion());
           System.out.println("Version : " + cache.getVersion());
           System.out.println("isEmpty : " + cache.isEmpty());
           System.out.println("Size : " + cache.size());
           System.out.println(cache.keySet().toString());
          
           System.out.println(cache.get("key1"));
           System.out.println(cache.get("key2"));
           System.out.println(cache.get("key3"));
      }
      

       

      Output :

      ProtocolVersion : HotRod client, protocol version :2.0

      Version : 7.0.2.Final

      isEmpty : false

      Size : 3

      [key3, key2, key1]

      null

      null

      null

       

      cache.getBulk() can get the value, but update or delete operation did not work.

       

      Could any one help me on this issue.