ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [4/4] incubator-ignite git commit: #ignite-964: wip.
Date Thu, 25 Jun 2015 15:58:21 GMT
#ignite-964: wip.


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

Branch: refs/heads/ignite-964
Commit: fb182ab17a13ee5ef29d3d6f079759e6cfd5d168
Parents: 414022e
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Thu Jun 25 18:58:06 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Thu Jun 25 18:58:06 2015 +0300

----------------------------------------------------------------------
 .../handlers/query/QueryCommandHandler.java     | 76 ++++++++++++++++++++
 .../http/jetty/GridJettyRestHandler.java        |  6 ++
 2 files changed, 82 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb182ab1/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
new file mode 100644
index 0000000..3f5c8bb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
@@ -0,0 +1,76 @@
+/*
+ * 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.query;
+
+import org.apache.ignite.internal.*;
+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.typedef.internal.*;
+import org.apache.ignite.lang.*;
+
+import java.util.*;
+
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
+
+/**
+ * Query command handler.
+ */
+public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
+    /** Supported commands. */
+    private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(EXECUTE_SQL_QUERY);
+
+    /**
+     * @param ctx Context.
+     */
+    public QueryCommandHandler(GridKernalContext ctx) {
+        super(ctx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<GridRestCommand> supportedCommands() {
+        return SUPPORTED_COMMANDS;
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest
req) {
+        assert req != null;
+
+        assert SUPPORTED_COMMANDS.contains(req.command());
+
+        switch (req.command()) {
+            case EXECUTE_SQL_QUERY: {
+                assert req instanceof RestSqlQueryRequest : "Invalid type of query request.";
+
+                return ctx.closure().callAsync(new IgniteClosure<RestSqlQueryRequest,
GridRestResponse>() {
+                    @Override public GridRestResponse apply(RestSqlQueryRequest req) {
+                        try {
+                            return new GridRestResponse(); //TODO
+                        }
+                        catch (Exception e) {
+                            return new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage());
+                        }
+                    }
+                }, (RestSqlQueryRequest)req, Collections.singleton(ctx.grid().localNode()));
+            }
+        }
+
+        return new GridFinishedFuture<>();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb182ab1/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 8b2c79c..65eaa3c 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
@@ -474,6 +474,12 @@ public class GridJettyRestHandler extends AbstractHandler {
             case EXECUTE_SQL_QUERY: {
                 RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
 
+                restReq0.sqlQuery((String)params.get("qry"));
+                restReq0.arguments((Object[]) params.get("arg"));
+
+                restReq = restReq0;
+
+                break;
             }
 
             default:


Mime
View raw message