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 11:16:40 UTC

[1/5] incubator-ignite git commit: disable failing test

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-964-1 dc75dd94f -> 4a2d313e6


disable failing test


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b1342ba1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b1342ba1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b1342ba1

Branch: refs/heads/ignite-964-1
Commit: b1342ba19078bd8f742d4d1d605bd9ccc19c82b5
Parents: 334fee9
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Jul 6 10:30:23 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Jul 6 10:30:23 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheAtomicReplicatedNodeRestartSelfTest.java       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b1342ba1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
index 52d8871..c802d7c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
@@ -27,7 +27,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*;
 public class IgniteCacheAtomicReplicatedNodeRestartSelfTest extends GridCacheReplicatedNodeRestartSelfTest {
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-747");
+        //fail("https://issues.apache.org/jira/browse/IGNITE-747");
     }
 
     /** {@inheritDoc} */
@@ -36,6 +36,11 @@ public class IgniteCacheAtomicReplicatedNodeRestartSelfTest extends GridCacheRep
     }
 
     /** {@inheritDoc} */
+    @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1095");
+    }
+
+    /** {@inheritDoc} */
     @Override protected CacheAtomicityMode atomicityMode() {
         return ATOMIC;
     }


[3/5] incubator-ignite git commit: #ignite-1086: ClusterNode.consistentId() should be the same after restart.

Posted by iv...@apache.org.
#ignite-1086: ClusterNode.consistentId() should be the same after restart.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a577d27b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a577d27b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a577d27b

Branch: refs/heads/ignite-964-1
Commit: a577d27b6a857e80d4ddf48a635dce09123eec8a
Parents: 3a4d008
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 6 11:19:00 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 6 11:19:00 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       |  6 +-
 .../TcpDiscoveryNodeConsistentIdSelfTest.java   | 80 ++++++++++++++++++++
 .../IgniteSpiDiscoverySelfTestSuite.java        |  2 +
 3 files changed, 87 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a577d27b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index f457d6c..46a23d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -8048,9 +8048,13 @@ public abstract class IgniteUtils {
     public static String consistentId(Collection<String> addrs, int port) {
         assert !F.isEmpty(addrs);
 
+        List<String> sortedAddrs = new ArrayList<>(addrs);
+
+        Collections.sort(sortedAddrs);
+
         StringBuilder sb = new StringBuilder();
 
-        for (String addr : addrs)
+        for (String addr : sortedAddrs)
             sb.append(addr).append(',');
 
         sb.delete(sb.length() - 1, sb.length());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a577d27b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java
new file mode 100644
index 0000000..d159d72
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.discovery.tcp;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.internal.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+/**
+ * Test for {@link TcpDiscoveryNode#consistentId()}
+ */
+public class TcpDiscoveryNodeConsistentIdSelfTest extends GridCommonAbstractTest {
+    /** IP finder. */
+    private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setLocalHost("0.0.0.0");
+
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startGrids(1);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConsistentId() throws Exception {
+        Object id0 = grid(0).localNode().consistentId();
+
+        int port0 = getDiscoveryPort(grid(0));
+
+        for (int i = 0; i < 10; ++i) {
+            stopAllGrids();
+
+            startGrids(1);
+
+            if (port0 == getDiscoveryPort(grid(0)))
+                assertEquals(id0, grid(0).localNode().consistentId());
+        }
+    }
+
+    /**
+     * @param ignite Ignite.
+     * @return Discovery port.
+     */
+    private int getDiscoveryPort(Ignite ignite) {
+        return ((TcpDiscoveryNode) ignite.cluster().localNode()).discoveryPort();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a577d27b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index ea5a7ac..498f50c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -55,6 +55,8 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(TcpClientDiscoveryMarshallerCheckSelfTest.class));
         suite.addTest(new TestSuite(TcpClientDiscoverySpiMulticastTest.class));
 
+        suite.addTest(new TestSuite(TcpDiscoveryNodeConsistentIdSelfTest.class));
+
         return suite;
     }
 }


[4/5] incubator-ignite git commit: Merge branch 'ignite-sprint-7' into ignite-964-1

Posted by iv...@apache.org.
Merge branch 'ignite-sprint-7' into ignite-964-1


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b4343dcf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b4343dcf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b4343dcf

Branch: refs/heads/ignite-964-1
Commit: b4343dcf186a7d063985d2cf0410e751668f74e8
Parents: dc75dd9 a577d27
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 6 11:35:31 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 6 11:35:31 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       |  6 +-
 ...acheAtomicReplicatedNodeRestartSelfTest.java |  5 ++
 .../TcpDiscoveryNodeConsistentIdSelfTest.java   | 80 ++++++++++++++++++++
 .../IgniteSpiDiscoverySelfTestSuite.java        |  2 +
 4 files changed, 92 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[5/5] incubator-ignite git commit: #ignite-964: add get or create cache to nodejs

Posted by iv...@apache.org.
#ignite-964: add get or create cache to nodejs


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4a2d313e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4a2d313e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4a2d313e

Branch: refs/heads/ignite-964-1
Commit: 4a2d313e6dde7cc85108d690b2dfbdc189ba97a4
Parents: b4343dc
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 6 12:16:29 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 6 12:16:29 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/GridRestCommand.java        |  3 +
 .../handlers/cache/GridCacheCommandHandler.java | 39 +++++++++++
 modules/nodejs/src/main/js/cache.js             | 66 +++++++++++++------
 modules/nodejs/src/main/js/ignite.js            | 13 +++-
 .../ignite/internal/NodeJsCacheApiSelfTest.java |  7 ++
 modules/nodejs/src/test/js/test-cache-api.js    | 68 +++++++++++---------
 .../http/jetty/GridJettyRestHandler.java        | 10 +++
 7 files changed, 155 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
index 81fb7f5..987269c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
@@ -129,6 +129,9 @@ public enum GridRestCommand {
     /** Quit. */
     QUIT("quit"),
 
+    /** Get or create cache. */
+    GET_OR_CREATE_CACHE("getorcreatecache"),
+
     /** Run script. */
     RUN_SCRIPT("runscript"),
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index d7ac3d7..abc195c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -53,6 +53,7 @@ import static org.apache.ignite.transactions.TransactionIsolation.*;
 public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
     /** Supported commands. */
     private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(
+        GET_OR_CREATE_CACHE,
         CACHE_CONTAINS_KEYS,
         CACHE_CONTAINS_KEY,
         CACHE_GET,
@@ -155,6 +156,12 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
             IgniteInternalFuture<GridRestResponse> fut;
 
             switch (cmd) {
+                case GET_OR_CREATE_CACHE: {
+                    fut = ctx.closure().callLocalSafe(new GetOrCreateCacheCallable(ctx, cacheName));
+
+                    break;
+                }
+
                 case CACHE_CONTAINS_KEYS: {
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName, skipStore, key,
                         new ContainsKeysCommand(getKeys(req0)));
@@ -1322,4 +1329,36 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
             return c.sizeAsync(new CachePeekMode[]{CachePeekMode.PRIMARY});
         }
     }
+
+    /**
+     * Map reduce callable.
+     */
+    private static class GetOrCreateCacheCallable implements Callable<GridRestResponse> {
+        /** Kernal context. */
+        private GridKernalContext ctx;
+
+        /** Cache name. */
+        private String cacheName;
+
+        /**
+         * @param ctx Kernal context.
+         * @param cacheName Cache name.
+         */
+        public GetOrCreateCacheCallable(GridKernalContext ctx, String cacheName) {
+            this.ctx = ctx;
+            this.cacheName = cacheName;
+        }
+
+        /** {@inheritDoc} */
+        @Override public GridRestResponse call() throws Exception {
+            try {
+                ctx.grid().getOrCreateCache(cacheName);
+
+                return new GridRestResponse();
+            }
+            catch (Exception e) {
+                return new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage());
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/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 020c71d..67762fd 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -27,10 +27,12 @@ var SqlQuery = require("./sql-query").SqlQuery
  * @this {Cache}
  * @param {Server} server Server class
  * @param {string} cacheName Cache name
+ * @param {boolean} create True if cache is not exist.
  */
-function Cache(server, cacheName) {
+function Cache(server, cacheName, create) {
     this._server = server;
     this._cacheName = cacheName;
+    this._create = create;
 }
 
 /**
@@ -41,7 +43,7 @@ function Cache(server, cacheName) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.get = function(key, callback) {
-    this._server.runCommand(this._createCommand("get").
+    this._runCacheCommand(this._createCommand("get").
         setPostData(JSON.stringify({"key": key})),
         callback);
 };
@@ -55,7 +57,7 @@ Cache.prototype.get = function(key, callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.put = function(key, value, callback) {
-    this._server.runCommand(this._createCommand("put").
+    this._runCacheCommand(this._createCommand("put").
         setPostData(JSON.stringify({"key": key, "val" : value})),
         callback);
 }
@@ -69,7 +71,7 @@ Cache.prototype.put = function(key, value, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.putIfAbsent = function(key, value, callback) {
-    this._server.runCommand(this._createCommand("putifabsent").
+    this._runCacheCommand(this._createCommand("putifabsent").
         setPostData(JSON.stringify({"key": key, "val" : value})),
         callback);
 }
@@ -82,7 +84,7 @@ Cache.prototype.putIfAbsent = function(key, value, callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.remove = function(key, callback) {
-    this._server.runCommand(this._createCommand("rmv").
+    this._runCacheCommand(this._createCommand("rmv").
         setPostData(JSON.stringify({"key": key})),
         callback);
 }
@@ -96,7 +98,7 @@ Cache.prototype.remove = function(key, callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.removeValue = function(key, value, callback) {
-    this._server.runCommand(this._createCommand("rmvvalue").
+    this._runCacheCommand(this._createCommand("rmvvalue").
         setPostData(JSON.stringify({"key": key, "val" : value})),
         callback);
 }
@@ -109,7 +111,7 @@ Cache.prototype.removeValue = function(key, value, callback) {
  * @param {onGet} callback Called on finish with previous value
  */
 Cache.prototype.getAndRemove = function(key, callback) {
-    this._server.runCommand(this._createCommand("getandrmv").
+    this._runCacheCommand(this._createCommand("getandrmv").
         setPostData(JSON.stringify({"key": key})),
         callback);
 }
@@ -122,7 +124,7 @@ Cache.prototype.getAndRemove = function(key, callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.removeAll = function(keys, callback) {
-    this._server.runCommand(this._createCommand("rmvall").
+    this._runCacheCommand(this._createCommand("rmvall").
         setPostData(JSON.stringify({"keys" : keys})),
         callback);
 }
@@ -134,7 +136,7 @@ Cache.prototype.removeAll = function(keys, callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.removeAllFromCache = function(callback) {
-    this._server.runCommand(this._createCommand("rmvall"),
+    this._runCacheCommand(this._createCommand("rmvall"),
         callback);
 }
 
@@ -146,7 +148,7 @@ Cache.prototype.removeAllFromCache = function(callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.putAll = function(entries, callback) {
-    this._server.runCommand(this._createCommand("putall").setPostData(
+    this._runCacheCommand(this._createCommand("putall").setPostData(
         JSON.stringify({"entries" : entries})), callback);
 }
 
@@ -174,7 +176,7 @@ Cache.prototype.getAll = function(keys, callback) {
         callback.call(null, null, result);
     }
 
-    this._server.runCommand(this._createCommand("getall").setPostData(
+    this._runCacheCommand(this._createCommand("getall").setPostData(
         JSON.stringify({"keys" : keys})),
         onGetAll.bind(null, callback));
 }
@@ -187,7 +189,7 @@ Cache.prototype.getAll = function(keys, callback) {
  * @param {Cache~onGetAll} callback Called on finish with boolean result
  */
 Cache.prototype.containsKey = function(key, callback) {
-    this._server.runCommand(this._createCommand("containskey").
+    this._runCacheCommand(this._createCommand("containskey").
         setPostData(JSON.stringify({"key" : key})), callback);
 }
 
@@ -199,7 +201,7 @@ Cache.prototype.containsKey = function(key, callback) {
  * @param {Cache~onGetAll} callback Called on finish with boolean result
  */
 Cache.prototype.containsKeys = function(keys, callback) {
-    this._server.runCommand(this._createCommand("containskeys").
+    this._runCacheCommand(this._createCommand("containskeys").
         setPostData(JSON.stringify({"keys" : keys})), callback);
 }
 
@@ -212,7 +214,7 @@ Cache.prototype.containsKeys = function(keys, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.getAndPut = function(key, val, callback) {
-    this._server.runCommand(this._createCommand("getandput").
+    this._runCacheCommand(this._createCommand("getandput").
         setPostData(JSON.stringify({"key" : key, "val" : val})), callback);
 }
 
@@ -225,7 +227,7 @@ Cache.prototype.getAndPut = function(key, val, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.replace = function(key, val, callback) {
-    this._server.runCommand(this._createCommand("rep").
+    this._runCacheCommand(this._createCommand("rep").
         setPostData(JSON.stringify({"key" : key, "val" : val})), callback);
 }
 
@@ -239,7 +241,7 @@ Cache.prototype.replace = function(key, val, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.replaceValue = function(key, val, oldVal, callback) {
-    this._server.runCommand(this._createCommand("repVal").
+    this._runCacheCommand(this._createCommand("repVal").
         setPostData(JSON.stringify({"key" : key, "val" : val, "oldVal" : oldVal})), callback);
 }
 
@@ -252,7 +254,7 @@ Cache.prototype.replaceValue = function(key, val, oldVal, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.getAndReplace = function(key, val, callback) {
-    this._server.runCommand(this._createCommand("getandreplace").
+    this._runCacheCommand(this._createCommand("getandreplace").
         setPostData(JSON.stringify({"key" : key, "val" : val})), callback);
 }
 
@@ -265,7 +267,7 @@ Cache.prototype.getAndReplace = function(key, val, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.getAndPutIfAbsent = function(key, val, callback) {
-    this._server.runCommand(this._createCommand("getandputifabsent").
+    this._runCacheCommand(this._createCommand("getandputifabsent").
         setPostData(JSON.stringify({"key" : key, "val" : val})), callback);
 }
 
@@ -274,7 +276,7 @@ Cache.prototype.getAndPutIfAbsent = function(key, val, callback) {
  * @param {onGet} callback Called on finish
  */
 Cache.prototype.size = function(callback) {
-    this._server.runCommand(this._createCommand("cachesize"), callback);
+    this._runCacheCommand(this._createCommand("cachesize"), callback);
 }
 
 /**
@@ -317,7 +319,7 @@ Cache.prototype._sqlFieldsQuery = function(qry, onQueryExecute) {
 
     command.setPostData(JSON.stringify({"arg" : qry.arguments()}));
 
-    this._server.runCommand(command, onQueryExecute.bind(this, qry));
+    this._runCacheCommand(command, onQueryExecute.bind(this, qry));
 }
 
 Cache.prototype._sqlQuery = function(qry, onQueryExecute) {
@@ -333,7 +335,7 @@ Cache.prototype._sqlQuery = function(qry, onQueryExecute) {
 
     command.setPostData(JSON.stringify({"arg" : qry.arguments()}));
 
-    this._server.runCommand(command, onQueryExecute.bind(this, qry));
+    this._runCacheCommand(command, onQueryExecute.bind(this, qry));
 }
 
 Cache.prototype._createCommand = function(name) {
@@ -350,6 +352,28 @@ Cache.prototype._createQueryCommand = function(name, qry) {
     return command.addParam("psz", qry.pageSize());
 }
 
+Cache.prototype._runCacheCommand = function(command, callback) {
+    console.log("RUNCACHECOMMAND create:" + this._create);
+    if (this._create) {
+        var onCreateCallback = function(command, callback, err) {
+            if (err !== null) {
+                callback.call(null, err, null);
+
+                return;
+            }
+
+            this._create = false;
+
+            this._server.runCommand(command, callback);
+        }
+
+        this._server.runCommand(this._createCommand("getorcreatecache"),
+            onCreateCallback.bind(this, command, callback));
+    }
+    else {
+        this._server.runCommand(command, callback);
+    }
+}
 /**
  * @this{Entry}
  * @param key Key

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/modules/nodejs/src/main/js/ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/ignite.js b/modules/nodejs/src/main/js/ignite.js
index dde259e..fea34f9 100644
--- a/modules/nodejs/src/main/js/ignite.js
+++ b/modules/nodejs/src/main/js/ignite.js
@@ -48,7 +48,18 @@ Ignite.prototype.server = function() {
  * @returns {Cache} Cache
  */
 Ignite.prototype.cache = function(cacheName) {
-    return new Cache(this._server, cacheName);
+    return new Cache(this._server, cacheName, false);
+}
+
+/**
+ * Get or create an instance of cache
+ *
+ * @this {Ignite}
+ * @param {string} Cache name
+ * @returns {Cache} Cache
+ */
+Ignite.prototype.getOrCreateCache = function(cacheName) {
+    return new Cache(this._server, cacheName, true);
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
index 3123c13..cd55500 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java
@@ -67,6 +67,13 @@ public class NodeJsCacheApiSelfTest extends NodeJsAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testGetOrCreateCacheName() throws Exception {
+        runJsScript("testGetOrCreateCacheName");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testRemove() throws Exception {
         runJsScript("testRemove");
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/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 dcf465a..98a382f 100644
--- a/modules/nodejs/src/test/js/test-cache-api.js
+++ b/modules/nodejs/src/test/js/test-cache-api.js
@@ -23,58 +23,62 @@ var Entry = Ignite.Entry;
 var assert = require("assert");
 
 testPutGet = function() {
-    startTest("mycache", {trace: [put, getExist], entry: ["key" , "6"]});
+    startTest(false, "mycache", {trace: [put, getExist], entry: ["key" , "6"]});
 }
 
 testPutGetObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest("mycache", {trace: [put, getExist], entry: [key , val]});
+    startTest(false, "mycache", {trace: [put, getExist], entry: [key , val]});
 }
 
 testPutContains = function() {
-    startTest("mycache", {trace: [put, containsKey], entry: ["key" , "6"]});
+    startTest(false, "mycache", {trace: [put, containsKey], entry: ["key" , "6"]});
 }
 
 testContains = function() {
-    startTest("mycache", {trace: [notContainsKey], entry: ["key" , "6"]});
+    startTest(false, "mycache", {trace: [notContainsKey], entry: ["key" , "6"]});
 }
 
 testPutContainsAll = function() {
-    startTest("mycache", {trace: [putAll, containsKeys], entry: objectEntries()});
+    startTest(false, "mycache", {trace: [putAll, containsKeys], entry: objectEntries()});
 }
 
 testNotContainsAll = function() {
-    startTest("mycache", {trace: [notContainsKeys], entry: stringEntries()});
+    startTest(false, "mycache", {trace: [notContainsKeys], entry: stringEntries()});
 }
 
 testRemove = function() {
-    startTest("mycache", {trace: [put, getExist, remove, getNonExist], entry: ["key" , "6"]});
+    startTest(false, "mycache", {trace: [put, getExist, remove, getNonExist], entry: ["key" , "6"]});
 }
 
 testRemoveNoKey = function() {
-    startTest("mycache", {trace: [remove, getNonExist], entry: ["key" , "6"]});
+    startTest(false, "mycache", {trace: [remove, getNonExist], entry: ["key" , "6"]});
 }
 
 testPutAllGetAll = function() {
-    startTest("mycache", {trace: [putAll, getAll], entry: stringEntries()});
+    startTest(false, "mycache", {trace: [putAll, getAll], entry: stringEntries()});
 }
 
 testPutAllObjectGetAll = function() {
-    startTest("mycache", {trace: [putAll, getAll], entry: objectEntries()});
+    startTest(false, "mycache", {trace: [putAll, getAll], entry: objectEntries()});
 }
 
 testRemoveAllObjectGetAll = function() {
-    startTest("mycache", {trace: [putAll, getAll, removeAll, getNone], entry: objectEntries()});
+    startTest(false, "mycache", {trace: [putAll, getAll, removeAll, getNone], entry: objectEntries()});
 }
 
 testRemoveAll = function() {
-    startTest("mycache", {trace: [putAll, getAll, removeAll, getNone], entry: stringEntries()});
+    startTest(false, "mycache", {trace: [putAll, getAll, removeAll, getNone], entry: stringEntries()});
 }
 
 testIncorrectCacheName = function() {
-    startTest("mycache1", {trace: [incorrectPut], entry: ["key", "6"]});
+    startTest(false, "mycache1", {trace: [incorrectPut], entry: ["key", "6"]});
+}
+
+testGetOrCreateCacheName = function() {
+    startTest(true, "mycache2", {trace: [put, getExist], entry: ["key", "6"]});
 }
 
 testGetAndPut = function() {
@@ -89,7 +93,7 @@ testGetAndPut = function() {
         cache.getAndPut("key", "7", onGetAndPut);
     }
 
-    startTest("mycache", {trace: [put, getAndPut], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, getAndPut], entry: ["key", "6"]});
 }
 
 testGetAndPutIfAbsent = function() {
@@ -104,7 +108,7 @@ testGetAndPutIfAbsent = function() {
         }
     }
 
-    startTest("mycache", {trace: [put, getAndPutIfAbsent, getExist], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, getAndPutIfAbsent, getExist], entry: ["key", "6"]});
 }
 
 testPutIfAbsent = function() {
@@ -119,7 +123,7 @@ testPutIfAbsent = function() {
         }
     }
 
-    startTest("mycache", {trace: [put, putIfAbsent, getExist], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, putIfAbsent, getExist], entry: ["key", "6"]});
 }
 
 testRemoveValue = function() {
@@ -134,7 +138,7 @@ testRemoveValue = function() {
         }
     }
 
-    startTest("mycache", {trace: [put, removeValue, getExist], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, removeValue, getExist], entry: ["key", "6"]});
 }
 
 testGetAndRemove = function() {
@@ -149,7 +153,7 @@ testGetAndRemove = function() {
         }
     }
 
-    startTest("mycache", {trace: [put, getAndRemove, getNone], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, getAndRemove, getNone], entry: ["key", "6"]});
 }
 
 testRemoveAllFromCache = function() {
@@ -157,7 +161,7 @@ testRemoveAllFromCache = function() {
         cache.removeAllFromCache(next);
     }
 
-    startTest("mycache", {trace: [put, removeAllFromCache, getNone], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, removeAllFromCache, getNone], entry: ["key", "6"]});
 }
 
 testReplace = function() {
@@ -176,7 +180,7 @@ testReplace = function() {
         }
     }
 
-    startTest("mycache", {trace: [put, replace], entry: ["key", "6"]});
+    startTest(false, "mycache", {trace: [put, replace], entry: ["key", "6"]});
 }
 
 testReplaceObject = function() {
@@ -200,7 +204,7 @@ testReplaceObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest("mycache", {trace: [put, replace], entry: [key, val]});
+    startTest(false, "mycache", {trace: [put, replace], entry: [key, val]});
 }
 
 testGetAndReplaceObject = function() {
@@ -219,7 +223,7 @@ testGetAndReplaceObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest("mycache", {trace: [put, getAndReplace], entry: [key, val]});
+    startTest(false, "mycache", {trace: [put, getAndReplace], entry: [key, val]});
 }
 
 testReplaceValueObject = function() {
@@ -237,7 +241,7 @@ testReplaceValueObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest("mycache", {trace: [put, replaceValue], entry: [key, val]});
+    startTest(false, "mycache", {trace: [put, replaceValue], entry: [key, val]});
 }
 
 testIncorrectReplaceObject = function() {
@@ -254,7 +258,7 @@ testIncorrectReplaceObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest("mycache", {trace: [put, replace], entry: [key, val]});
+    startTest(false, "mycache", {trace: [put, replace], entry: [key, val]});
 }
 
 testSize = function() {
@@ -276,7 +280,7 @@ testSize = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest("mycache", {trace: [size0, put, size1], entry: [key, val]});
+    startTest(false, "mycache", {trace: [size0, put, size1], entry: [key, val]});
 }
 
 function objectEntries() {
@@ -302,12 +306,18 @@ function stringEntries() {
     return entries;
 }
 
-function startTest(cacheName, testDescription) {
-    TestUtils.startIgniteNode(onStart.bind(null, cacheName, testDescription));
+function startTest(createCache, cacheName, testDescription) {
+    TestUtils.startIgniteNode(onStart.bind(null, createCache, cacheName, testDescription));
 }
 
-function onStart(cacheName, testDescription, error, ignite) {
-    var cache = ignite.cache(cacheName);
+function onStart(createCache, cacheName, testDescription, error, ignite) {
+    var cache;
+    if (createCache) {
+        cache = ignite.getOrCreateCache(cacheName);
+    }
+    else {
+        cache = ignite.cache(cacheName);
+    }
     callNext();
 
     function callNext(error) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a2d313e/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 7ad2a15..13917f8 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -360,6 +360,16 @@ public class GridJettyRestHandler extends AbstractHandler {
         GridRestRequest restReq;
 
         switch (cmd) {
+            case GET_OR_CREATE_CACHE: {
+                GridRestCacheRequest restReq0 = new GridRestCacheRequest();
+
+                restReq0.cacheName((String)params.get("cacheName"));
+
+                restReq = restReq0;
+
+                break;
+            }
+
             case ATOMIC_DECREMENT:
             case ATOMIC_INCREMENT: {
                 DataStructuresRequest restReq0 = new DataStructuresRequest();


[2/5] incubator-ignite git commit: disable failing test

Posted by iv...@apache.org.
disable failing test


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3a4d008b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3a4d008b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3a4d008b

Branch: refs/heads/ignite-964-1
Commit: 3a4d008b07ec9971e229e5bdb99bab38858634e5
Parents: b1342ba
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Jul 6 10:32:06 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Jul 6 10:32:06 2015 +0300

----------------------------------------------------------------------
 .../replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a4d008b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
index c802d7c..54409d1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheAtomicReplicatedNodeRestartSelfTest.java
@@ -27,7 +27,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*;
 public class IgniteCacheAtomicReplicatedNodeRestartSelfTest extends GridCacheReplicatedNodeRestartSelfTest {
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        //fail("https://issues.apache.org/jira/browse/IGNITE-747");
+        fail("https://issues.apache.org/jira/browse/IGNITE-747");
     }
 
     /** {@inheritDoc} */