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:44 UTC
[5/5] incubator-ignite git commit: #ignite-964: add get or create
cache to nodejs
#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();