You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2015/07/06 12:25:21 UTC
incubator-ignite git commit: #ignite-964: add cache-put-get-example.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-964-1 4a2d313e6 -> fd4cb53eb
#ignite-964: add cache-put-get-example.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/fd4cb53e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/fd4cb53e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/fd4cb53e
Branch: refs/heads/ignite-964-1
Commit: fd4cb53ebec2c190a9c7711de0be9cbe512bef6a
Parents: 4a2d313
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 6 13:25:03 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 6 13:25:03 2015 +0300
----------------------------------------------------------------------
.../processors/rest/GridRestProcessor.java | 4 -
modules/nodejs/src/main/js/cache.js | 1 -
.../main/js/examples/config/example-ignite.xml | 89 ++++++++++++++++++++
.../src/main/js/examples/config/rest-jetty.xml | 71 ++++++++++++++++
.../js/examples/src/cache-put-get-example.js | 72 ++++++++++++++++
.../ignite/examples/ExampleNodeStartup.java | 36 ++++++++
modules/nodejs/src/main/js/server.js | 2 +-
7 files changed, 269 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fd4cb53e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index 49120ed..df2304a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -59,10 +59,6 @@ public class GridRestProcessor extends GridProcessorAdapter {
private static final String HTTP_PROTO_CLS =
"org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyRestProtocol";
- /** HTTP protocol class name. */
- private static final String HTTP_SCRIPTING_CLS =
- "org.apache.ignite.internal.processors.rest.protocols.http.jetty.IgniteScriptingCommandHandler";
-
/** */
public static final byte[] ZERO_BYTES = new byte[0];
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fd4cb53e/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 67762fd..93ded2d 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -353,7 +353,6 @@ Cache.prototype._createQueryCommand = function(name, qry) {
}
Cache.prototype._runCacheCommand = function(command, callback) {
- console.log("RUNCACHECOMMAND create:" + this._create);
if (this._create) {
var onCreateCallback = function(command, callback, err) {
if (err !== null) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fd4cb53e/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
new file mode 100644
index 0000000..fd76bcf
--- /dev/null
+++ b/modules/nodejs/src/main/js/examples/config/example-ignite.xml
@@ -0,0 +1,89 @@
+<?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="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/fd4cb53e/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
new file mode 100644
index 0000000..abc146b
--- /dev/null
+++ b/modules/nodejs/src/main/js/examples/config/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/fd4cb53e/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
new file mode 100644
index 0000000..e89570a
--- /dev/null
+++ b/modules/nodejs/src/main/js/examples/src/cache-put-get-example.js
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+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("mycache");
+
+ 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++;
+ }
+
+ 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);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fd4cb53e/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
new file mode 100644
index 0000000..1578c18
--- /dev/null
+++ b/modules/nodejs/src/main/js/examples/src/org/apache/ignite/examples/ExampleNodeStartup.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;
+
+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/fd4cb53e/modules/nodejs/src/main/js/server.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/server.js b/modules/nodejs/src/main/js/server.js
index ee1a134..abe24a7 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -121,7 +121,7 @@ Server.prototype.runCommand = function(cmd, callback) {
var request = http.request(options, streamCallback);
- request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
+ request.setTimeout(20000, callback.bind(null, "Request timeout: >5 sec"));
request.on('error', callback);