#ignite-964: move examples to examples module.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5c86f3b0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5c86f3b0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5c86f3b0 Branch: refs/heads/ignite-964-1 Commit: 5c86f3b01496b5b58a83b41146a4a7869a0c058c Parents: a5654be Author: ivasilinets <ivasilin...@gridgain.com> Authored: Tue Jul 7 17:15:45 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Tue Jul 7 17:15:45 2015 +0300 ---------------------------------------------------------------------- examples/config/js/example-js-cache.xml | 40 ++++++ examples/config/js/rest-jetty.xml | 71 +++++++++++ examples/pom.xml | 6 + .../examples/js/ExampleJsNodeStartup.java | 36 ++++++ examples/src/main/js/cache-api-example.js | 67 ++++++++++ examples/src/main/js/cache-put-get-example.js | 119 ++++++++++++++++++ examples/src/main/js/cache-query-example.js | 52 ++++++++ .../main/js/compute-callable-cache-example.js | 49 ++++++++ .../src/main/js/compute-callable-example.js | 44 +++++++ .../src/main/js/compute-task-split-example.js | 56 +++++++++ .../IgniteScriptingCommandHandler.java | 2 +- modules/nodejs/src/main/js/apache-ignite.js | 2 +- modules/nodejs/src/main/js/cache.js | 10 +- .../main/js/examples/config/example-ignite.xml | 91 -------------- .../src/main/js/examples/config/rest-jetty.xml | 71 ----------- .../main/js/examples/src/cache-api-example.js | 85 ------------- .../js/examples/src/cache-put-get-example.js | 122 ------------------- .../main/js/examples/src/cache-query-example.js | 59 --------- .../src/compute-callable-cache-example.js | 57 --------- .../js/examples/src/compute-callable-example.js | 50 -------- .../js/examples/src/compute-runnable-example.js | 42 ------- .../examples/src/compute-task-split-example.js | 62 ---------- .../ignite/examples/ExampleNodeStartup.java | 36 ------ modules/nodejs/src/test/js/test-cache-api.js | 10 +- modules/nodejs/src/test/js/test-compute.js | 16 +-- 25 files changed, 560 insertions(+), 695 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/config/js/example-js-cache.xml ---------------------------------------------------------------------- diff --git a/examples/config/js/example-js-cache.xml b/examples/config/js/example-js-cache.xml new file mode 100644 index 0000000..2599e38 --- /dev/null +++ b/examples/config/js/example-js-cache.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + Ignite configuration with all defaults and enabled p2p deployment and enabled events. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="gridName" value="ServerNode" /> + + <property name="connectorConfiguration"> + <bean class="org.apache.ignite.configuration.ConnectorConfiguration"> + <property name="jettyPath" value="examples/config/js/rest-jetty.xml"/> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/config/js/rest-jetty.xml ---------------------------------------------------------------------- diff --git a/examples/config/js/rest-jetty.xml b/examples/config/js/rest-jetty.xml new file mode 100644 index 0000000..abc146b --- /dev/null +++ b/examples/config/js/rest-jetty.xml @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> +<Configure id="Server" class="org.eclipse.jetty.server.Server"> + <Arg name="threadPool"> + <!-- Default queued blocking thread pool --> + <New class="org.eclipse.jetty.util.thread.QueuedThreadPool"> + <Set name="minThreads">20</Set> + <Set name="maxThreads">200</Set> + </New> + </Arg> + <New id="httpCfg" class="org.eclipse.jetty.server.HttpConfiguration"> + <Set name="secureScheme">https</Set> + <Set name="securePort">8443</Set> + <Set name="sendServerVersion">true</Set> + <Set name="sendDateHeader">true</Set> + </New> + <Call name="addConnector"> + <Arg> + <New class="org.eclipse.jetty.server.ServerConnector"> + <Arg name="server"><Ref refid="Server"/></Arg> + <Arg name="factories"> + <Array type="org.eclipse.jetty.server.ConnectionFactory"> + <Item> + <New class="org.eclipse.jetty.server.HttpConnectionFactory"> + <Ref refid="httpCfg"/> + </New> + </Item> + </Array> + </Arg> + <Set name="host"> + <SystemProperty name="IGNITE_JETTY_HOST" default="localhost"/> + </Set> + <Set name="port"> + <SystemProperty name="IGNITE_JETTY_PORT" default="9095"/> + </Set> + <Set name="idleTimeout">30000</Set> + <Set name="reuseAddress">true</Set> + </New> + </Arg> + </Call> + <Set name="handler"> + <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> + <Set name="handlers"> + <Array type="org.eclipse.jetty.server.Handler"> + <Item> + <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> + </Item> + </Array> + </Set> + </New> + </Set> + <Set name="stopAtShutdown">false</Set> +</Configure> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index 2f292e9..ad20a70 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -51,6 +51,12 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-rest-http</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-spring</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/java/org/apache/ignite/examples/js/ExampleJsNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/js/ExampleJsNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/js/ExampleJsNodeStartup.java new file mode 100644 index 0000000..6fa2e6c --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/js/ExampleJsNodeStartup.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.js; + +import org.apache.ignite.*; +import org.apache.ignite.spi.discovery.tcp.internal.*; + +/** + * Starts up an empty node with example compute configuration. + */ +public class ExampleJsNodeStartup { + /** + * Start up an empty node with example compute configuration. + * + * @param args Command line arguments, none required. + * @throws IgniteException If failed. + */ + public static void main(String[] args) throws IgniteException { + Ignition.start("examples/config/js/example-js-cache.xml"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/js/cache-api-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/cache-api-example.js b/examples/src/main/js/cache-api-example.js new file mode 100644 index 0000000..24c31d2 --- /dev/null +++ b/examples/src/main/js/cache-api-example.js @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var apacheIgnite = require("apache-ignite"); +var Ignition = apacheIgnite.Ignition; + +Ignition.start(['127.0.0.1:9095'], null, onConnect); + +function onConnect(err, ignite) { + console.log(">>> Cache API example started."); + + var cache = ignite.getOrCreateCache("ApiExampleCache"); + + atomicMapOperations(cache); +} + +/** + * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that + * cache API is a lot richer than the JDK {@link ConcurrentMap}. + */ +atomicMapOperations = function(cache) { + console.log(">>> Cache atomic map operation examples."); + + cache.removeAllFromCache(function(err) { + cache.getAndPut(1, "1", onGetAndPut.bind(null, cache)) + }); +} + +function onGetAndPut(cache, err, entry) { + cache.put(2, "2", onPut.bind(null, cache)); +} + +function onPut(cache, err) { + cache.putIfAbsent(4, "44", onPutIfAbsent.bind(null, cache, true)); +} + +function onPutIfAbsent(cache, expRes, err, res) { + if (expRes) { + cache.putIfAbsent(4, "44", onPutIfAbsent.bind(null, cache, false)); + } + else { + cache.replaceValue(4, "55", "44", onReplaceValue.bind(null, cache, true)); + } +} + +function onReplaceValue(cache, expRes, err, res) { + if (expRes) { + cache.replaceValue(4, "555", "44", onReplaceValue.bind(null, cache, false)); + } + else { + console.log("End of the example.") + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/js/cache-put-get-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/cache-put-get-example.js b/examples/src/main/js/cache-put-get-example.js new file mode 100644 index 0000000..92e0797 --- /dev/null +++ b/examples/src/main/js/cache-put-get-example.js @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var apacheIgnite = require("apache-ignite"); + +var Ignition = apacheIgnite.Ignition; +var CacheEntry = apacheIgnite.CacheEntry; + +Ignition.start(['127.0.0.1:9095'], null, onConnect); + +function onConnect(err, ignite) { + if (err) + throw err; + + var cache = ignite.getOrCreateCache("PutGetExampleCache"); + + putGet(cache); + + putAllGetAll(cache); +} + +putGet = function(cache) { + console.log(">>> Cache put-get example started."); + + var keyCnt = 20; + + var putCnt = 0; + + var onGet = function(err, res) { + if (err) { + console.log("Error: " + err); + + throw new Error(err); + } + + console.log("Get val=" + res); + } + + var onPut = function(err) { + if (err) { + console.log("Error: " + err); + + throw new Error(err); + } + + if (putCnt < keyCnt - 1) { + putCnt++; + + return; + } + + console.log(">>> Stored values in cache."); + + for (var i = 0; i < keyCnt; i++) { + cache.get(i, onGet); + } + } + + // Store keys in cache. + for (var i = 0; i < keyCnt; i++) { + cache.put(i, i.toString(), onPut); + } +} + +putAllGetAll = function(cache) { + console.log(">>> Starting putAll-getAll example."); + + var keyCnt = 20; + + var batch = []; + var keys = []; + + for (var i = keyCnt; i < keyCnt + keyCnt; ++i) { + var key = i; + + var val = "bulk-" + i; + + keys.push(key); + batch.push(new CacheEntry(key, val)); + } + + var onGetAll = function(err, entries) { + if (err) { + console.log("Error: " + err); + + throw new Error(err); + } + + for (var e of entries) { + console.log("Got entry [key=" + e.key + ", val=" + e.value + ']'); + } + } + + var onPutAll= function(err) { + if (err) { + console.log("Error: " + err); + + throw new Error(err); + } + + cache.getAll(keys, onGetAll); + } + + cache.putAll(batch, onPutAll); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/js/cache-query-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/cache-query-example.js b/examples/src/main/js/cache-query-example.js new file mode 100644 index 0000000..f31f0d5 --- /dev/null +++ b/examples/src/main/js/cache-query-example.js @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var apacheIgnite = require("apache-ignite"); + +var Ignition = apacheIgnite.Ignition; +var SqlQuery = apacheIgnite.SqlQuery; +var SqlFieldsQuery = apacheIgnite.SqlFieldsQuery; +var CacheEntry = apacheIgnite.CacheEntry; + +var cacheName = "CacheQueryExample"; + +Ignition.start(['127.0.0.1:9095'], null, onConnect); + +function onConnect(err, ignite) { + console.log(">>> Cache query example started."); + + var entries = [new Entry("key0", "val0"), new Entry("key1", "val1")]; + + ignite.getOrCreateCache(cacheName).putAll(entries, onCachePut.bind(null, ignite)); +} + +function onCachePut(ignite, err) { + var qry = new SqlQuery("Select * from String"); + qry.setReturnType("String"); + + var fullRes = []; + + qry.on("page", function(res) { + fullRes = fullRes.concat(res); + }); + + qry.on("end", function(err) { + console.log(fullRes); + }); + + ignite.cache(cacheName).query(qry); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/js/compute-callable-cache-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/compute-callable-cache-example.js b/examples/src/main/js/compute-callable-cache-example.js new file mode 100644 index 0000000..1b92d7c --- /dev/null +++ b/examples/src/main/js/compute-callable-cache-example.js @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var apacheIgnite = require("apache-ignite"); +var Ignition = apacheIgnite.Ignition; + +var cacheName = "ComputeCallableCacheExample"; + +Ignition.start(['127.0.0.1:9095'], null, onConnect); + +function onConnect(err, ignite) { + console.log(">>> Compute callable example started."); + + var f = function (args) { + print(">>> Hello node: " + ignite.name()); + + var cache = ignite.getOrCreateCache(args); + + cache.put(ignite.name(), "Hello"); + + return ignite.name(); + } + + var onRunScript = function(err, igniteName) { + var cache = ignite.cache(cacheName); + + cache.get(igniteName, function(err, res) { + console.log(res+ " " + igniteName); + + console.log(">>> Check all nodes for output (this node is also part of the cluster)."); + }); + } + + ignite.compute().runScript(f, cacheName, onRunScript); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/js/compute-callable-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/compute-callable-example.js b/examples/src/main/js/compute-callable-example.js new file mode 100644 index 0000000..1005c9f --- /dev/null +++ b/examples/src/main/js/compute-callable-example.js @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var apacheIgnite = require("apache-ignite"); +var Ignition = apacheIgnite.Ignition; + +Ignition.start(['127.0.0.1:9095'], null, onConnect); + +function onConnect(err, ignite) { + console.log(">>> Compute callable example started"); + + var f = function (args) { + var words = args.split(" "); + + var sum = 0; + + for (var i = 0; i < words.length; ++i) { + sum += words[i].length; + } + + return sum; + } + + var onRunScript = function(err, sum) { + console.log(">>> Total number of characters in the phrase is '" + sum + "'."); + console.log(">>> Check all nodes for output (this node is also part of the cluster)."); + } + + ignite.compute().runScript(f, "Hello Ignite Enabled World!", onRunScript); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/examples/src/main/js/compute-task-split-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/compute-task-split-example.js b/examples/src/main/js/compute-task-split-example.js new file mode 100644 index 0000000..e6d7ee9 --- /dev/null +++ b/examples/src/main/js/compute-task-split-example.js @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var apacheIgnite = require("apache-ignite"); +var Ignition = apacheIgnite.Ignition; + +Ignition.start(['127.0.0.1:9095'], null, onConnect); + +function onConnect(err, ignite) { + console.log(">>> Compute task split example started."); + + var map = function(nodes, args) { + var words = args.split(" "); + + for (var i = 0; i < words.length; i++) { + var f = function (word) { + print(">>> Printing '" + word + "' on this node from ignite job."); + + return word.length; + }; + + emit(f, words[i], nodes[i % nodes.length]); + } + } + + var reduce = function(results) { + var sum = 0; + + for (var i = 0; i < results.length; ++i) { + sum += results[i]; + } + + return sum; + } + + var onMapReduce = function(err, cnt) { + console.log(">>> Total number of characters in the phrase is '" + cnt + "'."); + console.log(">>> Check all nodes for output (this node is also part of the cluster)."); + } + + ignite.compute().execute(map, reduce, "Hello Ignite Enabled World!", onMapReduce); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java index 2ccdcbc..f2ddd59 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java @@ -63,7 +63,7 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter script.addEngineFunction(emitFunction); - String entryFunction = "Entry = function(key, val) {" + + String entryFunction = "CacheEntry = function(key, val) {" + "this.key = key; this.value = val}"; script.addEngineFunction(entryFunction); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/apache-ignite.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/apache-ignite.js b/modules/nodejs/src/main/js/apache-ignite.js index 82aa5ca..2379b36 100644 --- a/modules/nodejs/src/main/js/apache-ignite.js +++ b/modules/nodejs/src/main/js/apache-ignite.js @@ -17,7 +17,7 @@ module.exports = { Cache : require('./cache.js').Cache, - Entry : require('./cache.js').Entry, + CacheEntry : require('./cache.js').CacheEntry, Ignition : require('./ignition.js').Ignition, Server : require('./server.js').Server, Ignite : require('./ignite.js').Ignite, http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/cache.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/cache.js b/modules/nodejs/src/main/js/cache.js index 93ded2d..67a8b6c 100644 --- a/modules/nodejs/src/main/js/cache.js +++ b/modules/nodejs/src/main/js/cache.js @@ -144,7 +144,7 @@ Cache.prototype.removeAllFromCache = function(callback) { * Put keys to cache * * @this {Cache} - * @param {Entry[]} List of entries to put in the cache + * @param {CacheEntry[]} List of entries to put in the cache * @param {noValue} callback Called on finish */ Cache.prototype.putAll = function(entries, callback) { @@ -170,7 +170,7 @@ Cache.prototype.getAll = function(keys, callback) { var result = []; for (var key of res) { - result.push(new Entry(key["key"], key["value"])); + result.push(new CacheEntry(key["key"], key["value"])); } callback.call(null, null, result); @@ -374,11 +374,11 @@ Cache.prototype._runCacheCommand = function(command, callback) { } } /** - * @this{Entry} + * @this{CacheEntry} * @param key Key * @param val Value */ -function Entry(key0, val0) { +function CacheEntry(key0, val0) { this.key = key0; this.value = val0; } @@ -392,4 +392,4 @@ function Entry(key0, val0) { */ exports.Cache = Cache -exports.Entry = Entry \ No newline at end of file +exports.CacheEntry = CacheEntry \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/config/example-ignite.xml ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/config/example-ignite.xml b/modules/nodejs/src/main/js/examples/config/example-ignite.xml deleted file mode 100644 index d351631..0000000 --- a/modules/nodejs/src/main/js/examples/config/example-ignite.xml +++ /dev/null @@ -1,91 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<!-- - Ignite configuration with all defaults and enabled p2p deployment and enabled events. ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:util="http://www.springframework.org/schema/util" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util - http://www.springframework.org/schema/util/spring-util.xsd"> - <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> - <property name="gridName" value="ServerNode" /> - - <property name="connectorConfiguration"> - <bean class="org.apache.ignite.configuration.ConnectorConfiguration"> - <property name="jettyPath" value="modules/nodejs/src/main/js/examples/config/rest-jetty.xml"/> - </bean> - </property> - - <!-- Set to true to enable distributed class loading for examples, default is false. --> - <property name="peerClassLoadingEnabled" value="true"/> - - <property name="marshaller"> - <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller"> - <!-- Set to false to allow non-serializable objects in examples, default is true. --> - <property name="requireSerializable" value="false"/> - </bean> - </property> - - <!-- Enable task execution events for examples. --> - <property name="includeEventTypes"> - <list> - <!--Task execution events--> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/> - - <!--Cache events--> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/> - </list> - </property> - - <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> - <property name="discoverySpi"> - <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> - <property name="ipFinder"> - <!-- - Ignite provides several options for automatic discovery that can be used - instead os static IP based discovery. For information on all options refer - to our documentation: http://apacheignite.readme.io/docs/cluster-config - --> - <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. --> - <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">--> - <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> - <property name="addresses"> - <list> - <!-- In distributed environment, replace with actual host IP address. --> - <value>127.0.0.1:47500..47509</value> - </list> - </property> - </bean> - </property> - </bean> - </property> - </bean> -</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/config/rest-jetty.xml ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/config/rest-jetty.xml b/modules/nodejs/src/main/js/examples/config/rest-jetty.xml deleted file mode 100644 index abc146b..0000000 --- a/modules/nodejs/src/main/js/examples/config/rest-jetty.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> -<Configure id="Server" class="org.eclipse.jetty.server.Server"> - <Arg name="threadPool"> - <!-- Default queued blocking thread pool --> - <New class="org.eclipse.jetty.util.thread.QueuedThreadPool"> - <Set name="minThreads">20</Set> - <Set name="maxThreads">200</Set> - </New> - </Arg> - <New id="httpCfg" class="org.eclipse.jetty.server.HttpConfiguration"> - <Set name="secureScheme">https</Set> - <Set name="securePort">8443</Set> - <Set name="sendServerVersion">true</Set> - <Set name="sendDateHeader">true</Set> - </New> - <Call name="addConnector"> - <Arg> - <New class="org.eclipse.jetty.server.ServerConnector"> - <Arg name="server"><Ref refid="Server"/></Arg> - <Arg name="factories"> - <Array type="org.eclipse.jetty.server.ConnectionFactory"> - <Item> - <New class="org.eclipse.jetty.server.HttpConnectionFactory"> - <Ref refid="httpCfg"/> - </New> - </Item> - </Array> - </Arg> - <Set name="host"> - <SystemProperty name="IGNITE_JETTY_HOST" default="localhost"/> - </Set> - <Set name="port"> - <SystemProperty name="IGNITE_JETTY_PORT" default="9095"/> - </Set> - <Set name="idleTimeout">30000</Set> - <Set name="reuseAddress">true</Set> - </New> - </Arg> - </Call> - <Set name="handler"> - <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> - <Set name="handlers"> - <Array type="org.eclipse.jetty.server.Handler"> - <Item> - <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> - </Item> - </Array> - </Set> - </New> - </Set> - <Set name="stopAtShutdown">false</Set> -</Configure> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/cache-api-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/cache-api-example.js b/modules/nodejs/src/main/js/examples/src/cache-api-example.js deleted file mode 100644 index 30e0739..0000000 --- a/modules/nodejs/src/main/js/examples/src/cache-api-example.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); -var assert = require("assert"); - -var Ignition = Ignite.Ignition; -var Entry = Ignite.Entry; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(err, ignite) { - assert(err === null); - - console.log(">>> Cache API example started."); - - var cache = ignite.getOrCreateCache("ApiExampleCache"); - - atomicMapOperations(cache); -} - -/** - * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that - * cache API is a lot richer than the JDK {@link ConcurrentMap}. - */ -atomicMapOperations = function(cache) { - console.log(">>> Cache atomic map operation examples."); - - cache.removeAllFromCache(function(err) { - assert(err === null); - - cache.getAndPut(1, "1", onGetAndPut.bind(null, cache)) - }); -} - -function onGetAndPut(cache, err, entry) { - assert(err == null); - assert(entry == null); - - cache.put(2, "2", onPut.bind(null, cache)); -} - -function onPut(cache, err) { - assert(err === null); - - cache.putIfAbsent(4, "44", onPutIfAbsent.bind(null, cache, true)); -} - -function onPutIfAbsent(cache, expRes, err, res) { - assert(err === null); - assert(res === expRes); - - if (expRes) { - cache.putIfAbsent(4, "44", onPutIfAbsent.bind(null, cache, false)); - } - else { - cache.replaceValue(4, "55", "44", onReplaceValue.bind(null, cache, true)); - } -} - -function onReplaceValue(cache, expRes, err, res) { - assert(err === null); - assert(res === expRes); - - if (expRes) { - cache.replaceValue(4, "555", "44", onReplaceValue.bind(null, cache, false)); - } - else { - console.log("End of the example.") - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js b/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js deleted file mode 100644 index 0906e64..0000000 --- a/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); - -var Ignition = Ignite.Ignition; -var Entry = Ignite.Entry; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(error, ignite) { - if (error) { - console.log("Error: " + error); - - throw new Error(error); - } - - var cache = ignite.getOrCreateCache("PutGetExampleCache"); - - putGet(cache); - - putAllGetAll(cache); -} - -putGet = function(cache) { - console.log(">>> Cache put-get example started."); - - var keyCnt = 20; - - var putCnt = 0; - - var onGet = function(err, res) { - if (err) { - console.log("Error: " + err); - - throw new Error(err); - } - - console.log("Get val=" + res); - } - - var onPut = function(err) { - if (err) { - console.log("Error: " + err); - - throw new Error(err); - } - - if (putCnt < keyCnt - 1) { - putCnt++; - - return; - } - - console.log(">>> Stored values in cache."); - - for (var i = 0; i < keyCnt; i++) { - cache.get(i, onGet); - } - } - - // Store keys in cache. - for (var i = 0; i < keyCnt; i++) { - cache.put(i, i.toString(), onPut); - } -} - -putAllGetAll = function(cache) { - console.log(">>> Starting putAll-getAll example."); - - var keyCnt = 20; - - var batch = []; - var keys = []; - - for (var i = keyCnt; i < keyCnt + keyCnt; ++i) { - var key = i; - - var val = "bulk-" + i; - - keys.push(key); - batch.push(new Entry(key, val)); - } - - var onGetAll = function(err, entries) { - if (err) { - console.log("Error: " + err); - - throw new Error(err); - } - - for (var e of entries) { - console.log("Got entry [key=" + e.key + ", val=" + e.value + ']'); - } - } - - var onPutAll= function(err) { - if (err) { - console.log("Error: " + err); - - throw new Error(err); - } - - cache.getAll(keys, onGetAll); - } - - cache.putAll(batch, onPutAll); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/cache-query-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/cache-query-example.js b/modules/nodejs/src/main/js/examples/src/cache-query-example.js deleted file mode 100644 index b6eb37a..0000000 --- a/modules/nodejs/src/main/js/examples/src/cache-query-example.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); -var assert = require("assert"); - -var Ignition = Ignite.Ignition; -var SqlQuery = Ignite.SqlQuery; -var SqlFieldsQuery = Ignite.SqlFieldsQuery; -var Entry = Ignite.Entry; - -var cacheName = "CacheQueryExample"; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(err, ignite) { - assert(err === null, err); - - console.log(">>> Cache query example started."); - - var entries = [new Entry("key0", "val0"), new Entry("key1", "val1")]; - - ignite.getOrCreateCache(cacheName).putAll(entries, onCachePut.bind(null, ignite)); -} - -function onCachePut(ignite, err) { - assert(err == null, err); - - var qry = new SqlQuery("Select * from String"); - qry.setReturnType("String"); - - var fullRes = []; - - qry.on("page", function(res) { - fullRes = fullRes.concat(res); - }); - - qry.on("end", function(err) { - assert(err == null, err); - - console.log(fullRes); - }); - - ignite.cache(cacheName).query(qry); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/compute-callable-cache-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/compute-callable-cache-example.js b/modules/nodejs/src/main/js/examples/src/compute-callable-cache-example.js deleted file mode 100644 index a1e8c0f..0000000 --- a/modules/nodejs/src/main/js/examples/src/compute-callable-cache-example.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); -var assert = require("assert"); - -var Ignition = Ignite.Ignition; - -var cacheName = "ComputeCallableCacheExample"; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(err, ignite) { - assert(err === null); - - console.log(">>> Compute callable example started."); - - var f = function (args) { - print(">>> Hello node: " + ignite.name()); - - var cache = ignite.getOrCreateCache(args); - - cache.put(ignite.name(), "Hello"); - - return ignite.name(); - } - - var onRunScript = function(err, igniteName) { - assert(err == null, err); - - var cache = ignite.cache(cacheName); - - cache.get(igniteName, function(err, res) { - assert(err == null, err); - - console.log(res+ " " + igniteName); - - console.log(">>> Check all nodes for output (this node is also part of the cluster)."); - }); - } - - ignite.compute().runScript(f, cacheName, onRunScript); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/compute-callable-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/compute-callable-example.js b/modules/nodejs/src/main/js/examples/src/compute-callable-example.js deleted file mode 100644 index bd923e6..0000000 --- a/modules/nodejs/src/main/js/examples/src/compute-callable-example.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); -var assert = require("assert"); - -var Ignition = Ignite.Ignition; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(err, ignite) { - assert(err === null); - - console.log(">>> Compute callable example started"); - - var f = function (args) { - var words = args.split(" "); - - var sum = 0; - - for (var i = 0; i < words.length; ++i) { - sum += words[i].length; - } - - return sum; - } - - var onRunScript = function(err, sum) { - assert(err == null); - - console.log(">>> Total number of characters in the phrase is '" + sum + "'."); - console.log(">>> Check all nodes for output (this node is also part of the cluster)."); - } - - ignite.compute().runScript(f, "Hello Ignite Enabled World!", onRunScript); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/compute-runnable-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/compute-runnable-example.js b/modules/nodejs/src/main/js/examples/src/compute-runnable-example.js deleted file mode 100644 index 191d750..0000000 --- a/modules/nodejs/src/main/js/examples/src/compute-runnable-example.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); -var assert = require("assert"); - -var Ignition = Ignite.Ignition; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(err, ignite) { - assert(err === null); - - console.log(">>> Compute runnable example started."); - - var f = function (args) { - print(">>> Printing '" + args + "' on this node from ignite job."); - } - - var onRunScript = function(err, res) { - assert(err == null, err); - - console.log(">>> Finished printing words using runnable execution."); - console.log(">>> Check all nodes for output (this node is also part of the cluster)."); - } - - ignite.compute().runScript(f, "Hello Ignite Enabled World!", onRunScript); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/compute-task-split-example.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/compute-task-split-example.js b/modules/nodejs/src/main/js/examples/src/compute-task-split-example.js deleted file mode 100644 index a5b0102..0000000 --- a/modules/nodejs/src/main/js/examples/src/compute-task-split-example.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Ignite = require("../../"); -var assert = require("assert"); - -var Ignition = Ignite.Ignition; - -Ignition.start(['127.0.0.1:9095'], null, onConnect); - -function onConnect(err, ignite) { - assert(err === null); - - console.log(">>> Compute task split example started."); - - var map = function(nodes, args) { - var words = args.split(" "); - - for (var i = 0; i < words.length; i++) { - var f = function (word) { - print(">>> Printing '" + word + "' on this node from ignite job."); - - return word.length; - }; - - emit(f, words[i], nodes[i % nodes.length]); - } - } - - var reduce = function(results) { - var sum = 0; - - for (var i = 0; i < results.length; ++i) { - sum += results[i]; - } - - return sum; - } - - var onMapReduce = function(err, cnt) { - assert(err === null, err); - - console.log(">>> Total number of characters in the phrase is '" + cnt + "'."); - console.log(">>> Check all nodes for output (this node is also part of the cluster)."); - } - - ignite.compute().execute(map, reduce, "Hello Ignite Enabled World!", onMapReduce); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/main/js/examples/src/org/apache/ignite/examples/ExampleNodeStartup.java ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/examples/src/org/apache/ignite/examples/ExampleNodeStartup.java b/modules/nodejs/src/main/js/examples/src/org/apache/ignite/examples/ExampleNodeStartup.java deleted file mode 100644 index 1578c18..0000000 --- a/modules/nodejs/src/main/js/examples/src/org/apache/ignite/examples/ExampleNodeStartup.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.examples; - -import org.apache.ignite.*; -import org.apache.ignite.spi.discovery.tcp.internal.*; - -/** - * Starts up an empty node with example compute configuration. - */ -public class ExampleNodeStartup { - /** - * Start up an empty node with example compute configuration. - * - * @param args Command line arguments, none required. - * @throws IgniteException If failed. - */ - public static void main(String[] args) throws IgniteException { - Ignition.start("modules/nodejs/src/main/js/examples/config/example-ignite.xml"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/test/js/test-cache-api.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-cache-api.js b/modules/nodejs/src/test/js/test-cache-api.js index 98a382f..c599a86 100644 --- a/modules/nodejs/src/test/js/test-cache-api.js +++ b/modules/nodejs/src/test/js/test-cache-api.js @@ -18,7 +18,7 @@ var TestUtils = require("./test-utils").TestUtils; var Ignite = require(TestUtils.scriptPath()); -var Entry = Ignite.Entry; +var CacheEntry = Ignite.CacheEntry; var assert = require("assert"); @@ -291,8 +291,8 @@ function objectEntries() { var val1 = {"age" : 12, "books" : ["1", "Book"]}; var val2 = {"age" : 13, "books" : ["1", "Book"]}; - entries.push(new Entry(key1, val1)); - entries.push(new Entry(key2, val2)); + entries.push(new CacheEntry(key1, val1)); + entries.push(new CacheEntry(key2, val2)); return entries; } @@ -300,8 +300,8 @@ function objectEntries() { function stringEntries() { entries = []; - entries.push(new Entry("key1", "val1")); - entries.push(new Entry("key2", "val2")); + entries.push(new CacheEntry("key1", "val1")); + entries.push(new CacheEntry("key2", "val2")); return entries; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c86f3b0/modules/nodejs/src/test/js/test-compute.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-compute.js b/modules/nodejs/src/test/js/test-compute.js index b99a7ad..111d79f 100644 --- a/modules/nodejs/src/test/js/test-compute.js +++ b/modules/nodejs/src/test/js/test-compute.js @@ -18,7 +18,7 @@ var TestUtils = require("./test-utils").TestUtils; var Ignite = require(TestUtils.scriptPath()); -var Entry = Ignite.Entry; +var CacheEntry = Ignite.CacheEntry; var assert = require("assert"); @@ -145,7 +145,7 @@ testComputeRunScriptPutAllGetAll = function() { var initKey1 = {"2" : "AAA"}; var initVal0 = {"1" : ["1", "2"]}; var initVal1 = {"2" : "AAA"}; - var initEntries = [new Entry(initKey0, initVal0), new Entry(initKey1, initVal1)]; + var initEntries = [new CacheEntry(initKey0, initVal0), new CacheEntry(initKey1, initVal1)]; comp.runScript(f, [initEntries, [initKey0, initKey1]], onEnd.bind(null)); @@ -172,7 +172,7 @@ testComputeRunScriptRemoveOperations = function() { var val0 = {"valName" : 1}; var val1 = {"valName" : 2}; - var entries = [new Entry(key0, val0), new Entry(key1, val1)]; + var entries = [new CacheEntry(key0, val0), new CacheEntry(key1, val1)]; var keys = [key0, key1]; cache.put(key0, val0); @@ -347,8 +347,8 @@ testComputeMapReduceGetAndRemoveObject = function() { var val1 = {"age" : 12, "books" : ["1", "Book"]}; var val2 = {"age" : 13, "books" : ["1", "Book"]}; - entries.push(new Entry(key1, val1)); - entries.push(new Entry(key2, val2)); + entries.push(new CacheEntry(key1, val1)); + entries.push(new CacheEntry(key2, val2)); ignite.compute().execute(map, reduce, entries, callback); } @@ -362,7 +362,7 @@ function onStart(onPut, error, ignite) { var params = []; for (var i = 900; i < 1000; ++i) { - params.push(new Entry("key" + i, "val" + i)); + params.push(new CacheEntry("key" + i, "val" + i)); } cache.putAll(params, onPut.bind(null, ignite)) @@ -517,8 +517,8 @@ function computeCacheExecute(error, ignite) { var val1 = {"age" : 12, "books" : ["1", "Book"]}; var val2 = {"age" : 13, "books" : ["1", "Book"]}; - entries.push(new Entry(key1, val1)); - entries.push(new Entry(key2, val2)); + entries.push(new CacheEntry(key1, val1)); + entries.push(new CacheEntry(key2, val2)); ignite.cache("mycache").putAll(entries, function(err) { ignite.compute().execute(map, reduce, [key1, val1], callback);