Uploaded image for project: 'Red Hat Data Grid'
  1. Red Hat Data Grid
  2. JDG-314

New cache creation based on newly created configuration template over CLI requires server restart

XMLWordPrintable

    • Hide

      1. Start JDG server in domain mode - ./domain.sh
      2. Start the ./ispn-cli.sh --connect and create new cache configuration and link a cache to it, e.g.

      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev:add(mode=SYNC,start=EAGER)
      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/transaction=TRANSACTION:add()
      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/transaction=TRANSACTION:write-attribute(name=mode,value=NON_XA)
      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/transaction=TRANSACTION:write-attribute(name=locking,value=PESSIMISTIC)
      
      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/compatibility=COMPATIBILITY:add()
      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/compatibility=COMPATIBILITY:write-attribute(name=enabled,value=true)
      
      /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/replicated-cache=testCache:add(configuration=arev)
      

      3. Then run the following main class:

      public class Test {
        public static void main(String[] args) throws IOException {
              RemoteCacheManager remoteCacheManager = new RemoteCacheManager(new   ConfigurationBuilder().addServer().host("localhost")
                      .port(11222).build(), true);
              RemoteCache<String, String> remoteCache = remoteCacheManager.getCache("testCache");
              RemoteCache scriptCache = remoteCacheManager.getCache("___script_cache");
      
              try (InputStream in = HotRodRemoteCacheDomainIT.class.getClassLoader().getResourceAsStream("test.js")) {
                  scriptCache.put("test.js", loadFileAsString(in));
              }
      
              Map<String, Object> parameters = new HashMap<>();
              parameters.put("key", "parameter");
              parameters.put("value", "value");
      
              int result = remoteCache.execute("test.js", parameters);
      
              assertEquals(1, result);
              assertEquals("value", remoteCache.get("parameter"));
          }
      }
      
      test.js
      
      // mode=local,language=javascript,parameters=[key,value]
      cache.put(key, value);
      
      // Return the size of the cache
      cache.size()
      
      

      This code will fail with the following assertion error:
      Exception in thread "main" java.lang.AssertionError: expected:<value> but was:<null>

      This happens because there is no key with name "parameter" in the cache. The key was placed into the cache as a byte (the compatibility configuration was ignored).

      4. If you will restart the jdg-server (manually or over CLI - reload --host=master ) and will run the same main class, then it will pass.
      5. If the reload is done over CLI with parameter for not restarting the server:
      reload --host=master --restart-servers=false
      then the issue still appears - so anyway it requires a server restart.

      The same can be done by using the transactions (before restarting the server, the program will throw a NullPointerException as there is no TransactionManager available). After restart it will pass.

      Show
      1. Start JDG server in domain mode - ./domain.sh 2. Start the ./ispn-cli.sh --connect and create new cache configuration and link a cache to it, e.g. /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev:add(mode=SYNC,start=EAGER) /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/transaction=TRANSACTION:add() /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/transaction=TRANSACTION:write-attribute(name=mode,value=NON_XA) /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/transaction=TRANSACTION:write-attribute(name=locking,value=PESSIMISTIC) /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/compatibility=COMPATIBILITY:add() /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS/replicated-cache-configuration=arev/compatibility=COMPATIBILITY:write-attribute(name=enabled,value= true ) /profile=clustered/subsystem=datagrid-infinispan/cache-container=clustered/replicated-cache=testCache:add(configuration=arev) 3. Then run the following main class: public class Test { public static void main( String [] args) throws IOException { RemoteCacheManager remoteCacheManager = new RemoteCacheManager( new ConfigurationBuilder().addServer().host( "localhost" ) .port(11222).build(), true ); RemoteCache< String , String > remoteCache = remoteCacheManager.getCache( "testCache" ); RemoteCache scriptCache = remoteCacheManager.getCache( "___script_cache" ); try (InputStream in = HotRodRemoteCacheDomainIT. class. getClassLoader().getResourceAsStream( "test.js" )) { scriptCache.put( "test.js" , loadFileAsString(in)); } Map< String , Object > parameters = new HashMap<>(); parameters.put( "key" , "parameter" ); parameters.put( "value" , "value" ); int result = remoteCache.execute( "test.js" , parameters); assertEquals(1, result); assertEquals( "value" , remoteCache.get( "parameter" )); } } test.js // mode=local,language=javascript,parameters=[key,value] cache.put(key, value); // Return the size of the cache cache.size() This code will fail with the following assertion error: Exception in thread "main" java.lang.AssertionError: expected:<value> but was:<null> This happens because there is no key with name "parameter" in the cache. The key was placed into the cache as a byte (the compatibility configuration was ignored). 4. If you will restart the jdg-server (manually or over CLI - reload --host=master ) and will run the same main class, then it will pass. 5. If the reload is done over CLI with parameter for not restarting the server: reload --host=master --restart-servers=false then the issue still appears - so anyway it requires a server restart. The same can be done by using the transactions (before restarting the server, the program will throw a NullPointerException as there is no TransactionManager available). After restart it will pass.

      When adding new cache configuration template (with linked cache) or modifying the existing cache configuration template (e.g. enabling the compatibility mode or transaction) using CLI, then the cache configuration is not visible from the client.
      The changes take affect only after the server restart.
      I would expect the cache be accessible right after the CLI changes are done.

      You can find the steps for reproduction in according section.

      Note: if only cache is created using CLI based on the existing configuration template (which was available before server start), then everything works fine - the configuration is applied to the newly created cache.

              rhn-support-chuffman Christian Huffman
              amanukya@redhat.com Anna Manukyan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: