You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/06/06 08:59:27 UTC
[09/50] [abbrv] ignite git commit: IGNITE-5176: JDBC thin driver:
implemented query execution. This closes #1994. This closes #2040.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
new file mode 100644
index 0000000..136fcf9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
@@ -0,0 +1,309 @@
+/*
+ * 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.jdbc.thin;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.logging.Logger;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
+import org.apache.ignite.internal.binary.BinaryWriterExImpl;
+import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.processors.odbc.SqlListenerNioListener;
+import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion;
+import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
+import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCloseRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResponse;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcUtils;
+import org.apache.ignite.internal.util.ipc.IpcEndpoint;
+import org.apache.ignite.internal.util.ipc.IpcEndpointFactory;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ * JDBC IO layer implementation based on blocking IPC streams.
+ */
+public class JdbcThinTcpIo {
+ /** Current version. */
+ private static final SqlListenerProtocolVersion CURRENT_VER = SqlListenerProtocolVersion.create(2, 1, 0);
+
+ /** Initial output stream capacity for handshake. */
+ private static final int HANDSHAKE_MSG_SIZE = 10;
+
+ /** Initial output for query message. */
+ private static final int QUERY_EXEC_MSG_INIT_CAP = 1024;
+
+ /** Initial output for query fetch message. */
+ private static final int QUERY_FETCH_MSG_SIZE = 13;
+
+ /** Initial output for query fetch message. */
+ private static final int QUERY_META_MSG_SIZE = 9;
+
+ /** Initial output for query close message. */
+ private static final int QUERY_CLOSE_MSG_SIZE = 9;
+
+ /** Logger. */
+ private static final Logger log = Logger.getLogger(JdbcThinTcpIo.class.getName());
+
+ /** Server endpoint address. */
+ private final String endpointAddr;
+
+ /** Endpoint. */
+ private IpcEndpoint endpoint;
+
+ /** Output stream. */
+ private BufferedOutputStream out;
+
+ /** Input stream. */
+ private BufferedInputStream in;
+
+ /** Distributed joins. */
+ private boolean distributedJoins;
+
+ /** Enforce join order. */
+ private boolean enforceJoinOrder;
+
+ /** Closed flag. */
+ private boolean closed;
+
+ /**
+ * @param endpointAddr Endpoint.
+ * @param distributedJoins Distributed joins flag.
+ * @param enforceJoinOrder Enforce join order flag.
+ */
+ JdbcThinTcpIo(String endpointAddr, boolean distributedJoins, boolean enforceJoinOrder) {
+ assert endpointAddr != null;
+
+ this.endpointAddr = endpointAddr;
+ this.distributedJoins = distributedJoins;
+ this.enforceJoinOrder= enforceJoinOrder;
+ }
+
+ /**
+ * @throws IgniteCheckedException On error.
+ * @throws IOException On IO error in handshake.
+ */
+ public void start() throws IgniteCheckedException, IOException {
+ endpoint = IpcEndpointFactory.connectEndpoint(endpointAddr, null);
+
+ out = new BufferedOutputStream(endpoint.outputStream());
+ in = new BufferedInputStream(endpoint.inputStream());
+
+ handshake();
+ }
+
+ /**
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ public void handshake() throws IOException, IgniteCheckedException {
+ BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
+ null, null);
+
+ writer.writeByte((byte)SqlListenerRequest.HANDSHAKE);
+
+ writer.writeShort(CURRENT_VER.major());
+ writer.writeShort(CURRENT_VER.minor());
+ writer.writeShort(CURRENT_VER.maintenance());
+
+ writer.writeByte(SqlListenerNioListener.JDBC_CLIENT);
+
+ writer.writeBoolean(distributedJoins);
+ writer.writeBoolean(enforceJoinOrder);
+
+ send(writer.array());
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, new BinaryHeapInputStream(read()),
+ null, null, false);
+
+ boolean accepted = reader.readBoolean();
+
+ if (accepted)
+ return;
+
+ short maj = reader.readShort();
+ short min = reader.readShort();
+ short maintenance = reader.readShort();
+
+ String err = reader.readString();
+
+ SqlListenerProtocolVersion ver = SqlListenerProtocolVersion.create(maj, min, maintenance);
+
+ throw new IgniteCheckedException("Handshake failed [driverProtocolVer=" + CURRENT_VER +
+ ", remoteNodeProtocolVer=" + ver + ", err=" + err + ']');
+ }
+
+ /**
+ * @param cache Cache name.
+ * @param fetchSize Fetch size.
+ * @param maxRows Max rows.
+ * @param sql SQL statement.
+ * @param args Query parameters.
+ * @return Execute query results.
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ public JdbcQueryExecuteResult queryExecute(String cache, int fetchSize, int maxRows,
+ String sql, List<Object> args)
+ throws IOException, IgniteCheckedException {
+ return sendRequest(new JdbcQueryExecuteRequest(cache, fetchSize, maxRows, sql,
+ args == null ? null : args.toArray(new Object[args.size()])), QUERY_EXEC_MSG_INIT_CAP);
+ }
+
+ /**
+ * @param req Request.
+ * @param cap Initial ouput stream capacity.
+ * @return Server response.
+ * @throws IOException On IO error.
+ * @throws IgniteCheckedException On error.
+ */
+ @SuppressWarnings("unchecked")
+ public <R extends JdbcResult> R sendRequest(JdbcRequest req, int cap) throws IOException, IgniteCheckedException {
+ BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(cap), null, null);
+
+ req.writeBinary(writer);
+
+ send(writer.array());
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, new BinaryHeapInputStream(read()), null, null, false);
+
+ JdbcResponse res = new JdbcResponse();
+
+ res.readBinary(reader);
+
+ if (res.status() != SqlListenerResponse.STATUS_SUCCESS)
+ throw new IgniteCheckedException("Error server response: [req=" + req + ", resp=" + res + ']');
+
+ return (R)res.response();
+ }
+
+ /**
+ * @param qryId Query ID.
+ * @param pageSize pageSize.
+ * @return Fetch results.
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ public JdbcQueryFetchResult queryFetch(Long qryId, int pageSize)
+ throws IOException, IgniteCheckedException {
+ return sendRequest(new JdbcQueryFetchRequest(qryId, pageSize), QUERY_FETCH_MSG_SIZE);
+ }
+
+
+ /**
+ * @param qryId Query ID.
+ * @return Fetch results.
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ public JdbcQueryMetadataResult queryMeta(Long qryId)
+ throws IOException, IgniteCheckedException {
+ return sendRequest(new JdbcQueryMetadataRequest(qryId), QUERY_META_MSG_SIZE);
+ }
+
+ /**
+ * @param qryId Query ID.
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ public void queryClose(long qryId) throws IOException, IgniteCheckedException {
+ sendRequest(new JdbcQueryCloseRequest(qryId), QUERY_CLOSE_MSG_SIZE);
+ }
+
+ /**
+ * @param req ODBC request.
+ * @throws IOException On error.
+ */
+ private void send(byte[] req) throws IOException {
+ int size = req.length;
+
+ out.write(size & 0xFF);
+ out.write((size >> 8) & 0xFF);
+ out.write((size >> 16) & 0xFF);
+ out.write((size >> 24) & 0xFF);
+
+ out.write(req);
+
+ out.flush();
+ }
+
+ /**
+ * @return Bytes of a response from server.
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ private byte[] read() throws IOException, IgniteCheckedException {
+ byte[] sizeBytes = read(4);
+
+ int msgSize = (((0xFF & sizeBytes[3]) << 24) | ((0xFF & sizeBytes[2]) << 16)
+ | ((0xFF & sizeBytes[1]) << 8) + (0xFF & sizeBytes[0]));
+
+ return read(msgSize);
+ }
+
+ /**
+ * @param size Count of bytes to read from stream.
+ * @return Read bytes.
+ * @throws IOException On error.
+ * @throws IgniteCheckedException On error.
+ */
+ private byte [] read(int size) throws IOException, IgniteCheckedException {
+ int off = 0;
+
+ byte[] data = new byte[size];
+
+ while (off != size) {
+ int res = in.read(data, off, size - off);
+
+ if (res == -1)
+ throw new IgniteCheckedException("Failed to read incoming message (not enough data).");
+
+ off += res;
+ }
+
+ return data;
+ }
+
+ /**
+ * Close the client IO.
+ */
+ public void close() {
+ if (closed)
+ return;
+
+ // Clean up resources.
+ U.closeQuiet(out);
+ U.closeQuiet(in);
+
+ if (endpoint != null)
+ endpoint.close();
+
+ closed = true;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
new file mode 100644
index 0000000..7f4c111
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
@@ -0,0 +1,152 @@
+/*
+ * 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.jdbc.thin;
+
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.Date;
+
+import static java.sql.Types.BIGINT;
+import static java.sql.Types.BINARY;
+import static java.sql.Types.BOOLEAN;
+import static java.sql.Types.DATE;
+import static java.sql.Types.DOUBLE;
+import static java.sql.Types.FLOAT;
+import static java.sql.Types.INTEGER;
+import static java.sql.Types.OTHER;
+import static java.sql.Types.SMALLINT;
+import static java.sql.Types.TIME;
+import static java.sql.Types.TIMESTAMP;
+import static java.sql.Types.TINYINT;
+import static java.sql.Types.VARCHAR;
+
+/**
+ * Utility methods for thin JDBC driver.
+ */
+public class JdbcThinUtils {
+ /**
+ * Converts Java class name to type from {@link Types}.
+ *
+ * @param cls Java class name.
+ * @return Type from {@link Types}.
+ */
+ @SuppressWarnings("IfMayBeConditional")
+ public static int type(String cls) {
+ if (Boolean.class.getName().equals(cls) || boolean.class.getName().equals(cls))
+ return BOOLEAN;
+ else if (Byte.class.getName().equals(cls) || byte.class.getName().equals(cls))
+ return TINYINT;
+ else if (Short.class.getName().equals(cls) || short.class.getName().equals(cls))
+ return SMALLINT;
+ else if (Integer.class.getName().equals(cls) || int.class.getName().equals(cls))
+ return INTEGER;
+ else if (Long.class.getName().equals(cls) || long.class.getName().equals(cls))
+ return BIGINT;
+ else if (Float.class.getName().equals(cls) || float.class.getName().equals(cls))
+ return FLOAT;
+ else if (Double.class.getName().equals(cls) || double.class.getName().equals(cls))
+ return DOUBLE;
+ else if (String.class.getName().equals(cls))
+ return VARCHAR;
+ else if (byte[].class.getName().equals(cls))
+ return BINARY;
+ else if (Time.class.getName().equals(cls))
+ return TIME;
+ else if (Timestamp.class.getName().equals(cls))
+ return TIMESTAMP;
+ else if (Date.class.getName().equals(cls))
+ return DATE;
+ else
+ return OTHER;
+ }
+
+ /**
+ * Converts Java class name to SQL type name.
+ *
+ * @param cls Java class name.
+ * @return SQL type name.
+ */
+ @SuppressWarnings("IfMayBeConditional")
+ public static String typeName(String cls) {
+ if (Boolean.class.getName().equals(cls) || boolean.class.getName().equals(cls))
+ return "BOOLEAN";
+ else if (Byte.class.getName().equals(cls) || byte.class.getName().equals(cls))
+ return "TINYINT";
+ else if (Short.class.getName().equals(cls) || short.class.getName().equals(cls))
+ return "SMALLINT";
+ else if (Integer.class.getName().equals(cls) || int.class.getName().equals(cls))
+ return "INTEGER";
+ else if (Long.class.getName().equals(cls) || long.class.getName().equals(cls))
+ return "BIGINT";
+ else if (Float.class.getName().equals(cls) || float.class.getName().equals(cls))
+ return "FLOAT";
+ else if (Double.class.getName().equals(cls) || double.class.getName().equals(cls))
+ return "DOUBLE";
+ else if (String.class.getName().equals(cls))
+ return "VARCHAR";
+ else if (byte[].class.getName().equals(cls))
+ return "BINARY";
+ else if (Time.class.getName().equals(cls))
+ return "TIME";
+ else if (Timestamp.class.getName().equals(cls))
+ return "TIMESTAMP";
+ else if (Date.class.getName().equals(cls))
+ return "DATE";
+ else
+ return "OTHER";
+ }
+
+ /**
+ * @param type a value from <code>java.sql.Types</code>.
+ * @return {@code true} if type is plain and supported by thin JDBC driver.
+ */
+ public static boolean isPlainJdbcType(int type) {
+ return type != Types.ARRAY
+ && type != Types.BLOB
+ && type != Types.CLOB
+ && type != Types.DATALINK
+ && type != Types.JAVA_OBJECT
+ && type != Types.NCHAR
+ && type != Types.NVARCHAR
+ && type != Types.LONGNVARCHAR
+ && type != Types.REF
+ && type != Types.NCHAR
+ && type != Types.ROWID
+ && type != Types.SQLXML;
+ }
+
+ /**
+ * Determines whether type is nullable.
+ *
+ * @param name Column name.
+ * @param cls Java class name.
+ * @return {@code True} if nullable.
+ */
+ public static boolean nullable(String name, String cls) {
+ return !"_KEY".equalsIgnoreCase(name) &&
+ !"_VAL".equalsIgnoreCase(name) &&
+ !(boolean.class.getName().equals(cls) ||
+ byte.class.getName().equals(cls) ||
+ short.class.getName().equals(cls) ||
+ int.class.getName().equals(cls) ||
+ long.class.getName().equals(cls) ||
+ float.class.getName().equals(cls) ||
+ double.class.getName().equals(cls));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
deleted file mode 100644
index bdfaa1d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
+++ /dev/null
@@ -1,74 +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.odbc;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * ODBC query get columns meta request.
- */
-public class OdbcQueryGetColumnsMetaRequest extends SqlListenerRequest {
- /** Cache name. */
- private final String cacheName;
-
- /** Table name. */
- private final String tableName;
-
- /** Column name. */
- private final String columnName;
-
- /**
- * @param cacheName Cache name.
- * @param tableName Table name.
- * @param columnName Column name.
- */
- public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
- super(META_COLS);
-
- this.cacheName = cacheName;
- this.tableName = tableName;
- this.columnName = columnName;
- }
-
- /**
- * @return Cache name.
- */
- @Nullable public String cacheName() {
- return cacheName;
- }
-
- /**
- * @return Table name.
- */
- public String tableName() {
- return tableName;
- }
-
- /**
- * @return Column name.
- */
- public String columnName() {
- return columnName;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(OdbcQueryGetColumnsMetaRequest.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
deleted file mode 100644
index 28daa56..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.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.odbc;
-
-import java.util.Collection;
-
-/**
- * Query get columns meta result.
- */
-public class OdbcQueryGetColumnsMetaResult {
- /** Query result rows. */
- private final Collection<SqlListenerColumnMeta> meta;
-
- /**
- * @param meta Column metadata.
- */
- public OdbcQueryGetColumnsMetaResult(Collection<SqlListenerColumnMeta> meta) {
- this.meta = meta;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<SqlListenerColumnMeta> meta() {
- return meta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaRequest.java
deleted file mode 100644
index e6a97e3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaRequest.java
+++ /dev/null
@@ -1,60 +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.odbc;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * ODBC query get params meta request.
- */
-public class OdbcQueryGetParamsMetaRequest extends SqlListenerRequest {
- /** Cache. */
- private final String cacheName;
-
- /** Query. */
- private final String query;
-
- /**
- * @param query SQL Query.
- */
- public OdbcQueryGetParamsMetaRequest(String cacheName, String query) {
- super(META_PARAMS);
-
- this.cacheName = cacheName;
- this.query = query;
- }
-
- /**
- * @return SQL Query.
- */
- public String query() {
- return query;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(OdbcQueryGetParamsMetaRequest.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaResult.java
deleted file mode 100644
index 616c82d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetParamsMetaResult.java
+++ /dev/null
@@ -1,40 +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.odbc;
-
-/**
- * ODBC query get params meta result.
- */
-public class OdbcQueryGetParamsMetaResult {
- /** List of parameter type IDs. */
- private final byte[] typeIds;
-
- /**
- * @param typeIds List of parameter type IDs.
- */
- public OdbcQueryGetParamsMetaResult(byte[] typeIds) {
- this.typeIds = typeIds;
- }
-
- /**
- * @return List of parameter type IDs.
- */
- public byte[] typeIds() {
- return typeIds;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
deleted file mode 100644
index 772c487..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
+++ /dev/null
@@ -1,85 +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.odbc;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * ODBC query get tables meta request.
- */
-public class OdbcQueryGetTablesMetaRequest extends SqlListenerRequest {
- /** Catalog search pattern. */
- private final String catalog;
-
- /** Schema search pattern. */
- private final String schema;
-
- /** Table search pattern. */
- private final String table;
-
- /** Table type search pattern. */
- private final String tableType;
-
- /**
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableType Table type search pattern.
- */
- public OdbcQueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) {
- super(META_TBLS);
-
- this.catalog = catalog;
- this.schema = schema;
- this.table = table;
- this.tableType = tableType;
- }
-
- /**
- * @return catalog search pattern.
- */
- public String catalog() {
- return catalog;
- }
-
- /**
- * @return Schema search pattern.
- */
- public String schema() {
- return schema;
- }
-
- /**
- * @return Table search pattern.
- */
- public String table() {
- return table;
- }
-
- /**
- * @return Table type search pattern.
- */
- public String tableType() {
- return tableType;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(OdbcQueryGetTablesMetaRequest.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
deleted file mode 100644
index 27bebd6..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.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.odbc;
-
-import java.util.Collection;
-
-/**
- * Query get columns meta result.
- */
-public class OdbcQueryGetTablesMetaResult {
- /** Query result rows. */
- private final Collection<OdbcTableMeta> meta;
-
- /**
- * @param meta Column metadata.
- */
- public OdbcQueryGetTablesMetaResult(Collection<OdbcTableMeta> meta) {
- this.meta = meta;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<OdbcTableMeta> meta() {
- return meta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
deleted file mode 100644
index ca630dd..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
+++ /dev/null
@@ -1,88 +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.odbc;
-
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
-
-import java.util.Objects;
-
-/**
- * ODBC table-related metadata.
- */
-public class OdbcTableMeta {
- /** Catalog name. */
- private final String catalog;
-
- /** Schema name. */
- private final String schema;
-
- /** Table name. */
- private final String table;
-
- /** Table type. */
- private final String tableType;
-
- /**
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @param tableType Table type.
- */
- public OdbcTableMeta(String catalog, String schema, String table, String tableType) {
- this.catalog = catalog;
- this.schema = OdbcUtils.addQuotationMarksIfNeeded(schema);
- this.table = table;
- this.tableType = tableType;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int hash = Objects.hashCode(catalog);
-
- hash = 31 * hash + Objects.hashCode(schema);
- hash = 31 * hash + Objects.hashCode(table);
- hash = 31 * hash + Objects.hashCode(tableType);
-
- return hash;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (o instanceof OdbcTableMeta) {
- OdbcTableMeta other = (OdbcTableMeta) o;
-
- return this == other ||
- Objects.equals(catalog, other.catalog) && Objects.equals(schema, other.schema) &&
- Objects.equals(table, other.table) && Objects.equals(tableType, other.tableType);
- }
-
- return false;
- }
-
- /**
- * Write in a binary format.
- *
- * @param writer Binary writer.
- */
- public void writeBinary(BinaryRawWriterEx writer) {
- writer.writeString(catalog);
- writer.writeString(schema);
- writer.writeString(table);
- writer.writeString(tableType);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractMessageParser.java
deleted file mode 100644
index 9d731ab..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractMessageParser.java
+++ /dev/null
@@ -1,265 +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.odbc;
-
-import java.util.Collection;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-
-/**
- * ODBC message parser.
- */
-public abstract class SqlListenerAbstractMessageParser implements SqlListenerMessageParser {
- /** Initial output stream capacity. */
- protected static final int INIT_CAP = 1024;
-
- /** Kernal context. */
- protected GridKernalContext ctx;
-
- /** Logger. */
- private final IgniteLogger log;
-
- /** Object reader. */
- private SqlListenerAbstractObjectReader objReader;
-
- /** Object writer. */
- private SqlListenerAbstractObjectWriter objWriter;
-
- /**
- * @param ctx Context.
- * @param objReader Object reader.
- * @param objWriter Object writer.
- */
- protected SqlListenerAbstractMessageParser(final GridKernalContext ctx, SqlListenerAbstractObjectReader objReader,
- SqlListenerAbstractObjectWriter objWriter) {
- this.ctx = ctx;
-
- log = ctx.log(getClass());
-
- this.objReader = objReader;
- this.objWriter = objWriter;
- }
-
- /** {@inheritDoc} */
- @Override public SqlListenerRequest decode(byte[] msg) {
- assert msg != null;
-
- BinaryReaderExImpl reader = createReader(msg);
-
- byte cmd = reader.readByte();
-
- SqlListenerRequest res;
-
- switch (cmd) {
- case SqlListenerRequest.QRY_EXEC: {
- String cache = reader.readString();
- String sql = reader.readString();
- int argsNum = reader.readInt();
-
- Object[] params = new Object[argsNum];
-
- for (int i = 0; i < argsNum; ++i)
- params[i] = objReader.readObject(reader);
-
- res = new SqlListenerQueryExecuteRequest(cache, sql, params);
-
- break;
- }
-
- case SqlListenerRequest.QRY_FETCH: {
- long queryId = reader.readLong();
- int pageSize = reader.readInt();
-
- res = new SqlListenerQueryFetchRequest(queryId, pageSize);
-
- break;
- }
-
- case SqlListenerRequest.QRY_CLOSE: {
- long queryId = reader.readLong();
-
- res = new SqlListenerQueryCloseRequest(queryId);
-
- break;
- }
-
- case SqlListenerRequest.META_COLS: {
- String cache = reader.readString();
- String table = reader.readString();
- String column = reader.readString();
-
- res = new OdbcQueryGetColumnsMetaRequest(cache, table, column);
-
- break;
- }
-
- case SqlListenerRequest.META_TBLS: {
- String catalog = reader.readString();
- String schema = reader.readString();
- String table = reader.readString();
- String tableType = reader.readString();
-
- res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
-
- break;
- }
-
- case SqlListenerRequest.META_PARAMS: {
- String cacheName = reader.readString();
- String sqlQuery = reader.readString();
-
- res = new OdbcQueryGetParamsMetaRequest(cacheName, sqlQuery);
-
- break;
- }
-
- default:
- throw new IgniteException("Unknown ODBC command: [cmd=" + cmd + ']');
- }
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] encode(SqlListenerResponse msg) {
- assert msg != null;
-
- // Creating new binary writer
- BinaryWriterExImpl writer = createWriter(INIT_CAP);
-
- // Writing status.
- writer.writeByte((byte) msg.status());
-
- if (msg.status() != SqlListenerResponse.STATUS_SUCCESS) {
- writer.writeString(msg.error());
-
- return writer.array();
- }
-
- Object res0 = msg.response();
-
- if (res0 == null)
- return writer.array();
- else if (res0 instanceof SqlListenerQueryExecuteResult) {
- SqlListenerQueryExecuteResult res = (SqlListenerQueryExecuteResult) res0;
-
- if (log.isDebugEnabled())
- log.debug("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- Collection<SqlListenerColumnMeta> metas = res.getColumnsMetadata();
-
- assert metas != null;
-
- writer.writeInt(metas.size());
-
- for (SqlListenerColumnMeta meta : metas)
- meta.write(writer);
- }
- else if (res0 instanceof SqlListenerQueryFetchResult) {
- SqlListenerQueryFetchResult res = (SqlListenerQueryFetchResult) res0;
-
- if (log.isDebugEnabled())
- log.debug("Resulting query ID: " + res.queryId());
-
- writer.writeLong(res.queryId());
-
- Collection<?> items0 = res.items();
-
- assert items0 != null;
-
- writer.writeBoolean(res.last());
-
- writer.writeInt(items0.size());
-
- for (Object row0 : items0) {
- if (row0 != null) {
- Collection<?> row = (Collection<?>)row0;
-
- writer.writeInt(row.size());
-
- for (Object obj : row)
- objWriter.writeObject(writer, obj);
- }
- }
- }
- else if (res0 instanceof SqlListenerQueryCloseResult) {
- SqlListenerQueryCloseResult res = (SqlListenerQueryCloseResult) res0;
-
- if (log.isDebugEnabled())
- log.debug("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
- }
- else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
- OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0;
-
- Collection<SqlListenerColumnMeta> columnsMeta = res.meta();
-
- assert columnsMeta != null;
-
- writer.writeInt(columnsMeta.size());
-
- for (SqlListenerColumnMeta columnMeta : columnsMeta)
- columnMeta.write(writer);
- }
- else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
- OdbcQueryGetTablesMetaResult res = (OdbcQueryGetTablesMetaResult) res0;
-
- Collection<OdbcTableMeta> tablesMeta = res.meta();
-
- assert tablesMeta != null;
-
- writer.writeInt(tablesMeta.size());
-
- for (OdbcTableMeta tableMeta : tablesMeta)
- tableMeta.writeBinary(writer);
- }
- else if (res0 instanceof OdbcQueryGetParamsMetaResult) {
- OdbcQueryGetParamsMetaResult res = (OdbcQueryGetParamsMetaResult) res0;
-
- byte[] typeIds = res.typeIds();
-
- objWriter.writeObject(writer, typeIds);
- }
- else
- assert false : "Should not reach here.";
-
- return writer.array();
- }
-
- /**
- * Create reader.
- *
- * @param msg Input message.
- * @return Reader.
- */
- protected abstract BinaryReaderExImpl createReader(byte[] msg);
-
- /**
- * Create writer.
- *
- * @param cap Initial capacity.
- * @return Binary writer instance.
- */
- protected abstract BinaryWriterExImpl createWriter(int cap);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectReader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectReader.java
deleted file mode 100644
index 18162e6..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectReader.java
+++ /dev/null
@@ -1,137 +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.odbc;
-
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-import org.apache.ignite.internal.binary.BinaryUtils;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Binary reader with marshaling non-primitive and non-embedded objects with JDK marshaller.
- */
-@SuppressWarnings("unchecked")
-public abstract class SqlListenerAbstractObjectReader {
- /**
- * @param reader Reader.
- * @return Read object.
- * @throws BinaryObjectException On error.
- */
- @Nullable public Object readObject(BinaryReaderExImpl reader) throws BinaryObjectException {
- byte type = reader.readByte();
-
- switch (type) {
- case GridBinaryMarshaller.NULL:
- return null;
-
- case GridBinaryMarshaller.BOOLEAN:
- return reader.readBoolean();
-
- case GridBinaryMarshaller.BYTE:
- return reader.readByte();
-
- case GridBinaryMarshaller.CHAR:
- return reader.readChar();
-
- case GridBinaryMarshaller.SHORT:
- return reader.readShort();
-
- case GridBinaryMarshaller.INT:
- return reader.readInt();
-
- case GridBinaryMarshaller.LONG:
- return reader.readLong();
-
- case GridBinaryMarshaller.FLOAT:
- return reader.readFloat();
-
- case GridBinaryMarshaller.DOUBLE:
- return reader.readDouble();
-
- case GridBinaryMarshaller.STRING:
- return BinaryUtils.doReadString(reader.in());
-
- case GridBinaryMarshaller.DECIMAL:
- return BinaryUtils.doReadDecimal(reader.in());
-
- case GridBinaryMarshaller.UUID:
- return BinaryUtils.doReadUuid(reader.in());
-
- case GridBinaryMarshaller.TIME:
- return BinaryUtils.doReadTime(reader.in());
-
- case GridBinaryMarshaller.TIMESTAMP:
- return BinaryUtils.doReadTimestamp(reader.in());
-
- case GridBinaryMarshaller.DATE:
- return BinaryUtils.doReadDate(reader.in());
-
- case GridBinaryMarshaller.BOOLEAN_ARR:
- return BinaryUtils.doReadBooleanArray(reader.in());
-
- case GridBinaryMarshaller.BYTE_ARR:
- return BinaryUtils.doReadByteArray(reader.in());
-
- case GridBinaryMarshaller.CHAR_ARR:
- return BinaryUtils.doReadCharArray(reader.in());
-
- case GridBinaryMarshaller.SHORT_ARR:
- return BinaryUtils.doReadShortArray(reader.in());
-
- case GridBinaryMarshaller.INT_ARR:
- return BinaryUtils.doReadIntArray(reader.in());
-
- case GridBinaryMarshaller.FLOAT_ARR:
- return BinaryUtils.doReadFloatArray(reader.in());
-
- case GridBinaryMarshaller.DOUBLE_ARR:
- return BinaryUtils.doReadDoubleArray(reader.in());
-
- case GridBinaryMarshaller.STRING_ARR:
- return BinaryUtils.doReadStringArray(reader.in());
-
- case GridBinaryMarshaller.DECIMAL_ARR:
- return BinaryUtils.doReadDecimalArray(reader.in());
-
- case GridBinaryMarshaller.UUID_ARR:
- return BinaryUtils.doReadUuidArray(reader.in());
-
- case GridBinaryMarshaller.TIME_ARR:
- return BinaryUtils.doReadTimeArray(reader.in());
-
- case GridBinaryMarshaller.TIMESTAMP_ARR:
- return BinaryUtils.doReadTimestampArray(reader.in());
-
- case GridBinaryMarshaller.DATE_ARR:
- return BinaryUtils.doReadDateArray(reader.in());
-
- default:
- reader.in().position(reader.in().position() - 1);
-
- return readCustomObject(reader);
- }
- }
-
- /**
- * @param reader Reader.
- * @return An object is unmarshaled by marshaller.
- * @throws BinaryObjectException On error.
- */
- protected abstract Object readCustomObject(BinaryReaderExImpl reader) throws BinaryObjectException;
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectWriter.java
deleted file mode 100644
index f5e9924..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerAbstractObjectWriter.java
+++ /dev/null
@@ -1,111 +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.odbc;
-
-import java.math.BigDecimal;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.UUID;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Binary writer with marshaling non-primitive and non-embedded objects with JDK marshaller..
- */
-public abstract class SqlListenerAbstractObjectWriter {
- /**
- * @param writer Writer.
- * @param obj Object to write.
- * @throws BinaryObjectException On error.
- */
- public void writeObject(BinaryWriterExImpl writer, @Nullable Object obj) throws BinaryObjectException {
- if (obj == null) {
- writer.writeByte(GridBinaryMarshaller.NULL);
-
- return;
- }
-
- Class<?> cls = obj.getClass();
-
- if (cls == Boolean.class)
- writer.writeBooleanFieldPrimitive((Boolean)obj);
- else if (cls == Byte.class)
- writer.writeByteFieldPrimitive((Byte)obj);
- else if (cls == Character.class)
- writer.writeCharFieldPrimitive((Character)obj);
- else if (cls == Short.class)
- writer.writeShortFieldPrimitive((Short)obj);
- else if (cls == Integer.class)
- writer.writeIntFieldPrimitive((Integer)obj);
- else if (cls == Long.class)
- writer.writeLongFieldPrimitive((Long)obj);
- else if (cls == Float.class)
- writer.writeFloatFieldPrimitive((Float)obj);
- else if (cls == Double.class)
- writer.writeDoubleFieldPrimitive((Double)obj);
- else if (cls == String.class)
- writer.doWriteString((String)obj);
- else if (cls == BigDecimal.class)
- writer.doWriteDecimal((BigDecimal)obj);
- else if (cls == UUID.class)
- writer.writeUuid((UUID)obj);
- else if (cls == Time.class)
- writer.writeTime((Time)obj);
- else if (cls == Timestamp.class)
- writer.writeTimestamp((Timestamp)obj);
- else if (cls == java.sql.Date.class || cls == java.util.Date.class)
- writer.writeDate((java.util.Date)obj);
- else if (cls == boolean[].class)
- writer.writeBooleanArray((boolean[])obj);
- else if (cls == byte[].class)
- writer.writeByteArray((byte[])obj);
- else if (cls == char[].class)
- writer.writeCharArray((char[])obj);
- else if (cls == short[].class)
- writer.writeShortArray((short[])obj);
- else if (cls == int[].class)
- writer.writeIntArray((int[])obj);
- else if (cls == float[].class)
- writer.writeFloatArray((float[])obj);
- else if (cls == double[].class)
- writer.writeDoubleArray((double[])obj);
- else if (cls == String[].class)
- writer.writeStringArray((String[])obj);
- else if (cls == BigDecimal[].class)
- writer.writeDecimalArray((BigDecimal[])obj);
- else if (cls == UUID[].class)
- writer.writeUuidArray((UUID[])obj);
- else if (cls == Time[].class)
- writer.writeTimeArray((Time[])obj);
- else if (cls == Timestamp[].class)
- writer.writeTimestampArray((Timestamp[])obj);
- else if (cls == java.util.Date[].class || cls == java.sql.Date[].class)
- writer.writeDateArray((java.util.Date[])obj);
- else
- writeCustomObject(writer, obj);
- }
-
- /**
- * @param writer Writer.
- * @param obj Object to marshal with marshaller and write to binary stream.
- * @throws BinaryObjectException On error.
- */
- protected abstract void writeCustomObject(BinaryWriterExImpl writer, Object obj) throws BinaryObjectException;
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerColumnMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerColumnMeta.java
deleted file mode 100644
index 73133a1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerColumnMeta.java
+++ /dev/null
@@ -1,110 +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.odbc;
-
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.internal.binary.BinaryUtils;
-import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
-
-/**
- * SQL listener column metadata.
- */
-public class SqlListenerColumnMeta {
- /** Cache name. */
- private final String schemaName;
-
- /** Table name. */
- private final String tableName;
-
- /** Column name. */
- private final String columnName;
-
- /** Data type. */
- private final Class<?> dataType;
-
- /**
- * @param schemaName Cache name.
- * @param tableName Table name.
- * @param columnName Column name.
- * @param dataType Data type.
- */
- public SqlListenerColumnMeta(String schemaName, String tableName, String columnName, Class<?> dataType) {
- this.schemaName = OdbcUtils.addQuotationMarksIfNeeded(schemaName);
- this.tableName = tableName;
- this.columnName = columnName;
- this.dataType = dataType;
- }
-
- /**
- * @param info Field metadata.
- */
- public SqlListenerColumnMeta(GridQueryFieldMetadata info) {
- this.schemaName = OdbcUtils.addQuotationMarksIfNeeded(info.schemaName());
- this.tableName = info.typeName();
- this.columnName = info.fieldName();
-
- Class<?> type;
-
- try {
- type = Class.forName(info.fieldTypeName());
- }
- catch (Exception ignored) {
- type = Object.class;
- }
-
- this.dataType = type;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int hash = schemaName.hashCode();
-
- hash = 31 * hash + tableName.hashCode();
- hash = 31 * hash + columnName.hashCode();
- hash = 31 * hash + dataType.hashCode();
-
- return hash;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (o instanceof SqlListenerColumnMeta) {
- SqlListenerColumnMeta other = (SqlListenerColumnMeta) o;
-
- return this == other || schemaName.equals(other.schemaName) && tableName.equals(other.tableName) &&
- columnName.equals(other.columnName) && dataType.equals(other.dataType);
- }
-
- return false;
- }
-
- /**
- * Write in a binary format.
- *
- * @param writer Binary writer.
- */
- public void write(BinaryRawWriter writer) {
- writer.writeString(schemaName);
- writer.writeString(tableName);
- writer.writeString(columnName);
-
- byte typeId = BinaryUtils.typeByClass(dataType);
-
- writer.writeByte(typeId);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
index 9eaec04..e46ee50 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
@@ -29,7 +29,9 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMessageParser;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler;
import org.apache.ignite.internal.processors.odbc.odbc.OdbcMessageParser;
+import org.apache.ignite.internal.processors.odbc.odbc.OdbcRequestHandler;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
import org.apache.ignite.internal.util.nio.GridNioSession;
@@ -118,6 +120,7 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
}
SqlListenerMessageParser parser = connCtx.parser();
+ SqlListenerRequestHandler handler = connCtx.handler();
SqlListenerRequest req;
@@ -125,7 +128,7 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
req = parser.decode(msg);
}
catch (Exception e) {
- log.error("Failed to parse SQL client request [err=" + e + ']');
+ log.error("Failed to parse SQL client request.", e);
ses.close();
@@ -146,8 +149,6 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
", req=" + req + ']');
}
- SqlListenerRequestHandler handler = connCtx.handler();
-
SqlListenerResponse resp = handler.handle(req);
if (log.isDebugEnabled()) {
@@ -162,9 +163,9 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
ses.send(outMsg);
}
catch (Exception e) {
- log.error("Failed to process SQL client request [reqId=" + req.requestId() + ", err=" + e + ']');
+ log.error("Failed to process SQL client request [req=" + req + ']', e);
- ses.send(parser.encode(new SqlListenerResponse(SqlListenerResponse.STATUS_FAILED, e.toString())));
+ ses.send(parser.encode(handler.handleException(e)));
}
}
@@ -238,25 +239,27 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
boolean distributedJoins = reader.readBoolean();
boolean enforceJoinOrder = reader.readBoolean();
- SqlListenerRequestHandlerImpl handler = new SqlListenerRequestHandlerImpl(ctx, busyLock, maxCursors,
- distributedJoins, enforceJoinOrder);
-
- SqlListenerMessageParser parser = null;
+ SqlListenerRequestHandler handler;
+ SqlListenerMessageParser parser;
switch (clientType) {
case ODBC_CLIENT:
parser = new OdbcMessageParser(ctx);
+ handler = new OdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, enforceJoinOrder);
+
break;
case JDBC_CLIENT:
parser = new JdbcMessageParser(ctx);
+ handler = new JdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, enforceJoinOrder);
+
break;
- }
- if (parser == null)
- throw new IgniteException("Unknown client type: " + clientType);
+ default:
+ throw new IgniteException("Unknown client type: " + clientType);
+ }
return new SqlListenerConnectionContext(handler, parser);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseRequest.java
deleted file mode 100644
index 74361c6..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseRequest.java
+++ /dev/null
@@ -1,49 +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.odbc;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * SQL listener query close request.
- */
-public class SqlListenerQueryCloseRequest extends SqlListenerRequest {
- /** Query ID. */
- private final long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public SqlListenerQueryCloseRequest(long queryId) {
- super(QRY_CLOSE);
-
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SqlListenerQueryCloseRequest.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseResult.java
deleted file mode 100644
index 2558a85..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryCloseResult.java
+++ /dev/null
@@ -1,40 +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.odbc;
-
-/**
- * SQL listener query close result.
- */
-public class SqlListenerQueryCloseResult {
- /** Query ID. */
- private final long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public SqlListenerQueryCloseResult(long queryId){
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteRequest.java
deleted file mode 100644
index 3c77e06..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteRequest.java
+++ /dev/null
@@ -1,78 +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.odbc;
-
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * SQL listener query execute request.
- */
-public class SqlListenerQueryExecuteRequest extends SqlListenerRequest {
- /** Cache name. */
- private final String cacheName;
-
- /** Sql query. */
- @GridToStringInclude(sensitive = true)
- private final String sqlQry;
-
- /** Sql query arguments. */
- @GridToStringExclude
- private final Object[] args;
-
- /**
- * @param cacheName Cache name.
- * @param sqlQry SQL query.
- * @param args Arguments list.
- */
- public SqlListenerQueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
- super(QRY_EXEC);
-
- this.cacheName = cacheName.isEmpty() ? null : cacheName;
- this.sqlQry = sqlQry;
- this.args = args;
- }
-
- /**
- * @return Sql query.
- */
- public String sqlQuery() {
- return sqlQry;
- }
-
- /**
- * @return Sql query arguments.
- */
- public Object[] arguments() {
- return args;
- }
-
- /**
- * @return Cache name.
- */
- @Nullable public String cacheName() {
- return cacheName;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SqlListenerQueryExecuteRequest.class, this, "args", args, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteResult.java
deleted file mode 100644
index e4c0cb9..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryExecuteResult.java
+++ /dev/null
@@ -1,54 +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.odbc;
-
-import java.util.Collection;
-
-/**
- * SQL listener query execute result.
- */
-public class SqlListenerQueryExecuteResult {
- /** Query ID. */
- private final long queryId;
-
- /** Fields metadata. */
- private final Collection<SqlListenerColumnMeta> columnsMeta;
-
- /**
- * @param queryId Query ID.
- * @param columnsMeta Columns metadata.
- */
- public SqlListenerQueryExecuteResult(long queryId, Collection<SqlListenerColumnMeta> columnsMeta) {
- this.queryId = queryId;
- this.columnsMeta = columnsMeta;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-
- /**
- * @return Columns metadata.
- */
- public Collection<SqlListenerColumnMeta> getColumnsMetadata() {
- return columnsMeta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchRequest.java
deleted file mode 100644
index 41c3be0..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchRequest.java
+++ /dev/null
@@ -1,61 +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.odbc;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * SQL listener query fetch request.
- */
-public class SqlListenerQueryFetchRequest extends SqlListenerRequest {
- /** Query ID. */
- private final long queryId;
-
- /** Page size - maximum number of rows to return. */
- private final int pageSize;
-
- /**
- * @param queryId Query ID.
- * @param pageSize Page size.
- */
- public SqlListenerQueryFetchRequest(long queryId, int pageSize) {
- super(QRY_FETCH);
-
- this.queryId = queryId;
- this.pageSize = pageSize;
- }
-
- /**
- * @return Page size.
- */
- public int pageSize() {
- return pageSize;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SqlListenerQueryFetchRequest.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchResult.java
deleted file mode 100644
index 6763f8b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerQueryFetchResult.java
+++ /dev/null
@@ -1,66 +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.odbc;
-
-import java.util.Collection;
-
-/**
- * SQL listener query fetch result.
- */
-public class SqlListenerQueryFetchResult {
- /** Query ID. */
- private final long queryId;
-
- /** Query result rows. */
- private final Collection<?> items;
-
- /** Flag indicating the query has no unfetched results. */
- private final boolean last;
-
- /**
- * @param queryId Query ID.
- * @param items Query result rows.
- * @param last Flag indicating the query has no unfetched results.
- */
- public SqlListenerQueryFetchResult(long queryId, Collection<?> items, boolean last){
- this.queryId = queryId;
- this.items = items;
- this.last = last;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<?> items() {
- return items;
- }
-
- /**
- * @return Flag indicating the query has no unfetched results.
- */
- public boolean last() {
- return last;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
index 2714237..3c74752 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
@@ -20,49 +20,14 @@ package org.apache.ignite.internal.processors.odbc;
/**
* SQL listener command request.
*/
-public class SqlListenerRequest {
+public abstract class SqlListenerRequest {
/** Handshake request. */
public static final int HANDSHAKE = 1;
- /** Execute sql query. */
- public static final int QRY_EXEC = 2;
-
- /** Fetch query results. */
- public static final int QRY_FETCH = 3;
-
- /** Close query. */
- public static final int QRY_CLOSE = 4;
-
- /** Get columns meta query. */
- public static final int META_COLS = 5;
-
- /** Get columns meta query. */
- public static final int META_TBLS = 6;
-
- /** Get parameters meta. */
- public static final int META_PARAMS = 7;
-
- /** Command. */
- private final int cmd;
-
/** Request ID. */
private long reqId;
/**
- * @param cmd Command type.
- */
- public SqlListenerRequest(int cmd) {
- this.cmd = cmd;
- }
-
- /**
- * @return Command.
- */
- public int command() {
- return cmd;
- }
-
- /**
* @return Request ID.
*/
public long requestId() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/e92707b6/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
index 0ebb084..98dc039 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
@@ -28,4 +28,12 @@ public interface SqlListenerRequestHandler {
* @return Response.
*/
public SqlListenerResponse handle(SqlListenerRequest req);
+
+ /**
+ * Handle exception.
+ *
+ * @param e Exception.
+ * @return Error response.
+ */
+ public SqlListenerResponse handleException(Exception e);
}