#ignite-964: renaming.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/38239701 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/38239701 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/38239701 Branch: refs/heads/ignite-961 Commit: 38239701076ad8e1938910e057643b32fec1dffe Parents: 06d3a29 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Fri Jul 10 12:57:55 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Fri Jul 10 12:57:55 2015 +0300 ---------------------------------------------------------------------- .../ignite/internal/GridKernalContext.java | 2 +- .../ignite/internal/GridKernalContextImpl.java | 8 +- .../apache/ignite/internal/IgniteKernal.java | 2 +- .../IgniteScriptingCommandHandler.java | 14 +- .../rest/handlers/scripting/NodeJSIgnite.java | 65 ----- .../rest/handlers/scripting/NodeJsCache.java | 259 ------------------ .../handlers/scripting/NodeJsClusterNode.java | 42 --- .../rest/handlers/scripting/RestEntry.java | 57 ---- .../handlers/scripting/RestJSONCacheObject.java | 166 ------------ .../scripting/ScriptingJSONCacheObject.java | 166 ++++++++++++ .../scripting/IgniteScriptProcessor.java | 147 ----------- .../scripting/IgniteScriptingProcessor.java | 147 +++++++++++ .../processors/scripting/JSONCacheObject.java | 108 -------- .../scripting/ScriptingCacheEntry.java | 59 +++++ .../scripting/ScriptingClusterNode.java | 42 +++ .../processors/scripting/ScriptingJSIgnite.java | 65 +++++ .../processors/scripting/ScriptingJsCache.java | 260 +++++++++++++++++++ .../org/apache/ignite/json/JSONCacheObject.java | 108 ++++++++ .../ignite/internal/NodeJsCacheApiSelfTest.java | 227 ---------------- .../internal/ScriptingJsCacheApiSelfTest.java | 227 ++++++++++++++++ .../testsuites/IgniteNodeJsTestSuite.java | 2 +- .../http/jetty/GridJettyRestHandler.java | 9 +- 22 files changed, 1090 insertions(+), 1092 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index 16615fa..dad144c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -240,7 +240,7 @@ public interface GridKernalContext extends Iterable<GridComponent> { * * @return Scripting processor. */ - public IgniteScriptProcessor scripting(); + public IgniteScriptingProcessor scripting(); /** * Gets segmentation processor. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index 5f8ba6c..caa34a8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -199,7 +199,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable /** */ @GridToStringInclude - private IgniteScriptProcessor scriptProc; + private IgniteScriptingProcessor scriptProc; /** */ @GridToStringInclude @@ -482,8 +482,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable dataStructuresProc = (DataStructuresProcessor)comp; else if (comp instanceof ClusterProcessor) cluster = (ClusterProcessor)comp; - else if (comp instanceof IgniteScriptProcessor) - scriptProc = (IgniteScriptProcessor) comp; + else if (comp instanceof IgniteScriptingProcessor) + scriptProc = (IgniteScriptingProcessor) comp; else if (!(comp instanceof DiscoveryNodeValidationProcessor)) assert (comp instanceof GridPluginComponent) : "Unknown manager class: " + comp.getClass(); @@ -664,7 +664,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable } /** {@inheritDoc} */ - @Override public IgniteScriptProcessor scripting() { + @Override public IgniteScriptingProcessor scripting() { return scriptProc; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 1de6f5a..6fab5f9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -776,7 +776,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { startProcessor(new GridTaskProcessor(ctx)); startProcessor((GridProcessor)SCHEDULE.createOptional(ctx)); startProcessor(new GridRestProcessor(ctx)); - startProcessor(new IgniteScriptProcessor(ctx)); + startProcessor(new IgniteScriptingProcessor(ctx)); startProcessor(new DataStreamProcessor(ctx)); startProcessor((GridProcessor)IGFS.create(ctx, F.isEmpty(cfg.getFileSystemConfiguration()))); startProcessor(new GridContinuousProcessor(ctx)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/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 d3f26da..8469e1c 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 @@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.scripting.*; import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.json.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; @@ -57,23 +58,16 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter super(ctx); try { - IgniteScriptProcessor script = ctx.scripting(); + IgniteScriptingProcessor script = ctx.scripting(); String emitFunction = "function emit(f, args, nodeId) {" + "__emitResult.add(f.toString(), args, nodeId);}"; script.addEngineFunction(emitFunction); - String entryFunction = "CacheEntry = function(key, val) {" + - "this.key = key; this.value = val}"; - - script.addEngineFunction(entryFunction); - emitRes = new IgniteJsEmitResult(); script.addBinding("__emitResult", emitRes); - - script.addBinding("ignite", new NodeJSIgnite(ctx.grid())); } catch (IgniteCheckedException e) { ctx.log().error(e.getMessage()); @@ -102,7 +96,7 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter case AFFINITY_RUN_SCRIPT: { assert req instanceof RestRunScriptRequest : "Invalid type of run script request."; - return ctx.closure().callLocalSafe(new AffinityRunScriptCallable(ctx, (RestRunScriptRequest)req)); + return ctx.closure().callLocalSafe(new AffinityRunScriptCallable(ctx, (RestRunScriptRequest) req)); } case EXECUTE_MAP_REDUCE_SCRIPT: { @@ -220,7 +214,7 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter public JsCallFunctionJob(String func, Object argv) { this.func = func; - this.argv = RestJSONCacheObject.convertToRestObject( + this.argv = ScriptingJSONCacheObject.convertToRestObject( JSONCacheObject.toSimpleObject(argv)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJSIgnite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJSIgnite.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJSIgnite.java deleted file mode 100644 index 3e1ef4e..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJSIgnite.java +++ /dev/null @@ -1,65 +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.internal.processors.rest.handlers.scripting; - -import org.apache.ignite.*; - -/** - * Node js ignite. - */ -public class NodeJSIgnite { - /** Ignite. */ - private Ignite ignite; - - /** - * @param ignite Ignite. - */ - public NodeJSIgnite(Ignite ignite) { - this.ignite = ignite; - } - - /** - * @param cache Cache name. - * @return Node js cache. - */ - public NodeJsCache cache(String cache) { - return new NodeJsCache(ignite.cache(cache)); - } - - /** - * @param cache Cache name. - * @return Node js cache. - */ - public NodeJsCache getOrCreateCache(String cache) { - return new NodeJsCache(ignite.getOrCreateCache(cache)); - } - - /** - * @return Local node. - */ - public NodeJsClusterNode localNode() { - return new NodeJsClusterNode(ignite.cluster().localNode()); - } - - /** - * @return Ignite name. - */ - public String name() { - return ignite.name(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsCache.java deleted file mode 100644 index 5c21e28..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsCache.java +++ /dev/null @@ -1,259 +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.internal.processors.rest.handlers.scripting; - -import org.apache.ignite.*; -import org.apache.ignite.internal.processors.scripting.*; -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.util.*; - -/** - * Node js cache. - */ -public class NodeJsCache { - /** Ignite cache. */ - private IgniteCache<Object, Object> cache; - - /** - * @param cache Ignite cache. - */ - public NodeJsCache(IgniteCache cache) { - this.cache = cache; - } - - /** - * @param key Key. - * @param val Value. - */ - public void put(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - cache.put(cacheKey, cacheVal); - } - - /** - * @param key Key. - */ - public Object get(Object key) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - - return RestJSONCacheObject.convertToRestObject(cache.get(cacheKey)); - } - - /** - * @param key Key - * @return True if cache contains key. - */ - public boolean containsKey(Object key) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - - return cache.containsKey(cacheKey); - } - - /** - * @param keys Keys - * @return True if cache contains key. - */ - public boolean containsKeys(List keys) { - List<Object> cacheKeys = (List<Object>)JSONCacheObject.toSimpleObject(keys); - - return cache.containsKeys(new HashSet<>(cacheKeys)); - } - - /** - * @param keys Keys. - * @return Cache entries. - */ - public List<RestEntry> getAll(List keys) { - List cacheKeys = (List)JSONCacheObject.toSimpleObject(keys); - - Map<Object, Object> entries = cache.getAll(new HashSet<>(cacheKeys)); - - List<RestEntry> res = new ArrayList<>(); - - for (Map.Entry<Object, Object> e : entries.entrySet()) - res.add(new RestEntry( - RestJSONCacheObject.convertToRestObject(e.getKey()), - RestJSONCacheObject.convertToRestObject(e.getValue()))); - - return res; - } - - /** - * @param keys Keys. - */ - public void removeAll(List keys) { - List cacheKeys = (List)JSONCacheObject.toSimpleObject(keys); - - cache.removeAll(new HashSet<>(cacheKeys)); - } - - /** - * @param entries Entries. - */ - public void putAll(List entries) { - List cacheKeys = (List)JSONCacheObject.toSimpleObject(entries); - - Map<Object, Object> cacheEntries = U.newHashMap(entries.size()); - - for (Object e : cacheKeys) { - JSONCacheObject e0 = (JSONCacheObject)e; - cacheEntries.put(e0.getField("key"), e0.getField("value")); - } - - cache.putAll(cacheEntries); - } - - /** - * @param key Key. - * @param val Value. - * @return Previous value. - */ - public Object getAndPut(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - return RestJSONCacheObject.convertToRestObject(cache.getAndPut(cacheKey, cacheVal)); - } - - /** - * @param key Key. - * @param val Value. - * @return Previous value. - */ - public Object getAndReplace(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - Object o = RestJSONCacheObject.convertToRestObject(cache.getAndReplace(cacheKey, cacheVal)); - - return o; - } - - /** - * @param key Key. - * @param val Value. - * @return Previous value. - */ - public Object getAndPutIfAbsent(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - return RestJSONCacheObject.convertToRestObject(cache.getAndPutIfAbsent(cacheKey, cacheVal)); - } - - /** - * @param key Key. - * @return Previous value. - */ - public Object getAndRemove(Object key) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - - return RestJSONCacheObject.convertToRestObject(cache.getAndRemove(cacheKey)); - } - - /** - * @param key Key. - * @return If operation success. - */ - public boolean remove(Object key) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - - return cache.remove(cacheKey); - } - - /** - * @param key Key. - * @param val Value. - * @return If operation success. - */ - public boolean removeValue(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - return cache.remove(cacheKey, cacheVal); - } - - /** - * @param key Key. - * @param val Value. - * @return If operation success. - */ - public boolean replace(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - return cache.replace(cacheKey, cacheVal); - } - - /** - * @param key Key. - * @param val Value. - * @param oldVal Old value. - * @return If operation success. - */ - public boolean replaceValue(Object key, Object val, Object oldVal) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - Object oldCacheVal = JSONCacheObject.toSimpleObject(oldVal); - - return cache.replace(cacheKey, oldCacheVal, cacheVal); - } - - /** - * Removes all from cache. - */ - public void removeAllFromCache() { - cache.removeAll(); - } - - /** - * @param key Key. - * @param val Value. - * @return Previous value. - */ - public Object putIfAbsent(Object key, Object val) { - Object cacheKey = JSONCacheObject.toSimpleObject(key); - Object cacheVal = JSONCacheObject.toSimpleObject(val); - - return cache.putIfAbsent(cacheKey, cacheVal); - } - - /** - * @return Cache name. - */ - public String getName() { - return cache.getName(); - } - - /** - * @return Local size. - */ - public int localSize() { - return cache.localSize(); - } - - /** - * @return Size. - */ - public int size() { - return cache.size(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsClusterNode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsClusterNode.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsClusterNode.java deleted file mode 100644 index fb513fb..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/NodeJsClusterNode.java +++ /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. - */ - -package org.apache.ignite.internal.processors.rest.handlers.scripting; - -import org.apache.ignite.cluster.*; - -/** - * Node js cluster node. - */ -public class NodeJsClusterNode { - /** Cluster node. */ - private String id; - - /** - * @param node Cluster node. - */ - public NodeJsClusterNode(ClusterNode node) { - this.id = node.id().toString(); - } - - /** - * @return Node id. - */ - public String id() { - return id; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestEntry.java deleted file mode 100644 index c4f9fd1..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestEntry.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.apache.ignite.internal.processors.rest.handlers.scripting; - - -/** - * Rest entry. - */ -public class RestEntry { - /** Key. */ - private Object key; - - /** Value. */ - private Object val; - - /** - * @param key Key. - * @param val Value. - */ - public RestEntry(Object key, Object val) { - if (key instanceof RestJSONCacheObject) - this.key = ((RestJSONCacheObject)key).getFields(); - else - this.key = key; - - if (val instanceof RestJSONCacheObject) - this.val = ((RestJSONCacheObject)val).getFields(); - else - this.val = val; - } - - /** - * @return Key. - */ - public Object getKey() { - return key; - } - - /** - * @param key Key. - */ - public void setKey(Object key) { - this.key = key; - } - - /** - * @return Value. - */ - public Object getValue() { - return val; - } - - /** - * @param val Value. - */ - public void setValue(Object val) { - this.val = val; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestJSONCacheObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestJSONCacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestJSONCacheObject.java deleted file mode 100644 index 3bb615c..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/RestJSONCacheObject.java +++ /dev/null @@ -1,166 +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.internal.processors.rest.handlers.scripting; - -import jdk.nashorn.api.scripting.*; -import org.apache.ignite.internal.processors.scripting.*; -import org.apache.ignite.internal.util.typedef.internal.U; - -import java.util.*; - -/** - * Json cache object. - */ -public class RestJSONCacheObject implements JSObject { - /** Fields. */ - private final JSONCacheObject fields; - - /** - * @param o JSON object. - */ - private RestJSONCacheObject(JSONCacheObject o) { - fields = o; - } - - /** - * @param o Object. - * @return Rest JSON cache object. - */ - public static Object convertToRestObject(Object o) { - if (o instanceof JSONCacheObject) - return new RestJSONCacheObject((JSONCacheObject)o); - - return o; - } - - /** - * @return Fields. - */ - public Map<Object, Object> getFields() { - return fields; - } - - /** - * @param key Field name. - * @return Field value. - */ - public Object getField(Object key) { - return fields.get(key); - } - - @Override public Object call(Object o, Object... objects) { - System.out.println("!!!!CALL"); - return null; - } - - @Override public Object newObject(Object... objects) { - System.out.println("!!!!newObject"); - return null; - } - - @Override public Object eval(String s) { - System.out.println("!!!!eval"); - return null; - } - - @Override public Object getMember(String s) { - System.out.println("!!!!getMember + " + s); - return fields.get(s); - } - - @Override public Object getSlot(int i) { - System.out.println("!!!!getSlot"); - return null; - } - - @Override public boolean hasMember(String s) { - System.out.println("!!!!hasMember"); - return fields.containsKey(s); - } - - @Override public boolean hasSlot(int i) { - System.out.println("!!!!hasSlot"); - return false; - } - - @Override public void removeMember(String s) { - System.out.println("!!!!removeMember"); - fields.remove(s); - } - - @Override public void setMember(String s, Object o) { - System.out.println("!!!!setMember"); - fields.put(s, o); - } - - @Override public void setSlot(int i, Object o) { - System.out.println("!!!!setSlot"); - - } - - @Override public Set<String> keySet() { - System.out.println("!!!!keySet"); - Set<String> keys = new HashSet<>(); - - for (Object o : fields.keySet()) { - if (!(o instanceof RestJSONCacheObject)) - keys.add(o.toString()); - } - - return keys; - } - - @Override public Collection<Object> values() { - System.out.println("!!!!values"); - return fields.values(); - } - - @Override public boolean isInstance(Object o) { - System.out.println("!!!!isInstance"); - return false; - } - - @Override public boolean isInstanceOf(Object o) { - System.out.println("!!!!isInstanceOf"); - return false; - } - - @Override public String getClassName() { - System.out.println("!!!!getClassName"); - return U.getSimpleName(RestJSONCacheObject.class); - } - - @Override public boolean isFunction() { - System.out.println("!!!!isFunction"); - return false; - } - - @Override public boolean isStrictFunction() { - System.out.println("!!!!isStrictFunction"); - return false; - } - - @Override public boolean isArray() { - System.out.println("!!!!isArray"); - return false; - } - - @Override public double toNumber() { - return 0; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/ScriptingJSONCacheObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/ScriptingJSONCacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/ScriptingJSONCacheObject.java new file mode 100644 index 0000000..8d446ba --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/ScriptingJSONCacheObject.java @@ -0,0 +1,166 @@ +/* + * 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.internal.processors.rest.handlers.scripting; + +import jdk.nashorn.api.scripting.*; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.json.*; + +import java.util.*; + +/** + * Json cache object. + */ +public class ScriptingJSONCacheObject implements JSObject { + /** Fields. */ + private final JSONCacheObject fields; + + /** + * @param o JSON object. + */ + private ScriptingJSONCacheObject(JSONCacheObject o) { + fields = o; + } + + /** + * @param o Object. + * @return Rest JSON cache object. + */ + public static Object convertToRestObject(Object o) { + if (o instanceof JSONCacheObject) + return new ScriptingJSONCacheObject((JSONCacheObject)o); + + return o; + } + + /** + * @return Fields. + */ + public Map<Object, Object> getFields() { + return fields; + } + + /** + * @param key Field name. + * @return Field value. + */ + public Object getField(Object key) { + return fields.get(key); + } + + @Override public Object call(Object o, Object... objects) { + System.out.println("!!!!CALL"); + return null; + } + + @Override public Object newObject(Object... objects) { + System.out.println("!!!!newObject"); + return null; + } + + @Override public Object eval(String s) { + System.out.println("!!!!eval"); + return null; + } + + @Override public Object getMember(String s) { + System.out.println("!!!!getMember + " + s); + return fields.get(s); + } + + @Override public Object getSlot(int i) { + System.out.println("!!!!getSlot"); + return null; + } + + @Override public boolean hasMember(String s) { + System.out.println("!!!!hasMember"); + return fields.containsKey(s); + } + + @Override public boolean hasSlot(int i) { + System.out.println("!!!!hasSlot"); + return false; + } + + @Override public void removeMember(String s) { + System.out.println("!!!!removeMember"); + fields.remove(s); + } + + @Override public void setMember(String s, Object o) { + System.out.println("!!!!setMember"); + fields.put(s, o); + } + + @Override public void setSlot(int i, Object o) { + System.out.println("!!!!setSlot"); + + } + + @Override public Set<String> keySet() { + System.out.println("!!!!keySet"); + Set<String> keys = new HashSet<>(); + + for (Object o : fields.keySet()) { + if (!(o instanceof ScriptingJSONCacheObject)) + keys.add(o.toString()); + } + + return keys; + } + + @Override public Collection<Object> values() { + System.out.println("!!!!values"); + return fields.values(); + } + + @Override public boolean isInstance(Object o) { + System.out.println("!!!!isInstance"); + return false; + } + + @Override public boolean isInstanceOf(Object o) { + System.out.println("!!!!isInstanceOf"); + return false; + } + + @Override public String getClassName() { + System.out.println("!!!!getClassName"); + return U.getSimpleName(ScriptingJSONCacheObject.class); + } + + @Override public boolean isFunction() { + System.out.println("!!!!isFunction"); + return false; + } + + @Override public boolean isStrictFunction() { + System.out.println("!!!!isStrictFunction"); + return false; + } + + @Override public boolean isArray() { + System.out.println("!!!!isArray"); + return false; + } + + @Override public double toNumber() { + return 0; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java deleted file mode 100644 index 1f6dfbc..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java +++ /dev/null @@ -1,147 +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.internal.processors.scripting; - -import org.apache.ignite.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.*; - -import javax.script.*; - -import static javax.script.ScriptContext.*; - -/** - * Ignite scripting processor. - */ -public class IgniteScriptProcessor extends GridProcessorAdapter { - /** Javascript engine name. */ - public static final String JAVA_SCRIPT_ENGINE_NAME = "nashorn"; - - /** Javascript engine. */ - private ScriptEngine jsEngine; - - /** - * @param ctx Kernal context. - */ - public IgniteScriptProcessor(GridKernalContext ctx) { - super(ctx); - } - - /** {@inheritDoc} */ - @Override public void start() throws IgniteCheckedException { - ScriptEngineManager factory = new ScriptEngineManager(); - - jsEngine = factory.getEngineByName(JAVA_SCRIPT_ENGINE_NAME); - - Bindings bind = jsEngine.createBindings(); - - bind.put("ignite", ctx.grid()); - - jsEngine.setBindings(bind, ENGINE_SCOPE); - - String createJSFunction = "function __createJSFunction(mapFunc) {" + - "return eval('(function() { return ' + mapFunc.trim() + '})()'); }"; - - String internalCall = "function __internalCall(funcSource, arg1, arg2) { " + - "var func = __createJSFunction(funcSource); " + - "return func.apply(null, [arg1, arg2]); }"; - - String internalJSCall = "function __internalJSCall(funcSource, arg1, arg2) { " + - "var func = __createJSFunction(funcSource); " + - "return func.apply(null, [JSON.parse(arg1), arg2]); }"; - - addEngineFunction(createJSFunction); - addEngineFunction(internalCall); - addEngineFunction(internalJSCall); - } - - /** - * Add function to scope. - * - * @param script Function script. - * @throws IgniteCheckedException If script failed. - */ - public void addEngineFunction(String script) throws IgniteCheckedException { - try { - jsEngine.eval(script); - } - catch (ScriptException e) { - throw new IgniteCheckedException("Script evaluation failed [script=" + script + "].", e); - } - } - - /** - * Add binding. - * - * @param name Binding name. - * @param o Object to bind. - */ - public void addBinding(String name, Object o) { - Bindings b = jsEngine.getBindings(ENGINE_SCOPE); - - b.put(name, o); - - jsEngine.setBindings(b, ENGINE_SCOPE); - } - - /** - * @param src Script src. - * @return Result of the function. - * @throws IgniteCheckedException If script failed. - */ - public Object invokeFunction(String src) throws IgniteCheckedException { - try { - return jsEngine.eval("(" + src + ")()"); - } - catch (ScriptException e) { - throw new IgniteCheckedException("Function evaluation failed [funcName=" + src + "]."); - } - } - - /** - * @param src Script src. - * @param arg Argument. - * @return Result of the function. - * @throws IgniteCheckedException If script failed. - */ - public Object invokeFunction(String src, Object arg) throws IgniteCheckedException { - return invokeFunction(src, arg, null); - } - - /** - * @param src Script src. - * @param arg Argument. - * @return Result of the function. - * @throws IgniteCheckedException If script failed. - */ - public Object invokeFunction(String src, Object arg, Object arg2) throws IgniteCheckedException { - try { - Invocable invocable = (Invocable) jsEngine; - - return invocable.invokeFunction("__internalCall", src, arg, arg2); - } - catch (ScriptException e) { - throw new IgniteCheckedException("Function evaluation failed [funcName=" + src + - ", err= " + e.getMessage() + "]."); - } - catch (NoSuchMethodException e) { - throw new IgniteCheckedException("Cannot find function [func=__internalCall" + - ", err= " + e.getMessage() + "]."); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java new file mode 100644 index 0000000..4224b22 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java @@ -0,0 +1,147 @@ +/* + * 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.internal.processors.scripting; + +import org.apache.ignite.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.*; + +import javax.script.*; + +import static javax.script.ScriptContext.*; + +/** + * Ignite scripting processor. + */ +public class IgniteScriptingProcessor extends GridProcessorAdapter { + /** Javascript engine name. */ + public static final String JAVA_SCRIPT_ENGINE_NAME = "nashorn"; + + /** Javascript engine. */ + private ScriptEngine jsEngine; + + /** + * @param ctx Kernal context. + */ + public IgniteScriptingProcessor(GridKernalContext ctx) { + super(ctx); + } + + /** {@inheritDoc} */ + @Override public void start() throws IgniteCheckedException { + ScriptEngineManager factory = new ScriptEngineManager(); + + jsEngine = factory.getEngineByName(JAVA_SCRIPT_ENGINE_NAME); + + addBinding("ignite", new ScriptingJSIgnite(ctx.grid())); + + String createJSFunction = "function __createJSFunction(mapFunc) {" + + "return eval('(function() { return ' + mapFunc.trim() + '})()'); }"; + + String internalCall = "function __internalCall(funcSource, arg1, arg2) { " + + "var func = __createJSFunction(funcSource); " + + "return func.apply(null, [arg1, arg2]); }"; + + String internalJSCall = "function __internalJSCall(funcSource, arg1, arg2) { " + + "var func = __createJSFunction(funcSource); " + + "return func.apply(null, [JSON.parse(arg1), arg2]); }"; + + String entryFunction = "CacheEntry = function(key, val) {" + + "this.key = key; this.value = val}"; + + addEngineFunction(entryFunction); + addEngineFunction(createJSFunction); + addEngineFunction(internalCall); + addEngineFunction(internalJSCall); + } + + /** + * Add function to scope. + * + * @param script Function script. + * @throws IgniteCheckedException If script failed. + */ + public void addEngineFunction(String script) throws IgniteCheckedException { + try { + jsEngine.eval(script); + } + catch (ScriptException e) { + throw new IgniteCheckedException("Script evaluation failed [script=" + script + "].", e); + } + } + + /** + * Add binding. + * + * @param name Binding name. + * @param o Object to bind. + */ + public void addBinding(String name, Object o) { + Bindings b = jsEngine.getBindings(ENGINE_SCOPE); + + b.put(name, o); + + jsEngine.setBindings(b, ENGINE_SCOPE); + } + + /** + * @param src Script src. + * @return Result of the function. + * @throws IgniteCheckedException If script failed. + */ + public Object invokeFunction(String src) throws IgniteCheckedException { + try { + return jsEngine.eval("(" + src + ")()"); + } + catch (ScriptException e) { + throw new IgniteCheckedException("Function evaluation failed [funcName=" + src + "]."); + } + } + + /** + * @param src Script src. + * @param arg Argument. + * @return Result of the function. + * @throws IgniteCheckedException If script failed. + */ + public Object invokeFunction(String src, Object arg) throws IgniteCheckedException { + return invokeFunction(src, arg, null); + } + + /** + * @param src Script src. + * @param arg Argument. + * @return Result of the function. + * @throws IgniteCheckedException If script failed. + */ + public Object invokeFunction(String src, Object arg, Object arg2) throws IgniteCheckedException { + try { + Invocable invocable = (Invocable) jsEngine; + + return invocable.invokeFunction("__internalCall", src, arg, arg2); + } + catch (ScriptException e) { + throw new IgniteCheckedException("Function evaluation failed [funcName=" + src + + ", err= " + e.getMessage() + "]."); + } + catch (NoSuchMethodException e) { + throw new IgniteCheckedException("Cannot find function [func=__internalCall" + + ", err= " + e.getMessage() + "]."); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/JSONCacheObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/JSONCacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/JSONCacheObject.java deleted file mode 100644 index 8116fa0..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/JSONCacheObject.java +++ /dev/null @@ -1,108 +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.internal.processors.scripting; - -import java.util.*; - -/** - * JSON cache object. - */ -public class JSONCacheObject extends HashMap<Object, Object> { - /** - * Empty constructor. - */ - public JSONCacheObject() { - // No-op. - } - - /** - * @param o Map. - */ - public JSONCacheObject(Map o) { - for (Object key : o.keySet()) - addField(JSONCacheObject.toSimpleObject(key), JSONCacheObject.toSimpleObject(o.get(key))); - } - - /** - * @param key Field name. - * @param val Field value. - */ - public void addField(Object key, Object val) { - put(key, val); - } - - /** - * @param key Field name. - * @return Field value. - */ - public Object getField(Object key) { - return get(key); - } - - /** - * Convert JSON object to RestJSONCacheObject - * - * @param o Object to convert. - * @return Converted object. - */ - public static Object toSimpleObject(Object o) { - if (o == null) - return null; - - if (o instanceof Map) { - Map o1 = (Map)o; - - JSONCacheObject res = new JSONCacheObject(); - - for (Object key : o1.keySet()) - res.addField(toSimpleObject(key), toSimpleObject(o1.get(key))); - - return res; - } - else if (o instanceof List) { - List o1 = (List) o; - - List<Object> val = new ArrayList<>(); - - for (Object v : o1) - val.add(toSimpleObject(v)); - - return val; - } - else if (o.getClass().isArray()) { - Object[] o1 = (Object[]) o; - - List<Object> val = new ArrayList<>(); - - for (Object v : o1) - val.add(toSimpleObject(v)); - - return val; - } - - return o; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof JSONCacheObject)) - return false; - - return super.equals(obj); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingCacheEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingCacheEntry.java new file mode 100644 index 0000000..96c98d0 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingCacheEntry.java @@ -0,0 +1,59 @@ +package org.apache.ignite.internal.processors.scripting; + + +import org.apache.ignite.internal.processors.rest.handlers.scripting.*; + +/** + * Scripting cache entry. + */ +public class ScriptingCacheEntry { + /** Key. */ + private Object key; + + /** Value. */ + private Object val; + + /** + * @param key Key. + * @param val Value. + */ + public ScriptingCacheEntry(Object key, Object val) { + if (key instanceof ScriptingJSONCacheObject) + this.key = ((ScriptingJSONCacheObject)key).getFields(); + else + this.key = key; + + if (val instanceof ScriptingJSONCacheObject) + this.val = ((ScriptingJSONCacheObject)val).getFields(); + else + this.val = val; + } + + /** + * @return Key. + */ + public Object getKey() { + return key; + } + + /** + * @param key Key. + */ + public void setKey(Object key) { + this.key = key; + } + + /** + * @return Value. + */ + public Object getValue() { + return val; + } + + /** + * @param val Value. + */ + public void setValue(Object val) { + this.val = val; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingClusterNode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingClusterNode.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingClusterNode.java new file mode 100644 index 0000000..7c42274 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingClusterNode.java @@ -0,0 +1,42 @@ +/* + * 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.internal.processors.scripting; + +import org.apache.ignite.cluster.*; + +/** + * Node js cluster node. + */ +public class ScriptingClusterNode { + /** Cluster node. */ + private String id; + + /** + * @param node Cluster node. + */ + public ScriptingClusterNode(ClusterNode node) { + this.id = node.id().toString(); + } + + /** + * @return Node id. + */ + public String id() { + return id; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJSIgnite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJSIgnite.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJSIgnite.java new file mode 100644 index 0000000..1c89318 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJSIgnite.java @@ -0,0 +1,65 @@ +/* + * 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.internal.processors.scripting; + +import org.apache.ignite.*; + +/** + * Node js ignite. + */ +public class ScriptingJSIgnite { + /** Ignite. */ + private Ignite ignite; + + /** + * @param ignite Ignite. + */ + public ScriptingJSIgnite(Ignite ignite) { + this.ignite = ignite; + } + + /** + * @param cache Cache name. + * @return Node js cache. + */ + public ScriptingJsCache cache(String cache) { + return new ScriptingJsCache(ignite.cache(cache)); + } + + /** + * @param cache Cache name. + * @return Node js cache. + */ + public ScriptingJsCache getOrCreateCache(String cache) { + return new ScriptingJsCache(ignite.getOrCreateCache(cache)); + } + + /** + * @return Local node. + */ + public ScriptingClusterNode localNode() { + return new ScriptingClusterNode(ignite.cluster().localNode()); + } + + /** + * @return Ignite name. + */ + public String name() { + return ignite.name(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJsCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJsCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJsCache.java new file mode 100644 index 0000000..cc1dd18 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/ScriptingJsCache.java @@ -0,0 +1,260 @@ +/* + * 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.internal.processors.scripting; + +import org.apache.ignite.*; +import org.apache.ignite.internal.processors.rest.handlers.scripting.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.json.*; + +import java.util.*; + +/** + * Scripting cache. + */ +public class ScriptingJsCache { + /** Ignite cache. */ + private IgniteCache<Object, Object> cache; + + /** + * @param cache Ignite cache. + */ + public ScriptingJsCache(IgniteCache cache) { + this.cache = cache; + } + + /** + * @param key Key. + * @param val Value. + */ + public void put(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + cache.put(cacheKey, cacheVal); + } + + /** + * @param key Key. + */ + public Object get(Object key) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + + return ScriptingJSONCacheObject.convertToRestObject(cache.get(cacheKey)); + } + + /** + * @param key Key + * @return True if cache contains key. + */ + public boolean containsKey(Object key) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + + return cache.containsKey(cacheKey); + } + + /** + * @param keys Keys + * @return True if cache contains key. + */ + public boolean containsKeys(List keys) { + List<Object> cacheKeys = (List<Object>)JSONCacheObject.toSimpleObject(keys); + + return cache.containsKeys(new HashSet<>(cacheKeys)); + } + + /** + * @param keys Keys. + * @return Cache entries. + */ + public List<ScriptingCacheEntry> getAll(List keys) { + List cacheKeys = (List)JSONCacheObject.toSimpleObject(keys); + + Map<Object, Object> entries = cache.getAll(new HashSet<>(cacheKeys)); + + List<ScriptingCacheEntry> res = new ArrayList<>(); + + for (Map.Entry<Object, Object> e : entries.entrySet()) + res.add(new ScriptingCacheEntry( + ScriptingJSONCacheObject.convertToRestObject(e.getKey()), + ScriptingJSONCacheObject.convertToRestObject(e.getValue()))); + + return res; + } + + /** + * @param keys Keys. + */ + public void removeAll(List keys) { + List cacheKeys = (List)JSONCacheObject.toSimpleObject(keys); + + cache.removeAll(new HashSet<>(cacheKeys)); + } + + /** + * @param entries Entries. + */ + public void putAll(List entries) { + List cacheKeys = (List)JSONCacheObject.toSimpleObject(entries); + + Map<Object, Object> cacheEntries = U.newHashMap(entries.size()); + + for (Object e : cacheKeys) { + JSONCacheObject e0 = (JSONCacheObject)e; + cacheEntries.put(e0.getField("key"), e0.getField("value")); + } + + cache.putAll(cacheEntries); + } + + /** + * @param key Key. + * @param val Value. + * @return Previous value. + */ + public Object getAndPut(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + return ScriptingJSONCacheObject.convertToRestObject(cache.getAndPut(cacheKey, cacheVal)); + } + + /** + * @param key Key. + * @param val Value. + * @return Previous value. + */ + public Object getAndReplace(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + Object o = ScriptingJSONCacheObject.convertToRestObject(cache.getAndReplace(cacheKey, cacheVal)); + + return o; + } + + /** + * @param key Key. + * @param val Value. + * @return Previous value. + */ + public Object getAndPutIfAbsent(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + return ScriptingJSONCacheObject.convertToRestObject(cache.getAndPutIfAbsent(cacheKey, cacheVal)); + } + + /** + * @param key Key. + * @return Previous value. + */ + public Object getAndRemove(Object key) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + + return ScriptingJSONCacheObject.convertToRestObject(cache.getAndRemove(cacheKey)); + } + + /** + * @param key Key. + * @return If operation success. + */ + public boolean remove(Object key) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + + return cache.remove(cacheKey); + } + + /** + * @param key Key. + * @param val Value. + * @return If operation success. + */ + public boolean removeValue(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + return cache.remove(cacheKey, cacheVal); + } + + /** + * @param key Key. + * @param val Value. + * @return If operation success. + */ + public boolean replace(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + return cache.replace(cacheKey, cacheVal); + } + + /** + * @param key Key. + * @param val Value. + * @param oldVal Old value. + * @return If operation success. + */ + public boolean replaceValue(Object key, Object val, Object oldVal) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + Object oldCacheVal = JSONCacheObject.toSimpleObject(oldVal); + + return cache.replace(cacheKey, oldCacheVal, cacheVal); + } + + /** + * Removes all from cache. + */ + public void removeAllFromCache() { + cache.removeAll(); + } + + /** + * @param key Key. + * @param val Value. + * @return Previous value. + */ + public Object putIfAbsent(Object key, Object val) { + Object cacheKey = JSONCacheObject.toSimpleObject(key); + Object cacheVal = JSONCacheObject.toSimpleObject(val); + + return cache.putIfAbsent(cacheKey, cacheVal); + } + + /** + * @return Cache name. + */ + public String getName() { + return cache.getName(); + } + + /** + * @return Local size. + */ + public int localSize() { + return cache.localSize(); + } + + /** + * @return Size. + */ + public int size() { + return cache.size(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java b/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java new file mode 100644 index 0000000..9f1b601 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java @@ -0,0 +1,108 @@ +/* + * 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.json; + +import java.util.*; + +/** + * JSON cache object. + */ +public class JSONCacheObject extends HashMap<Object, Object> { + /** + * Empty constructor. + */ + public JSONCacheObject() { + // No-op. + } + + /** + * @param o Map. + */ + public JSONCacheObject(Map o) { + for (Object key : o.keySet()) + addField(JSONCacheObject.toSimpleObject(key), JSONCacheObject.toSimpleObject(o.get(key))); + } + + /** + * @param key Field name. + * @param val Field value. + */ + public void addField(Object key, Object val) { + put(key, val); + } + + /** + * @param key Field name. + * @return Field value. + */ + public Object getField(Object key) { + return get(key); + } + + /** + * Convert JSON object to RestJSONCacheObject + * + * @param o Object to convert. + * @return Converted object. + */ + public static Object toSimpleObject(Object o) { + if (o == null) + return null; + + if (o instanceof Map) { + Map o1 = (Map)o; + + JSONCacheObject res = new JSONCacheObject(); + + for (Object key : o1.keySet()) + res.addField(toSimpleObject(key), toSimpleObject(o1.get(key))); + + return res; + } + else if (o instanceof List) { + List o1 = (List) o; + + List<Object> val = new ArrayList<>(); + + for (Object v : o1) + val.add(toSimpleObject(v)); + + return val; + } + else if (o.getClass().isArray()) { + Object[] o1 = (Object[]) o; + + List<Object> val = new ArrayList<>(); + + for (Object v : o1) + val.add(toSimpleObject(v)); + + return val; + } + + return o; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object obj) { + if (obj == null || !(obj instanceof JSONCacheObject)) + return false; + + return super.equals(obj); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/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 deleted file mode 100644 index cd55500..0000000 --- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsCacheApiSelfTest.java +++ /dev/null @@ -1,227 +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.internal; - -/** - * Test node js client put/get. - */ -public class NodeJsCacheApiSelfTest extends NodeJsAbstractTest { - /** - * Constructor. - */ - public NodeJsCacheApiSelfTest() { - super("test-cache-api.js"); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGrid(0); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - grid(0).cache(NodeJsAbstractTest.CACHE_NAME).removeAll(); - } - - /** - * @throws Exception If failed. - */ - public void testPutGet() throws Exception { - runJsScript("testPutGet"); - } - - /** - * @throws Exception If failed. - */ - public void testPutGetObject() throws Exception { - runJsScript("testPutGetObject"); - } - - /** - * @throws Exception If failed. - */ - public void testIncorrectCache() throws Exception { - runJsScript("testIncorrectCacheName"); - } - - /** - * @throws Exception If failed. - */ - public void testGetOrCreateCacheName() throws Exception { - runJsScript("testGetOrCreateCacheName"); - } - - /** - * @throws Exception If failed. - */ - public void testRemove() throws Exception { - runJsScript("testRemove"); - } - - /** - * @throws Exception If failed. - */ - public void testRemoveNoKey() throws Exception { - runJsScript("testRemoveNoKey"); - } - - /** - * @throws Exception If failed. - */ - public void testRemoveAll() throws Exception { - runJsScript("testRemoveAll"); - } - - /** - * @throws Exception If failed. - */ - public void testPutAllGetAll() throws Exception { - runJsScript("testPutAllGetAll"); - } - - /** - * @throws Exception If failed. - */ - public void testPutAllObjectGetAll() throws Exception { - runJsScript("testPutAllObjectGetAll"); - } - - /** - * @throws Exception If failed. - */ - public void testRemoveAllObjectGetAll() throws Exception { - runJsScript("testRemoveAllObjectGetAll"); - } - - /** - * @throws Exception If failed. - */ - public void testContains() throws Exception { - runJsScript("testContains"); - } - - /** - * @throws Exception If failed. - */ - public void testPutContains() throws Exception { - runJsScript("testPutContains"); - } - - /** - * @throws Exception If failed. - */ - public void testPutContainsAll() throws Exception { - runJsScript("testPutContainsAll"); - } - - /** - * @throws Exception If failed. - */ - public void testNotContainsAll() throws Exception { - runJsScript("testNotContainsAll"); - } - - /** - * @throws Exception If failed. - */ - public void testGetAndPut() throws Exception { - runJsScript("testGetAndPut"); - } - - /** - * @throws Exception If failed. - */ - public void testGetAndPutIfAbsent() throws Exception { - runJsScript("testGetAndPutIfAbsent"); - } - - /** - * @throws Exception If failed. - */ - public void testPutIfAbsent() throws Exception { - runJsScript("testPutIfAbsent"); - } - - /** - * @throws Exception If failed. - */ - public void testGetAndRemove() throws Exception { - runJsScript("testGetAndRemove"); - } - - /** - * @throws Exception If failed. - */ - public void testRemoveValue() throws Exception { - runJsScript("testRemoveValue"); - } - - /** - * @throws Exception If failed. - */ - public void testRemoveAllFromCache() throws Exception { - runJsScript("testRemoveAllFromCache"); - } - - /** - * @throws Exception If failed. - */ - public void testReplace() throws Exception { - runJsScript("testReplace"); - } - - /** - * @throws Exception If failed. - */ - public void testIncorrectReplaceObject() throws Exception { - runJsScript("testIncorrectReplaceObject"); - } - - /** - * @throws Exception If failed. - */ - public void testReplaceObject() throws Exception { - runJsScript("testReplaceObject"); - } - - /** - * @throws Exception If failed. - */ - public void testGetAndReplaceObject() throws Exception { - runJsScript("testGetAndReplaceObject"); - } - - /** - * @throws Exception If failed. - */ - public void testReplaceValueObject() throws Exception { - runJsScript("testReplaceValueObject"); - } - - /** - * @throws Exception If failed. - */ - public void testSize() throws Exception { - runJsScript("testSize"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/nodejs/src/test/java/org/apache/ignite/internal/ScriptingJsCacheApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/ScriptingJsCacheApiSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/ScriptingJsCacheApiSelfTest.java new file mode 100644 index 0000000..445d6d3 --- /dev/null +++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/ScriptingJsCacheApiSelfTest.java @@ -0,0 +1,227 @@ +/* + * 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.internal; + +/** + * Test node js client put/get. + */ +public class ScriptingJsCacheApiSelfTest extends NodeJsAbstractTest { + /** + * Constructor. + */ + public ScriptingJsCacheApiSelfTest() { + super("test-cache-api.js"); + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGrid(0); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + grid(0).cache(NodeJsAbstractTest.CACHE_NAME).removeAll(); + } + + /** + * @throws Exception If failed. + */ + public void testPutGet() throws Exception { + runJsScript("testPutGet"); + } + + /** + * @throws Exception If failed. + */ + public void testPutGetObject() throws Exception { + runJsScript("testPutGetObject"); + } + + /** + * @throws Exception If failed. + */ + public void testIncorrectCache() throws Exception { + runJsScript("testIncorrectCacheName"); + } + + /** + * @throws Exception If failed. + */ + public void testGetOrCreateCacheName() throws Exception { + runJsScript("testGetOrCreateCacheName"); + } + + /** + * @throws Exception If failed. + */ + public void testRemove() throws Exception { + runJsScript("testRemove"); + } + + /** + * @throws Exception If failed. + */ + public void testRemoveNoKey() throws Exception { + runJsScript("testRemoveNoKey"); + } + + /** + * @throws Exception If failed. + */ + public void testRemoveAll() throws Exception { + runJsScript("testRemoveAll"); + } + + /** + * @throws Exception If failed. + */ + public void testPutAllGetAll() throws Exception { + runJsScript("testPutAllGetAll"); + } + + /** + * @throws Exception If failed. + */ + public void testPutAllObjectGetAll() throws Exception { + runJsScript("testPutAllObjectGetAll"); + } + + /** + * @throws Exception If failed. + */ + public void testRemoveAllObjectGetAll() throws Exception { + runJsScript("testRemoveAllObjectGetAll"); + } + + /** + * @throws Exception If failed. + */ + public void testContains() throws Exception { + runJsScript("testContains"); + } + + /** + * @throws Exception If failed. + */ + public void testPutContains() throws Exception { + runJsScript("testPutContains"); + } + + /** + * @throws Exception If failed. + */ + public void testPutContainsAll() throws Exception { + runJsScript("testPutContainsAll"); + } + + /** + * @throws Exception If failed. + */ + public void testNotContainsAll() throws Exception { + runJsScript("testNotContainsAll"); + } + + /** + * @throws Exception If failed. + */ + public void testGetAndPut() throws Exception { + runJsScript("testGetAndPut"); + } + + /** + * @throws Exception If failed. + */ + public void testGetAndPutIfAbsent() throws Exception { + runJsScript("testGetAndPutIfAbsent"); + } + + /** + * @throws Exception If failed. + */ + public void testPutIfAbsent() throws Exception { + runJsScript("testPutIfAbsent"); + } + + /** + * @throws Exception If failed. + */ + public void testGetAndRemove() throws Exception { + runJsScript("testGetAndRemove"); + } + + /** + * @throws Exception If failed. + */ + public void testRemoveValue() throws Exception { + runJsScript("testRemoveValue"); + } + + /** + * @throws Exception If failed. + */ + public void testRemoveAllFromCache() throws Exception { + runJsScript("testRemoveAllFromCache"); + } + + /** + * @throws Exception If failed. + */ + public void testReplace() throws Exception { + runJsScript("testReplace"); + } + + /** + * @throws Exception If failed. + */ + public void testIncorrectReplaceObject() throws Exception { + runJsScript("testIncorrectReplaceObject"); + } + + /** + * @throws Exception If failed. + */ + public void testReplaceObject() throws Exception { + runJsScript("testReplaceObject"); + } + + /** + * @throws Exception If failed. + */ + public void testGetAndReplaceObject() throws Exception { + runJsScript("testGetAndReplaceObject"); + } + + /** + * @throws Exception If failed. + */ + public void testReplaceValueObject() throws Exception { + runJsScript("testReplaceValueObject"); + } + + /** + * @throws Exception If failed. + */ + public void testSize() throws Exception { + runJsScript("testSize"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java b/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java index f6ab879..c52799c 100644 --- a/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java +++ b/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java @@ -32,7 +32,7 @@ public class IgniteNodeJsTestSuite extends TestSuite { TestSuite suite = new TestSuite("Ignite Node JS Test Suite"); suite.addTest(new TestSuite(NodeJsIgnitionSelfTest.class)); - suite.addTest(new TestSuite(NodeJsCacheApiSelfTest.class)); + suite.addTest(new TestSuite(ScriptingJsCacheApiSelfTest.class)); suite.addTest(new TestSuite(NodeJsSecretKeySelfTest.class)); suite.addTest(new TestSuite(NodeJsComputeSelfTest.class)); suite.addTest(new TestSuite(NodeJsIgniteSelfTest.class)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38239701/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 cad7cc2..3d662e5 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 @@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.rest.request.*; import org.apache.ignite.internal.processors.scripting.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.json.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.security.*; import org.eclipse.jetty.server.*; @@ -330,10 +331,10 @@ public class GridJettyRestHandler extends AbstractHandler { if (cmd == CACHE_GET_ALL) { Map o = (Map)cmdRes.getResponse(); - List<RestEntry> res = new ArrayList<>(); + List<ScriptingCacheEntry> res = new ArrayList<>(); for (Object k : o.keySet()) - res.add(new RestEntry(k, o.get(k))); + res.add(new ScriptingCacheEntry(k, o.get(k))); cmdRes.setResponse(res); @@ -341,8 +342,8 @@ public class GridJettyRestHandler extends AbstractHandler { else { Object o = cmdRes.getResponse(); - if (o instanceof RestJSONCacheObject) - cmdRes.setResponse(((RestJSONCacheObject)o).getFields()); + if (o instanceof ScriptingJSONCacheObject) + cmdRes.setResponse(((ScriptingJSONCacheObject)o).getFields()); } }