14 Replies Latest reply on Jul 8, 2017 11:30 PM by galder.zamarreno

    Infinispan Remote scripting with Protostreammarshaller

    abhishekdg1983

      Hi,

       

      I want to execute a remote java script with Protostreammarshaller configured:

       

      My java code:

      --------------------------------------

      ConfigurationBuilder builder = new ConfigurationBuilder();

               

              

              

               // builder.addServers("localhost:11222;localhost:11372").socketTimeout(1200000).security().authentication().enable().serverName("myhotrodserver").

               // saslMechanism("DIGEST-MD5").callbackHandler(new MyCallBackHandler("myuser", "ApplicationRealm", "qwer1234!".toCharArray())).marshaller(new ProtoStreamMarshaller());

                //URL resource = Thread.currentThread().getContextClassLoader().getResource("/addresscache/src/main/java/org/jboss/as/quickstarts/datagrid/hotrod/query/hotrod-client.properties");

       

                //URL resource = Thread.currentThread().getContextClassLoader().getResource("/org/jboss/as/quickstarts/datagrid/hotrod/query/hotrod-client.properties");

                InputStream is = AddressBookManager.class.getResourceAsStream("/org/jboss/as/quickstarts/datagrid/hotrod/query/hotrod-client.properties");

               

                Properties prop = new Properties();

       

               

       

                prop.load(is);

       

              builder.withProperties(prop).marshaller(new ProtoStreamMarshaller()); // this line is giving error

              

              

               

                //builder.addCluster(clusterName)addClusterNode("10.129.27.76", "11222")

               

                //builder.addServers("10.133.71.210:11222").marshaller(new ProtoStreamMarshaller());

                //builder.withProperties(is.)

                cacheManager = new RemoteCacheManager(builder.build());

             // Retrieve the cache containing the scripts

                RemoteCache<String, String> scriptCache = cacheManager.getCache("___script_cache");

                // Create a simple script which multiplies to numbers

                scriptCache.put("simple.js", "multiplicand * multiplier");

                // Obtain the remote cache

                RemoteCache<String, Integer> cache = cacheManager.getCache();

                // Create the parameters for script execution

                Map<String, Object> params = new HashMap<String, Object>();

                params.put("multiplicand", 10);

                params.put("multiplier", 20);

            

                // Run the script on the server, passing in the parameters

                Object result = cache.execute("simple.js", params);

                // Print the result

                System.out.printf("Result = %s\n", result);

                // Stop the cache manager and release resources

                cacheManager.stop();

       

       

      simple.js:

      ------------------------

       

      //mode=local,language=javascript

      multiplicand * multiplier