Example #1
0
        public void RemoteMapReduceWithStreamsTest()
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.AddServer().Host("127.0.0.1").Port(11222);
            conf.ConnectionTimeout(90000).SocketTimeout(6000);
            marshaller = new JBasicMarshaller();
            conf.Marshaller(marshaller);
            remoteManager = new RemoteCacheManager(conf.Build(), true);
            IRemoteCache <string, string> scriptCache = remoteManager.GetCache <string, string>(PROTOBUF_SCRIPT_CACHE_NAME);
            IRemoteCache <string, string> testCache   = remoteManager.GetCache <string, string>();

            try
            {
                const string scriptName = "wordCountStream.js";
                ScriptUtils.LoadTestCache(testCache, "macbeth.txt");
                ScriptUtils.LoadScriptCache(scriptCache, scriptName, scriptName);

                Dictionary <string, object> scriptArgs = new Dictionary <string, object>();

                var       result = (System.Int64)testCache.Execute(scriptName, scriptArgs);
                const int expectedMacbethCount = 287;
                Assert.AreEqual(expectedMacbethCount, result);
            }
            finally
            {
                testCache.Clear();
            }
        }
        public void TestRemoteTaskExec(IRemoteCache <string, string> cache, IRemoteCache <string, string> scriptCache, IMarshaller marshaller)
        {
            string scriptName = "script.js";
            string script     = "//mode=local,language=javascript\n "
                                + "var cache = cacheManager.getCache(\"default\");\n "
                                + "cache.put(\"k1\", value);\n"
                                + "cache.get(\"k1\");\n";
            DataFormat df = new DataFormat();

            df.KeyMediaType   = "application/x-jboss-marshalling";
            df.ValueMediaType = "application/x-jboss-marshalling";
            IRemoteCache <String, String> dfScriptCache = scriptCache.WithDataFormat(df);

            dfScriptCache.Put(scriptName, script);
            IRemoteCache <String, String> dfCache    = cache.WithDataFormat(df);
            Dictionary <string, object>   scriptArgs = new Dictionary <string, object>();

            scriptArgs.Add("value", "v1");
            string ret1 = (string)dfCache.Execute(scriptName, scriptArgs);

            Assert.AreEqual("v1", ret1);
        }
Example #3
0
        public void RemoteTaskEmptyArgsTest()
        {
            // Register on the server a js routine that takes 3 sec to return a value
            string scriptName = "script.js";
            string script     = "// mode=local,language=javascript\n "
                                + "var cache = cacheManager.getCache(\"default\");\n"
                                + "cache.put(\"argsKey1\", \"argValue1\");\n"
                                + "cache.get(\"argsKey1\");\n";
            IRemoteCache <string, string> scriptCache = remoteManager.GetCache <string, string>(PROTOBUF_SCRIPT_CACHE_NAME, new JBasicMarshaller());
            IRemoteCache <string, long>   testCache   = remoteManager.GetCache <string, long>();

            try
            {
                scriptCache.Put(scriptName, script);
                string ret1 = (string)testCache.Execute(scriptName);
                Assert.AreEqual("argValue1", ret1);
            }
            finally
            {
                testCache.Clear();
            }
        }
Example #4
0
        public void RemoteTaskWithIntArgs()
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.AddServer().Host("127.0.0.1").Port(11222);
            conf.ConnectionTimeout(90000).SocketTimeout(6000);
            remoteManager = new RemoteCacheManager(conf.Build(), true);
            string script = "// mode=local,language=javascript \n"
                            + "var x = k+v; \n"
                            + "x; \n";
            LoggingEventListener <string> listener    = new LoggingEventListener <string>();
            IRemoteCache <string, string> testCache   = remoteManager.GetCache <string, string>();
            IRemoteCache <string, string> scriptCache = remoteManager.GetCache <string, string>(PROTOBUF_SCRIPT_CACHE_NAME, new JBasicMarshaller());
            const string scriptName = "putit-get.js";

            scriptCache.Put(scriptName, script);
            Dictionary <string, object> scriptArgs = new Dictionary <string, object>();

            scriptArgs.Add("k", (int)1);
            scriptArgs.Add("v", (int)2);
            object v = testCache.Execute(scriptName, scriptArgs);

            Assert.AreEqual(3, v);
        }