#ignite-738: Remove GridCacheQueryCommandHandler.

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

Branch: refs/heads/ignite-gg-9613
Commit: 7c2092ef27e8f48b0034667d862628d9cbef2803
Parents: 9816ee4
Author: ivasilinets <ivasilin...@gridgain.com>
Authored: Wed Apr 15 12:11:26 2015 +0300
Committer: ivasilinets <ivasilin...@gridgain.com>
Committed: Wed Apr 15 12:11:26 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/GridRestCommand.java        |  11 +-
 .../processors/rest/GridRestProcessor.java      |   9 -
 .../message/GridClientCacheQueryRequest.java    | 258 -----------
 .../cache/GridCacheClientQueryResult.java       |  97 ----
 .../cache/GridCacheQueryCommandHandler.java     | 450 -------------------
 .../protocols/tcp/GridTcpRestNioListener.java   |  24 -
 .../rest/request/GridRestCacheQueryRequest.java | 102 -----
 7 files changed, 1 insertion(+), 950 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/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 03c522b..62732f0 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
@@ -94,16 +94,7 @@ public enum GridRestCommand {
     NOOP("noop"),
 
     /** Quit. */
-    QUIT("quit"),
-
-    /** Start query execution. */
-    CACHE_QUERY_EXECUTE("queryexecute"),
-
-    /** Fetch query results. */
-    CACHE_QUERY_FETCH("queryfetch"),
-
-    /** Rebuild indexes. */
-    CACHE_QUERY_REBUILD_INDEXES("rebuildqueryindexes");
+    QUIT("quit");
 
     /** Enum values. */
     private static final GridRestCommand[] VALS = values();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index 917a8e3..4bc87ad 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -245,7 +245,6 @@ public class GridRestProcessor extends GridProcessorAdapter 
{
         if (isRestEnabled()) {
             // Register handlers.
             addHandler(new GridCacheCommandHandler(ctx));
-            addHandler(new GridCacheQueryCommandHandler(ctx));
             addHandler(new GridTaskCommandHandler(ctx));
             addHandler(new GridTopologyCommandHandler(ctx));
             addHandler(new GridVersionCommandHandler(ctx));
@@ -529,14 +528,6 @@ public class GridRestProcessor extends 
GridProcessorAdapter {
 
                 break;
 
-            case CACHE_QUERY_EXECUTE:
-            case CACHE_QUERY_FETCH:
-            case CACHE_QUERY_REBUILD_INDEXES:
-                perm = SecurityPermission.CACHE_READ;
-                name = ((GridRestCacheQueryRequest)req).cacheName();
-
-                break;
-
             case CACHE_PUT:
             case CACHE_ADD:
             case CACHE_PUT_ALL:

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
deleted file mode 100644
index c2d7f36..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
+++ /dev/null
@@ -1,258 +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.client.message;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-
-/**
- * Cache query request.
- */
-public class GridClientCacheQueryRequest extends GridClientAbstractMessage {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * Available query operations.
-     */
-    @SuppressWarnings("PublicInnerClass")
-    public enum GridQueryOperation {
-        /** First time query execution. Will assign query ID for executed 
query. */
-        EXECUTE,
-
-        /** Fetch next data page. */
-        FETCH,
-
-        /** Rebuild one or all indexes. */
-        REBUILD_INDEXES;
-
-        /** Enumerated values. */
-        private static final GridQueryOperation[] VALS = values();
-
-        /**
-         * Efficiently gets enumerated value from its ordinal.
-         *
-         * @param ord Ordinal value.
-         * @return Enumerated value or {@code null} if ordinal out of range.
-         */
-        @Nullable public static GridQueryOperation fromOrdinal(int ord) {
-            return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
-        }
-    }
-
-    /**
-     * Query types.
-     */
-    @SuppressWarnings("PublicInnerClass")
-    public enum GridQueryType {
-        /** SQL query. */
-        SQL,
-
-        /** SQL fields query. */
-        SQL_FIELDS,
-
-        /** Full text query. */
-        FULL_TEXT,
-
-        /** Scan query. */
-        SCAN;
-
-        /** Enumerated values. */
-        private static final GridQueryType[] VALS = values();
-
-        /**
-         * Efficiently gets enumerated value from its ordinal.
-         *
-         * @param ord Ordinal value.
-         * @return Enumerated value or {@code null} if ordinal out of range.
-         */
-        @Nullable public static GridQueryType fromOrdinal(int ord) {
-            return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
-        }
-    }
-
-    /** Query ID linked to destination node ID. */
-    private long qryId;
-
-    /** Query operation. */
-    private GridQueryOperation op;
-
-    /** Cache name. */
-    private String cacheName;
-
-    /** Query type. */
-    private GridQueryType type;
-
-    /** Query clause. */
-    private String clause;
-
-    /** Page size. */
-    private int pageSize;
-
-    /** Class name. */
-    private String clsName;
-
-    /** Query arguments. */
-    private Object[] qryArgs;
-
-    /**
-     * @return Query ID.
-     */
-    public long queryId() {
-        return qryId;
-    }
-
-    /**
-     * @param qryId Query ID.
-     */
-    public void queryId(long qryId) {
-        this.qryId = qryId;
-    }
-
-    /**
-     * @return Operation.
-     */
-    public GridQueryOperation operation() {
-        return op;
-    }
-
-    /**
-     * @param op Operation.
-     */
-    public void operation(GridQueryOperation op) {
-        this.op = op;
-    }
-
-    /**
-     * @return Cache name.
-     */
-    public String cacheName() {
-        return cacheName;
-    }
-
-    /**
-     * @param cacheName Cache name.
-     */
-    public void cacheName(String cacheName) {
-        this.cacheName = cacheName;
-    }
-
-    /**
-     * @return Query type.
-     */
-    public GridQueryType type() {
-        return type;
-    }
-
-    /**
-     * @param type Query type.
-     */
-    public void type(GridQueryType type) {
-        this.type = type;
-    }
-
-    /**
-     * @return Query clause.
-     */
-    public String clause() {
-        return clause;
-    }
-
-    /**
-     * @param clause Query clause.
-     */
-    public void clause(String clause) {
-        this.clause = clause;
-    }
-
-    /**
-     * @return Page size.
-     */
-    public int pageSize() {
-        return pageSize;
-    }
-
-    /**
-     * @param pageSize Page size.
-     */
-    public void pageSize(int pageSize) {
-        this.pageSize = pageSize;
-    }
-
-    /**
-     * @return Class name.
-     */
-    public String className() {
-        return clsName;
-    }
-
-    /**
-     * @param clsName Class name.
-     */
-    public void className(String clsName) {
-        this.clsName = clsName;
-    }
-
-    /**
-     * @return Query arguments.
-     */
-    public Object[] queryArguments() {
-        return qryArgs;
-    }
-
-    /**
-     * @param qryArgs Query arguments.
-     */
-    public void queryArguments(Object[] qryArgs) {
-        this.qryArgs = qryArgs;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        super.readExternal(in);
-
-        qryId = in.readLong();
-        op = GridQueryOperation.fromOrdinal(in.readInt());
-        type = GridQueryType.fromOrdinal(in.readInt());
-        cacheName = U.readString(in);
-        clause = U.readString(in);
-        pageSize = in.readInt();
-        clsName = U.readString(in);
-        qryArgs = U.readArray(in);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        super.writeExternal(out);
-
-        out.writeLong(qryId);
-        out.writeInt(op.ordinal());
-        out.writeInt(type == null ? -1 : type.ordinal());
-        U.writeString(out, cacheName);
-        U.writeString(out, clause);
-        U.writeString(out, clsName);
-        U.writeArray(out, qryArgs);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridClientCacheQueryRequest.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java
deleted file mode 100644
index b994cae..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java
+++ /dev/null
@@ -1,97 +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.cache;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Client query result.
- */
-public class GridCacheClientQueryResult implements Serializable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Query ID. */
-    private long qryId;
-
-    /** Result items. */
-    private Collection<?> items;
-
-    /** Last flag. */
-    private boolean last;
-
-    /** Node ID. */
-    private UUID nodeId;
-
-    /**
-     * @return Query ID.
-     */
-    public long queryId() {
-        return qryId;
-    }
-
-    /**
-     * @param qryId Query ID.
-     */
-    public void queryId(long qryId) {
-        this.qryId = qryId;
-    }
-
-    /**
-     * @return Items.
-     */
-    public Collection<?> items() {
-        return items;
-    }
-
-    /**
-     * @param items Items.
-     */
-    public void items(Collection<?> items) {
-        this.items = items;
-    }
-
-    /**
-     * @return Last flag.
-     */
-    public boolean last() {
-        return last;
-    }
-
-    /**
-     * @param last Last flag.
-     */
-    public void last(boolean last) {
-        this.last = last;
-    }
-
-    /**
-     * @return Node ID.
-     */
-    public UUID nodeId() {
-        return nodeId;
-    }
-
-    /**
-     * @param nodeId Node ID.
-     */
-    public void nodeId(UUID nodeId) {
-        this.nodeId = nodeId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
deleted file mode 100644
index f32efc3..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
+++ /dev/null
@@ -1,450 +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.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.query.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.rest.*;
-import org.apache.ignite.internal.processors.rest.handlers.*;
-import org.apache.ignite.internal.processors.rest.request.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.lang.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.internal.GridClosureCallMode.*;
-import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
-import static 
org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.*;
-
-/**
- * Cache query command handler.
- */
-public class GridCacheQueryCommandHandler extends 
GridRestCommandHandlerAdapter {
-    /** Supported commands. */
-    private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = 
U.sealList(
-        CACHE_QUERY_EXECUTE,
-        CACHE_QUERY_FETCH,
-        CACHE_QUERY_REBUILD_INDEXES
-    );
-
-    /** Query ID sequence. */
-    private static final AtomicLong qryIdGen = new AtomicLong();
-
-    /**
-     * @param ctx Context.
-     */
-    public GridCacheQueryCommandHandler(GridKernalContext ctx) {
-        super(ctx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<GridRestCommand> supportedCommands() {
-        return SUPPORTED_COMMANDS;
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<GridRestResponse> 
handleAsync(GridRestRequest req) {
-        assert req instanceof GridRestCacheQueryRequest;
-        assert SUPPORTED_COMMANDS.contains(req.command());
-
-        GridRestCacheQueryRequest qryReq = (GridRestCacheQueryRequest)req;
-
-        UUID destId = qryReq.destinationId();
-        String cacheName = qryReq.cacheName();
-
-        switch (qryReq.command()) {
-            case CACHE_QUERY_EXECUTE: {
-                return execute(destId, cacheName, new ExecuteQuery(qryReq));
-            }
-
-            case CACHE_QUERY_FETCH: {
-                return execute(destId, cacheName, new 
FetchQueryResults(qryReq));
-            }
-
-            case CACHE_QUERY_REBUILD_INDEXES: {
-                return broadcast(qryReq.cacheName(), new 
RebuildIndexes(qryReq.cacheName(), qryReq.className()));
-            }
-
-            default:
-                return new GridFinishedFuture<>(new 
IgniteCheckedException("Unsupported query command: " + req.command()));
-        }
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @return If replicated cache with given name is locally available.
-     */
-    private boolean replicatedCacheAvailable(String cacheName) {
-        GridCacheAdapter<Object,Object> cache = 
ctx.cache().internalCache(cacheName);
-
-        return cache != null && cache.configuration().getCacheMode() == 
CacheMode.REPLICATED;
-    }
-
-    /**
-     * Executes given closure either locally or on specified node.
-     *
-     * @param destId Destination node ID.
-     * @param cacheName Cache name.
-     * @param c Closure to execute.
-     * @return Execution future.
-     */
-    private IgniteInternalFuture<GridRestResponse> execute(UUID destId,
-        String cacheName,
-        Callable<GridRestResponse> c)
-    {
-        boolean locExec = destId == null || destId.equals(ctx.localNodeId()) 
|| replicatedCacheAvailable(cacheName);
-
-        if (locExec)
-            return ctx.closure().callLocalSafe(c, false);
-        else {
-            if (ctx.discovery().node(destId) == null)
-                return new GridFinishedFuture<>(new 
IgniteCheckedException("Destination node ID has left the grid " +
-                    "(retry the query): " + destId));
-
-            ctx.task().setThreadContext(TC_NO_FAILOVER, true);
-
-            return ctx.closure().callAsync(BALANCE, c, 
ctx.grid().cluster().forNodeId(destId).nodes());
-        }
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param c Closure to execute.
-     * @return Execution future.
-     */
-    private IgniteInternalFuture<GridRestResponse> broadcast(String cacheName, 
Callable<Object> c) {
-        ctx.task().setThreadContext(TC_NO_FAILOVER, true);
-
-        IgniteInternalFuture<Collection<Object>> fut = 
ctx.closure().callAsync(BROADCAST,
-            Arrays.asList(c),
-            ctx.grid().cluster().forCacheNodes(cacheName).nodes());
-
-        return fut.chain(new C1<IgniteInternalFuture<Collection<Object>>, 
GridRestResponse>() {
-            @Override public GridRestResponse 
apply(IgniteInternalFuture<Collection<Object>> fut) {
-                try {
-                    fut.get();
-
-                    return new GridRestResponse();
-                }
-                catch (IgniteCheckedException e) {
-                    throw new GridClosureException(e);
-                }
-            }
-        });
-    }
-
-    /**
-     * @param qryId Query ID.
-     * @param wrapper Query future wrapper.
-     * @param locMap Queries map.
-     * @param locNodeId Local node ID.
-     * @return Rest response.
-     * @throws IgniteCheckedException If failed.
-     */
-    private static GridRestResponse fetchQueryResults(
-        long qryId,
-        QueryFutureWrapper wrapper,
-        ConcurrentMap<QueryExecutionKey, QueryFutureWrapper> locMap,
-        UUID locNodeId
-    ) throws IgniteCheckedException {
-        if (wrapper == null)
-            throw new IgniteCheckedException("Failed to find query future 
(query has been expired).");
-        Collection<Object> col = wrapper.result();
-
-        GridCacheRestResponse res = new GridCacheRestResponse();
-
-        GridCacheClientQueryResult qryRes = new GridCacheClientQueryResult();
-
-        if (col == null) {
-            col = Collections.emptyList();
-
-            qryRes.last(true);
-
-            locMap.remove(new QueryExecutionKey(qryId), wrapper);
-        }
-
-        qryRes.items(col);
-        qryRes.queryId(qryId);
-        qryRes.nodeId(locNodeId);
-
-        res.setResponse(qryRes);
-
-        return res;
-    }
-
-    /**
-     * Creates class instance.
-     *
-     * @param cls Target class.
-     * @param clsName Implementing class name.
-     * @return Class instance.
-     * @throws IgniteCheckedException If failed.
-     */
-    private static <T> T instance(Class<? extends T> cls, String clsName) 
throws IgniteCheckedException {
-        try {
-            Class<?> implCls = Class.forName(clsName);
-
-            if (!cls.isAssignableFrom(implCls))
-                throw new IgniteCheckedException("Failed to create instance 
(target class does not extend or implement " +
-                    "required class or interface) [cls=" + cls.getName() + ", 
clsName=" + clsName + ']');
-
-            Constructor<?> ctor = implCls.getConstructor();
-
-            return (T)ctor.newInstance();
-        }
-        catch (ClassNotFoundException e) {
-            throw new IgniteCheckedException("Failed to find target class: " + 
clsName, e);
-        }
-        catch (NoSuchMethodException e) {
-            throw new IgniteCheckedException("Failed to find constructor for 
provided arguments " +
-                "[clsName=" + clsName + ']', e);
-        }
-        catch (InstantiationException e) {
-            throw new IgniteCheckedException("Failed to instantiate target 
class " +
-                "[clsName=" + clsName + ']', e);
-        }
-        catch (IllegalAccessException e) {
-            throw new IgniteCheckedException("Failed to instantiate class 
(constructor is not available) " +
-                "[clsName=" + clsName + ']', e);
-        }
-        catch (InvocationTargetException e) {
-            throw new IgniteCheckedException("Failed to instantiate class 
(constructor threw an exception) " +
-                "[clsName=" + clsName + ']', e.getCause());
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ExecuteQuery implements 
IgniteCallable<GridRestResponse> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Injected grid. */
-        @IgniteInstanceResource
-        private Ignite g;
-
-        /** Query request. */
-        private GridRestCacheQueryRequest req;
-
-        /**
-         * @param req Request.
-         */
-        private ExecuteQuery(GridRestCacheQueryRequest req) {
-            this.req = req;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings({"unchecked", "IfMayBeConditional"})
-        @Override public GridRestResponse call() throws Exception {
-            long qryId = qryIdGen.getAndIncrement();
-
-            IgniteCache cache = g.cache(req.cacheName());
-
-            Query qry;
-
-            switch (req.type()) {
-                case SQL:
-                    qry = new SqlQuery(req.className(), 
req.clause()).setArgs(req.queryArguments());
-
-                    break;
-
-                case SQL_FIELDS:
-                    qry = new 
SqlFieldsQuery(req.clause()).setArgs(req.queryArguments());
-
-                    break;
-
-                case FULL_TEXT:
-                    qry = new TextQuery(req.className(), req.clause());
-
-                    break;
-
-                case SCAN:
-                    qry = new ScanQuery(instance(IgniteBiPredicate.class, 
req.className()));
-
-                    break;
-
-                default:
-                    throw new IgniteCheckedException("Unsupported query type: 
" + req.type());
-            }
-
-            if (req.pageSize() > 0)
-                qry = qry.setPageSize(req.pageSize());
-
-            List<?> fut;
-
-            fut = cache.query(qry).getAll();
-
-            ConcurrentMap<QueryExecutionKey, QueryFutureWrapper> locMap = 
g.cluster().nodeLocalMap();
-
-            QueryFutureWrapper wrapper = new QueryFutureWrapper(fut);
-
-            QueryFutureWrapper old = locMap.putIfAbsent(new 
QueryExecutionKey(qryId), wrapper);
-
-            assert old == null;
-
-            return fetchQueryResults(qryId, wrapper, locMap, 
g.cluster().localNode().id());
-        }
-    }
-
-    /**
-     *
-     */
-    private static class FetchQueryResults implements 
IgniteCallable<GridRestResponse> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Injected grid. */
-        @IgniteInstanceResource
-        private Ignite g;
-
-        /** Query request. */
-        private GridRestCacheQueryRequest req;
-
-        /**
-         * @param req Request.
-         */
-        private FetchQueryResults(GridRestCacheQueryRequest req) {
-            this.req = req;
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridRestResponse call() throws Exception {
-            ConcurrentMap<QueryExecutionKey, QueryFutureWrapper> locMap = 
g.cluster().nodeLocalMap();
-
-            return fetchQueryResults(req.queryId(), locMap.get(new 
QueryExecutionKey(req.queryId())),
-                locMap, g.cluster().localNode().id());
-        }
-    }
-
-    /**
-     * Rebuild indexes closure.
-     */
-    private static class RebuildIndexes implements IgniteCallable<Object> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Injected grid. */
-        @IgniteInstanceResource
-        private Ignite g;
-
-        /** Cache name. */
-        private String cacheName;
-
-        /** Class name. */
-        private String clsName;
-
-        /**
-         * @param cacheName Cache name.
-         * @param clsName Optional class name to rebuild indexes for.
-         */
-        private RebuildIndexes(String cacheName, String clsName) {
-            this.cacheName = cacheName;
-            this.clsName = clsName;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object call() throws Exception {
-            if (clsName == null)
-                ((IgniteKernal)g).context().query().rebuildAllIndexes();
-            else
-                ((IgniteKernal)g).context().query().rebuildIndexes(cacheName, 
clsName);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class QueryExecutionKey {
-        /** Query ID. */
-        private long qryId;
-
-        /**
-         * @param qryId Query ID.
-         */
-        private QueryExecutionKey(long qryId) {
-            this.qryId = qryId;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (!(o instanceof QueryExecutionKey))
-                return false;
-
-            QueryExecutionKey that = (QueryExecutionKey)o;
-
-            return qryId == that.qryId;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return (int)(qryId ^ (qryId >>> 32));
-        }
-    }
-
-    /**
-     * Query future wrapper.
-     */
-    private static class QueryFutureWrapper {
-        /** Query future. */
-        private final List qryFut;
-
-        /** Last future use timestamp. */
-        private volatile long lastUseTs;
-
-        /**
-         * @param qryFut Query future.
-         */
-        private QueryFutureWrapper(List qryFut) {
-            this.qryFut = qryFut;
-
-            lastUseTs = U.currentTimeMillis();
-        }
-
-        /**
-         * @return Query future.
-         */
-        private List result() {
-            lastUseTs = U.currentTimeMillis();
-
-            return qryFut;
-        }
-
-        /**
-         * @return Last use timestamp.
-         */
-        private long lastUseTimestamp() {
-            return lastUseTs;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
index 3da47bb..9a24b40 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
@@ -261,30 +261,6 @@ public class GridTcpRestNioListener extends 
GridNioServerListenerAdapter<GridCli
 
             restReq = restCacheReq;
         }
-        else if (msg instanceof GridClientCacheQueryRequest) {
-            GridClientCacheQueryRequest req = (GridClientCacheQueryRequest) 
msg;
-
-            restReq = new GridRestCacheQueryRequest(req);
-
-            switch (req.operation()) {
-                case EXECUTE:
-                    restReq.command(CACHE_QUERY_EXECUTE);
-
-                    break;
-
-                case FETCH:
-                    restReq.command(CACHE_QUERY_FETCH);
-                    break;
-
-                case REBUILD_INDEXES:
-                    restReq.command(CACHE_QUERY_REBUILD_INDEXES);
-
-                    break;
-
-                default:
-                    throw new IllegalArgumentException("Unknown query 
operation: " + req.operation());
-            }
-        }
         else if (msg instanceof GridClientTaskRequest) {
             GridClientTaskRequest req = (GridClientTaskRequest) msg;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c2092ef/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
deleted file mode 100644
index e32dd32..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
+++ /dev/null
@@ -1,102 +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.request;
-
-import org.apache.ignite.internal.processors.rest.client.message.*;
-
-import java.io.*;
-
-/**
- * Cache query request.
- */
-public class GridRestCacheQueryRequest extends GridRestRequest implements 
Serializable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Request message. */
-    private GridClientCacheQueryRequest msg;
-
-    /**
-     * @param msg Client request message.
-     */
-    public GridRestCacheQueryRequest(GridClientCacheQueryRequest msg) {
-        this.msg = msg;
-    }
-
-    /**
-     * @return Query ID.
-     */
-    public long queryId() {
-        return msg.queryId();
-    }
-
-    /**
-     * @return Operation.
-     */
-    public GridClientCacheQueryRequest.GridQueryOperation operation() {
-        return msg.operation();
-    }
-
-    /**
-     * @return Cache name.
-     */
-    public String cacheName() {
-        return msg.cacheName();
-    }
-
-    /**
-     * @return Query clause.
-     */
-    public String clause() {
-        return msg.clause();
-    }
-
-    /**
-     * @return Query type.
-     */
-    public GridClientCacheQueryRequest.GridQueryType type() {
-        return msg.type();
-    }
-
-    /**
-     * @return Page size.
-     */
-    public int pageSize() {
-        return msg.pageSize();
-    }
-
-    /**
-     * @return Class name.
-     */
-    public String className() {
-        return msg.className();
-    }
-
-
-    /**
-     * @return Query arguments.
-     */
-    public Object[] queryArguments() {
-        return msg.queryArguments();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return msg.toString();
-    }
-}

Reply via email to