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/05/11 09:56:15 UTC
[04/30] ignite git commit: IGNITE-5164: ODBC: renamed classes which
is obviously common with JDBC.
IGNITE-5164: ODBC: renamed classes which is obviously common with JDBC.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c7f09d8a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c7f09d8a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c7f09d8a
Branch: refs/heads/ignite-5075-cacheStart
Commit: c7f09d8a3cd6544eea7d78dcce8f8479ce905019
Parents: 7f8a430
Author: devozerov <vo...@gridgain.com>
Authored: Thu May 4 13:28:54 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu May 4 13:28:54 2017 +0300
----------------------------------------------------------------------
.../internal/processors/odbc/IgniteTypes.java | 69 -----------
.../processors/odbc/OdbcBufferedParser.java | 81 -------------
.../processors/odbc/OdbcColumnMeta.java | 110 ------------------
.../processors/odbc/OdbcConnectionData.java | 60 ++++++++++
.../processors/odbc/OdbcHandshakeRequest.java | 8 +-
.../processors/odbc/OdbcMessageParser.java | 48 ++++----
.../processors/odbc/OdbcNioListener.java | 44 +------
.../processors/odbc/OdbcNioServerBuffer.java | 114 -------------------
.../internal/processors/odbc/OdbcProcessor.java | 2 +-
.../processors/odbc/OdbcProtocolVersion.java | 88 --------------
.../processors/odbc/OdbcQueryCloseRequest.java | 49 --------
.../processors/odbc/OdbcQueryCloseResult.java | 40 -------
.../odbc/OdbcQueryExecuteRequest.java | 78 -------------
.../processors/odbc/OdbcQueryExecuteResult.java | 54 ---------
.../processors/odbc/OdbcQueryFetchRequest.java | 61 ----------
.../processors/odbc/OdbcQueryFetchResult.java | 66 -----------
.../odbc/OdbcQueryGetColumnsMetaRequest.java | 4 +-
.../odbc/OdbcQueryGetColumnsMetaResult.java | 6 +-
.../odbc/OdbcQueryGetParamsMetaRequest.java | 4 +-
.../odbc/OdbcQueryGetTablesMetaRequest.java | 4 +-
.../internal/processors/odbc/OdbcRequest.java | 61 ----------
.../processors/odbc/OdbcRequestHandler.java | 56 ++++-----
.../internal/processors/odbc/OdbcUtils.java | 32 +++---
.../odbc/SqlListenerBufferedParser.java | 81 +++++++++++++
.../processors/odbc/SqlListenerColumnMeta.java | 110 ++++++++++++++++++
.../processors/odbc/SqlListenerDataTypes.java | 69 +++++++++++
.../odbc/SqlListenerNioServerBuffer.java | 114 +++++++++++++++++++
.../odbc/SqlListenerProtocolVersion.java | 88 ++++++++++++++
.../odbc/SqlListenerQueryCloseRequest.java | 49 ++++++++
.../odbc/SqlListenerQueryCloseResult.java | 40 +++++++
.../odbc/SqlListenerQueryExecuteRequest.java | 78 +++++++++++++
.../odbc/SqlListenerQueryExecuteResult.java | 54 +++++++++
.../odbc/SqlListenerQueryFetchRequest.java | 61 ++++++++++
.../odbc/SqlListenerQueryFetchResult.java | 66 +++++++++++
.../processors/odbc/SqlListenerRequest.java | 61 ++++++++++
35 files changed, 1017 insertions(+), 993 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/IgniteTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/IgniteTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/IgniteTypes.java
deleted file mode 100644
index 1eea4e2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/IgniteTypes.java
+++ /dev/null
@@ -1,69 +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;
-
-/**
- * Data type names usable in SQL queries
- * after escape sequence transformation
- */
-public class IgniteTypes {
- /** Type name for 64-bit integer */
- static final String BIGINT = "BIGINT";
-
- /** Type name for byte array */
- static final String BINARY = "BINARY";
-
- /** Type name for boolean flag */
- static final String BIT = "BIT";
-
- /** Type name for unicode string */
- static final String CHAR = "CHAR";
-
- /** Type name for decimal number */
- static final String DECIMAL = "DECIMAL";
-
- /** Type name for unicode string */
- static final String VARCHAR = "VARCHAR";
-
- /** Type name for floating point number */
- static final String DOUBLE = "DOUBLE";
-
- /** Type name for single precision floating point number */
- static final String REAL = "REAL";
-
- /** Type name for universally unique identifier */
- static final String UUID = "UUID";
-
- /** Type name for 16-bit integer */
- static final String SMALLINT = "SMALLINT";
-
- /** Type name for 32-bit integer */
- static final String INTEGER = "INTEGER";
-
- /** Type name for 8-bit integer */
- static final String TINYINT = "TINYINT";
-
- /** Type name for date */
- static final String DATE = "DATE";
-
- /** Type name for time */
- static final String TIME = "TIME";
-
- /** Type name for timestamp */
- static final String TIMESTAMP = "TIMESTAMP";
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcBufferedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcBufferedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcBufferedParser.java
deleted file mode 100644
index 0d43aec..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcBufferedParser.java
+++ /dev/null
@@ -1,81 +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.IgniteCheckedException;
-import org.apache.ignite.internal.util.nio.GridNioParser;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * This class implements stream parser based on {@link OdbcNioServerBuffer}.
- * <p>
- * The rule for this parser is that every message sent over the stream is prepended with
- * 4-byte integer header containing message size. So, the stream structure is as follows:
- * <pre>
- * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
- * | MSG_SIZE | MESSAGE | MSG_SIZE | MESSAGE |
- * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
- * </pre>
- */
-public class OdbcBufferedParser implements GridNioParser {
- /** Buffer metadata key. */
- private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
-
- /** {@inheritDoc} */
- @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException {
- OdbcNioServerBuffer nioBuf = ses.meta(BUF_META_KEY);
-
- // Decode for a given session is called per one thread, so there should not be any concurrency issues.
- // However, we make some additional checks.
- if (nioBuf == null) {
- nioBuf = new OdbcNioServerBuffer();
-
- OdbcNioServerBuffer old = ses.addMeta(BUF_META_KEY, nioBuf);
-
- assert old == null;
- }
-
- return nioBuf.read(buf);
- }
-
- /** {@inheritDoc} */
- @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
- byte[] msg0 = (byte[])msg;
-
- ByteBuffer res = ByteBuffer.allocate(msg0.length + 4);
-
- res.order(ByteOrder.LITTLE_ENDIAN);
-
- res.putInt(msg0.length);
- res.put(msg0);
-
- res.flip();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return OdbcBufferedParser.class.getSimpleName();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
deleted file mode 100644
index 0edfabc..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.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;
-
-/**
- * ODBC column-related metadata.
- */
-public class OdbcColumnMeta {
- /** 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 OdbcColumnMeta(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 OdbcColumnMeta(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 OdbcColumnMeta) {
- OdbcColumnMeta other = (OdbcColumnMeta) 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/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcConnectionData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcConnectionData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcConnectionData.java
new file mode 100644
index 0000000..28a903d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcConnectionData.java
@@ -0,0 +1,60 @@
+/*
+ * 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.GridKernalContext;
+import org.apache.ignite.internal.util.GridSpinBusyLock;
+
+/**
+ * Connection-related data.
+ */
+class OdbcConnectionData {
+ /** Request handler. */
+ private final OdbcRequestHandler handler;
+
+ /** Message parser. */
+ private final OdbcMessageParser parser;
+
+ /**
+ * Constructor.
+ *
+ * @param ctx Context.
+ * @param busyLock Shutdown busy lock.
+ * @param maxCursors Maximum cursors.
+ */
+ public OdbcConnectionData(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors) {
+ handler = new OdbcRequestHandler(ctx, busyLock, maxCursors);
+ parser = new OdbcMessageParser(ctx);
+ }
+
+ /**
+ * Handler getter.
+ * @return Request handler for the connection.
+ */
+ public OdbcRequestHandler getHandler() {
+ return handler;
+ }
+
+ /**
+ * Parser getter
+ * @return Message parser for the connection.
+ */
+ public OdbcMessageParser getParser() {
+ return parser;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
index 55ff21f..7d337b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
@@ -22,9 +22,9 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC handshake request.
*/
-public class OdbcHandshakeRequest extends OdbcRequest {
+public class OdbcHandshakeRequest extends SqlListenerRequest {
/** Protocol version. */
- private final OdbcProtocolVersion ver;
+ private final SqlListenerProtocolVersion ver;
/** Distributed joins flag. */
private boolean distributedJoins = false;
@@ -38,13 +38,13 @@ public class OdbcHandshakeRequest extends OdbcRequest {
public OdbcHandshakeRequest(long ver) {
super(HANDSHAKE);
- this.ver = OdbcProtocolVersion.fromLong(ver);
+ this.ver = SqlListenerProtocolVersion.fromLong(ver);
}
/**
* @return Protocol version.
*/
- public OdbcProtocolVersion version() {
+ public SqlListenerProtocolVersion version() {
return ver;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
index a3d7308..d999501 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
@@ -63,7 +63,7 @@ public class OdbcMessageParser {
* @param msg Message.
* @return Assembled ODBC request.
*/
- public OdbcRequest decode(byte[] msg) {
+ public SqlListenerRequest decode(byte[] msg) {
assert msg != null;
BinaryInputStream stream = new BinaryHeapInputStream(msg);
@@ -75,15 +75,15 @@ public class OdbcMessageParser {
// This is a special case because we can not decode protocol messages until
// we has not confirmed that the remote client uses the same protocol version.
if (!verConfirmed) {
- if (cmd == OdbcRequest.HANDSHAKE)
+ if (cmd == SqlListenerRequest.HANDSHAKE)
{
long longVersion = reader.readLong();
OdbcHandshakeRequest res = new OdbcHandshakeRequest(longVersion);
- OdbcProtocolVersion version = res.version();
+ SqlListenerProtocolVersion version = res.version();
- if (version == OdbcProtocolVersion.UNKNOWN)
+ if (version == SqlListenerProtocolVersion.UNKNOWN)
return res;
res.distributedJoins(reader.readBoolean());
@@ -96,10 +96,10 @@ public class OdbcMessageParser {
"(first message is not a handshake request): [cmd=" + cmd + ']');
}
- OdbcRequest res;
+ SqlListenerRequest res;
switch (cmd) {
- case OdbcRequest.EXECUTE_SQL_QUERY: {
+ case SqlListenerRequest.QRY_EXEC: {
String cache = reader.readString();
String sql = reader.readString();
int argsNum = reader.readInt();
@@ -109,29 +109,29 @@ public class OdbcMessageParser {
for (int i = 0; i < argsNum; ++i)
params[i] = reader.readObjectDetached();
- res = new OdbcQueryExecuteRequest(cache, sql, params);
+ res = new SqlListenerQueryExecuteRequest(cache, sql, params);
break;
}
- case OdbcRequest.FETCH_SQL_QUERY: {
+ case SqlListenerRequest.QRY_FETCH: {
long queryId = reader.readLong();
int pageSize = reader.readInt();
- res = new OdbcQueryFetchRequest(queryId, pageSize);
+ res = new SqlListenerQueryFetchRequest(queryId, pageSize);
break;
}
- case OdbcRequest.CLOSE_SQL_QUERY: {
+ case SqlListenerRequest.QRY_CLOSE: {
long queryId = reader.readLong();
- res = new OdbcQueryCloseRequest(queryId);
+ res = new SqlListenerQueryCloseRequest(queryId);
break;
}
- case OdbcRequest.GET_COLUMNS_META: {
+ case SqlListenerRequest.META_COLS: {
String cache = reader.readString();
String table = reader.readString();
String column = reader.readString();
@@ -141,7 +141,7 @@ public class OdbcMessageParser {
break;
}
- case OdbcRequest.GET_TABLES_META: {
+ case SqlListenerRequest.META_TBLS: {
String catalog = reader.readString();
String schema = reader.readString();
String table = reader.readString();
@@ -152,7 +152,7 @@ public class OdbcMessageParser {
break;
}
- case OdbcRequest.GET_PARAMS_META: {
+ case SqlListenerRequest.META_PARAMS: {
String cacheName = reader.readString();
String sqlQuery = reader.readString();
@@ -212,25 +212,25 @@ public class OdbcMessageParser {
writer.writeString(res.currentVersion());
}
}
- else if (res0 instanceof OdbcQueryExecuteResult) {
- OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0;
+ else if (res0 instanceof SqlListenerQueryExecuteResult) {
+ SqlListenerQueryExecuteResult res = (SqlListenerQueryExecuteResult) res0;
if (log.isDebugEnabled())
log.debug("Resulting query ID: " + res.getQueryId());
writer.writeLong(res.getQueryId());
- Collection<OdbcColumnMeta> metas = res.getColumnsMetadata();
+ Collection<SqlListenerColumnMeta> metas = res.getColumnsMetadata();
assert metas != null;
writer.writeInt(metas.size());
- for (OdbcColumnMeta meta : metas)
+ for (SqlListenerColumnMeta meta : metas)
meta.write(writer);
}
- else if (res0 instanceof OdbcQueryFetchResult) {
- OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0;
+ else if (res0 instanceof SqlListenerQueryFetchResult) {
+ SqlListenerQueryFetchResult res = (SqlListenerQueryFetchResult) res0;
if (log.isDebugEnabled())
log.debug("Resulting query ID: " + res.queryId());
@@ -271,8 +271,8 @@ public class OdbcMessageParser {
}
}
}
- else if (res0 instanceof OdbcQueryCloseResult) {
- OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0;
+ else if (res0 instanceof SqlListenerQueryCloseResult) {
+ SqlListenerQueryCloseResult res = (SqlListenerQueryCloseResult) res0;
if (log.isDebugEnabled())
log.debug("Resulting query ID: " + res.getQueryId());
@@ -282,13 +282,13 @@ public class OdbcMessageParser {
else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0;
- Collection<OdbcColumnMeta> columnsMeta = res.meta();
+ Collection<SqlListenerColumnMeta> columnsMeta = res.meta();
assert columnsMeta != null;
writer.writeInt(columnsMeta.size());
- for (OdbcColumnMeta columnMeta : columnsMeta)
+ for (SqlListenerColumnMeta columnMeta : columnsMeta)
columnMeta.write(writer);
}
else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
index 378e5f2..b0146e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]> {
/** Connection-related metadata key. */
- private static final int CONNECTION_DATA_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
+ private static final int CONN_DATA_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
/** Request ID generator. */
private static final AtomicLong REQ_ID_GEN = new AtomicLong();
@@ -69,7 +69,7 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]> {
if (log.isDebugEnabled())
log.debug("ODBC client connected: " + ses.remoteAddress());
- ses.addMeta(CONNECTION_DATA_META_KEY, new ConnectionData(ctx, busyLock));
+ ses.addMeta(CONN_DATA_META_KEY, new OdbcConnectionData(ctx, busyLock, maxCursors));
}
/** {@inheritDoc} */
@@ -88,13 +88,13 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]> {
long reqId = REQ_ID_GEN.incrementAndGet();
- ConnectionData connData = ses.meta(CONNECTION_DATA_META_KEY);
+ OdbcConnectionData connData = ses.meta(CONN_DATA_META_KEY);
assert connData != null;
OdbcMessageParser parser = connData.getParser();
- OdbcRequest req;
+ SqlListenerRequest req;
try {
req = parser.decode(msg);
@@ -140,40 +140,4 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]> {
ses.send(parser.encode(new OdbcResponse(OdbcResponse.STATUS_FAILED, e.toString())));
}
}
-
- /**
- * Connection-related data.
- */
- private class ConnectionData {
- /** Request handler. */
- private final OdbcRequestHandler handler;
-
- /** Message parser. */
- private final OdbcMessageParser parser;
-
- /**
- * @param ctx Context.
- * @param busyLock Shutdown busy lock.
- */
- public ConnectionData(GridKernalContext ctx, GridSpinBusyLock busyLock) {
- handler = new OdbcRequestHandler(ctx, busyLock, maxCursors);
- parser = new OdbcMessageParser(ctx);
- }
-
- /**
- * Handler getter.
- * @return Request handler for the connection.
- */
- public OdbcRequestHandler getHandler() {
- return handler;
- }
-
- /**
- * Parser getter
- * @return Message parser for the connection.
- */
- public OdbcMessageParser getParser() {
- return parser;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioServerBuffer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioServerBuffer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioServerBuffer.java
deleted file mode 100644
index d1e6dd9..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioServerBuffer.java
+++ /dev/null
@@ -1,114 +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.IgniteCheckedException;
-import org.jetbrains.annotations.Nullable;
-
-import java.nio.ByteBuffer;
-
-/**
- * NIO server buffer.
- */
-public class OdbcNioServerBuffer {
- /** Current message data. */
- private byte[] data;
-
- /** Count of received bytes of the current message. */
- private int cnt = -4;
-
- /** Current message size. */
- private int msgSize;
-
- /**
- * Reset buffer state.
- */
- public void reset() {
- msgSize = 0;
- cnt = -4;
- data = null;
- }
-
- /**
- * Checks whether the byte array is filled.
- *
- * @return Flag indicating whether byte array is filled or not.
- */
- public boolean isFilled() {
- return cnt > 0 && cnt == msgSize;
- }
-
- /**
- * Get data withing the buffer.
- *
- * @return Data.
- */
- public byte[] data() {
- return data;
- }
-
- /**
- * @param buf Buffer.
- * @return Message bytes or {@code null} if message is not fully read yet.
- * @throws IgniteCheckedException If failed to parse message.
- */
- @Nullable public byte[] read(ByteBuffer buf) throws IgniteCheckedException {
- if (cnt < 0) {
- for (; cnt < 0 && buf.hasRemaining(); cnt++)
- msgSize |= (buf.get() & 0xFF) << (8*(4 + cnt));
-
- if (cnt < 0)
- return null;
-
- // If count is 0 then message size should be inited.
- if (msgSize <= 0)
- throw new IgniteCheckedException("Invalid message size: " + msgSize);
-
- data = new byte[msgSize];
- }
-
- assert msgSize > 0;
- assert cnt >= 0;
-
- int remaining = buf.remaining();
-
- // If there are more bytes in buffer.
- if (remaining > 0) {
- int missing = msgSize - cnt;
-
- // Read only up to message size.
- if (missing > 0) {
- int len = missing < remaining ? missing : remaining;
-
- buf.get(data, cnt, len);
-
- cnt += len;
- }
- }
-
- if (cnt == msgSize) {
- byte[] data0 = data;
-
- reset();
-
- return data0;
- }
- else
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
index 054f0dc..6b8b5a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
@@ -128,7 +128,7 @@ public class OdbcProcessor extends GridProcessorAdapter {
proceedSessionOpened(ses);
}
},
- new GridNioCodecFilter(new OdbcBufferedParser(), log, false)
+ new GridNioCodecFilter(new SqlListenerBufferedParser(), log, false)
};
GridNioServer<byte[]> srv0 = GridNioServer.<byte[]>builder()
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
deleted file mode 100644
index 5c156d2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.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;
-
-/**
- * ODBC protocol version.
- */
-public enum OdbcProtocolVersion {
- /** Version 2.1.0. */
- VER_2_1_0(makeVersion(2, 1, 0), "2.1.0"),
-
- /** Unknown version. */
- UNKNOWN(Long.MIN_VALUE, "UNKNOWN");
-
- /** Mask to get 2 lowest bytes of the value and cast to long. */
- private static final long LONG_MASK = 0x000000000000FFFFL;
-
- /** Long value for version. */
- private final long longVal;
-
- /** Since string. */
- private final String since;
-
- /**
- * Constructor.
- *
- * @param longVal Long value.
- * @param since Since string.
- */
- OdbcProtocolVersion(long longVal, String since) {
- this.longVal = longVal;
- this.since = since;
- }
-
- /**
- * Make long value for the version.
- *
- * @param major Major version.
- * @param minor Minor version.
- * @param maintenance Maintenance version.
- * @return Long value for the version.
- */
- private static long makeVersion(int major, int minor, int maintenance) {
- return ((major & LONG_MASK) << 48) | ((minor & LONG_MASK) << 32) | ((maintenance & LONG_MASK) << 16);
- }
-
- /**
- * @param longVal Long value.
- * @return Protocol version.
- */
- public static OdbcProtocolVersion fromLong(long longVal) {
- for (OdbcProtocolVersion ver : OdbcProtocolVersion.values()) {
- if (ver.longValue() == longVal)
- return ver;
- }
-
- return UNKNOWN;
- }
-
- /**
- * @return Long value.
- */
- public long longValue() {
- return longVal;
- }
-
- /**
- * @return Ignite version when introduced.
- */
- public String since() {
- return since;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
deleted file mode 100644
index 8c081ef..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.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;
-
-/**
- * ODBC query close request.
- */
-public class OdbcQueryCloseRequest extends OdbcRequest {
- /** Query ID. */
- private final long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public OdbcQueryCloseRequest(long queryId) {
- super(CLOSE_SQL_QUERY);
-
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(OdbcQueryCloseRequest.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
deleted file mode 100644
index 9a85e43..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.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 result.
- */
-public class OdbcQueryCloseResult {
- /** Query ID. */
- private final long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public OdbcQueryCloseResult(long queryId){
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
deleted file mode 100644
index c0d1c60..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.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;
-
-/**
- * ODBC query execute request.
- */
-public class OdbcQueryExecuteRequest extends OdbcRequest {
- /** 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 OdbcQueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
- super(EXECUTE_SQL_QUERY);
-
- 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(OdbcQueryExecuteRequest.class, this, "args", args, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
deleted file mode 100644
index a403812..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.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;
-
-/**
- * Query execute result.
- */
-public class OdbcQueryExecuteResult {
- /** Query ID. */
- private final long queryId;
-
- /** Fields metadata. */
- private final Collection<OdbcColumnMeta> columnsMeta;
-
- /**
- * @param queryId Query ID.
- * @param columnsMeta Columns metadata.
- */
- public OdbcQueryExecuteResult(long queryId, Collection<OdbcColumnMeta> columnsMeta) {
- this.queryId = queryId;
- this.columnsMeta = columnsMeta;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-
- /**
- * @return Columns metadata.
- */
- public Collection<OdbcColumnMeta> getColumnsMetadata() {
- return columnsMeta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
deleted file mode 100644
index 58bc43a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.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;
-
-/**
- * ODBC query fetch request.
- */
-public class OdbcQueryFetchRequest extends OdbcRequest {
- /** 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 OdbcQueryFetchRequest(long queryId, int pageSize) {
- super(FETCH_SQL_QUERY);
-
- 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(OdbcQueryFetchRequest.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
deleted file mode 100644
index f72d7e1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.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;
-
-/**
- * Query fetch result.
- */
-public class OdbcQueryFetchResult {
- /** 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 OdbcQueryFetchResult(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/c7f09d8a/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
index 875be89..bdfaa1d 100644
--- 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
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
/**
* ODBC query get columns meta request.
*/
-public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
+public class OdbcQueryGetColumnsMetaRequest extends SqlListenerRequest {
/** Cache name. */
private final String cacheName;
@@ -39,7 +39,7 @@ public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
* @param columnName Column name.
*/
public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
- super(GET_COLUMNS_META);
+ super(META_COLS);
this.cacheName = cacheName;
this.tableName = tableName;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/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
index 256b15b..28daa56 100644
--- 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
@@ -24,19 +24,19 @@ import java.util.Collection;
*/
public class OdbcQueryGetColumnsMetaResult {
/** Query result rows. */
- private final Collection<OdbcColumnMeta> meta;
+ private final Collection<SqlListenerColumnMeta> meta;
/**
* @param meta Column metadata.
*/
- public OdbcQueryGetColumnsMetaResult(Collection<OdbcColumnMeta> meta) {
+ public OdbcQueryGetColumnsMetaResult(Collection<SqlListenerColumnMeta> meta) {
this.meta = meta;
}
/**
* @return Query result rows.
*/
- public Collection<OdbcColumnMeta> meta() {
+ public Collection<SqlListenerColumnMeta> meta() {
return meta;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/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
index c372c0b..e6a97e3 100644
--- 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
@@ -22,7 +22,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC query get params meta request.
*/
-public class OdbcQueryGetParamsMetaRequest extends OdbcRequest {
+public class OdbcQueryGetParamsMetaRequest extends SqlListenerRequest {
/** Cache. */
private final String cacheName;
@@ -33,7 +33,7 @@ public class OdbcQueryGetParamsMetaRequest extends OdbcRequest {
* @param query SQL Query.
*/
public OdbcQueryGetParamsMetaRequest(String cacheName, String query) {
- super(GET_PARAMS_META);
+ super(META_PARAMS);
this.cacheName = cacheName;
this.query = query;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/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
index a56aad2..772c487 100644
--- 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
@@ -22,7 +22,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC query get tables meta request.
*/
-public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
+public class OdbcQueryGetTablesMetaRequest extends SqlListenerRequest {
/** Catalog search pattern. */
private final String catalog;
@@ -42,7 +42,7 @@ public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
* @param tableType Table type search pattern.
*/
public OdbcQueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) {
- super(GET_TABLES_META);
+ super(META_TBLS);
this.catalog = catalog;
this.schema = schema;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
deleted file mode 100644
index f056fed..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.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;
-
-/**
- * ODBC command request.
- */
-public class OdbcRequest {
- /** Handshake request. */
- public static final int HANDSHAKE = 1;
-
- /** Execute sql query. */
- public static final int EXECUTE_SQL_QUERY = 2;
-
- /** Fetch query results. */
- public static final int FETCH_SQL_QUERY = 3;
-
- /** Close query. */
- public static final int CLOSE_SQL_QUERY = 4;
-
- /** Get columns meta query. */
- public static final int GET_COLUMNS_META = 5;
-
- /** Get columns meta query. */
- public static final int GET_TABLES_META = 6;
-
- /** Get parameters meta. */
- public static final int GET_PARAMS_META = 7;
-
- /** Command. */
- private final int cmd;
-
- /**
- * @param cmd Command type.
- */
- public OdbcRequest(int cmd) {
- this.cmd = cmd;
- }
-
- /**
- * @return Command.
- */
- public int command() {
- return cmd;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
index c17dd63..d98c366 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
@@ -40,7 +40,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import static org.apache.ignite.internal.processors.odbc.OdbcRequest.*;
+import static org.apache.ignite.internal.processors.odbc.SqlListenerRequest.*;
/**
* SQL query handler.
@@ -92,7 +92,7 @@ public class OdbcRequestHandler {
* @param req Request.
* @return Response.
*/
- public OdbcResponse handle(long reqId, OdbcRequest req) {
+ public OdbcResponse handle(long reqId, SqlListenerRequest req) {
assert req != null;
if (!busyLock.enterBusy())
@@ -104,22 +104,22 @@ public class OdbcRequestHandler {
case HANDSHAKE:
return performHandshake(reqId, (OdbcHandshakeRequest)req);
- case EXECUTE_SQL_QUERY:
- return executeQuery(reqId, (OdbcQueryExecuteRequest)req);
+ case QRY_EXEC:
+ return executeQuery(reqId, (SqlListenerQueryExecuteRequest)req);
- case FETCH_SQL_QUERY:
- return fetchQuery(reqId, (OdbcQueryFetchRequest)req);
+ case QRY_FETCH:
+ return fetchQuery(reqId, (SqlListenerQueryFetchRequest)req);
- case CLOSE_SQL_QUERY:
- return closeQuery(reqId, (OdbcQueryCloseRequest)req);
+ case QRY_CLOSE:
+ return closeQuery(reqId, (SqlListenerQueryCloseRequest)req);
- case GET_COLUMNS_META:
+ case META_COLS:
return getColumnsMeta(reqId, (OdbcQueryGetColumnsMetaRequest)req);
- case GET_TABLES_META:
+ case META_TBLS:
return getTablesMeta(reqId, (OdbcQueryGetTablesMetaRequest)req);
- case GET_PARAMS_META:
+ case META_PARAMS:
return getParamsMeta(reqId, (OdbcQueryGetParamsMetaRequest)req);
}
@@ -139,9 +139,9 @@ public class OdbcRequestHandler {
*/
private OdbcResponse performHandshake(long reqId, OdbcHandshakeRequest req) {
try {
- OdbcProtocolVersion version = req.version();
+ SqlListenerProtocolVersion version = req.version();
- if (version == OdbcProtocolVersion.UNKNOWN) {
+ if (version == SqlListenerProtocolVersion.UNKNOWN) {
IgniteProductVersion ver = ctx.grid().version();
String verStr = Byte.toString(ver.major()) + '.' + ver.minor() + '.' + ver.maintenance();
@@ -166,13 +166,13 @@ public class OdbcRequestHandler {
}
/**
- * {@link OdbcQueryExecuteRequest} command handler.
+ * {@link SqlListenerQueryExecuteRequest} command handler.
*
* @param reqId Request ID.
* @param req Execute query request.
* @return Response.
*/
- private OdbcResponse executeQuery(long reqId, OdbcQueryExecuteRequest req) {
+ private OdbcResponse executeQuery(long reqId, SqlListenerQueryExecuteRequest req) {
int cursorCnt = qryCursors.size();
if (maxCursors > 0 && cursorCnt >= maxCursors)
@@ -214,7 +214,7 @@ public class OdbcRequestHandler {
List<?> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
- OdbcQueryExecuteResult res = new OdbcQueryExecuteResult(qryId, convertMetadata(fieldsMeta));
+ SqlListenerQueryExecuteResult res = new SqlListenerQueryExecuteResult(qryId, convertMetadata(fieldsMeta));
return new OdbcResponse(res);
}
@@ -228,13 +228,13 @@ public class OdbcRequestHandler {
}
/**
- * {@link OdbcQueryCloseRequest} command handler.
+ * {@link SqlListenerQueryCloseRequest} command handler.
*
* @param reqId Request ID.
* @param req Execute query request.
* @return Response.
*/
- private OdbcResponse closeQuery(long reqId, OdbcQueryCloseRequest req) {
+ private OdbcResponse closeQuery(long reqId, SqlListenerQueryCloseRequest req) {
try {
IgniteBiTuple<QueryCursor, Iterator> tuple = qryCursors.get(req.queryId());
@@ -249,7 +249,7 @@ public class OdbcRequestHandler {
qryCursors.remove(req.queryId());
- OdbcQueryCloseResult res = new OdbcQueryCloseResult(req.queryId());
+ SqlListenerQueryCloseResult res = new SqlListenerQueryCloseResult(req.queryId());
return new OdbcResponse(res);
}
@@ -263,13 +263,13 @@ public class OdbcRequestHandler {
}
/**
- * {@link OdbcQueryFetchRequest} command handler.
+ * {@link SqlListenerQueryFetchRequest} command handler.
*
* @param reqId Request ID.
* @param req Execute query request.
* @return Response.
*/
- private OdbcResponse fetchQuery(long reqId, OdbcQueryFetchRequest req) {
+ private OdbcResponse fetchQuery(long reqId, SqlListenerQueryFetchRequest req) {
try {
IgniteBiTuple<QueryCursor, Iterator> tuple = qryCursors.get(req.queryId());
@@ -291,7 +291,7 @@ public class OdbcRequestHandler {
for (int i = 0; i < req.pageSize() && iter.hasNext(); ++i)
items.add(iter.next());
- OdbcQueryFetchResult res = new OdbcQueryFetchResult(req.queryId(), items, !iter.hasNext());
+ SqlListenerQueryFetchResult res = new SqlListenerQueryFetchResult(req.queryId(), items, !iter.hasNext());
return new OdbcResponse(res);
}
@@ -311,7 +311,7 @@ public class OdbcRequestHandler {
*/
private OdbcResponse getColumnsMeta(long reqId, OdbcQueryGetColumnsMetaRequest req) {
try {
- List<OdbcColumnMeta> meta = new ArrayList<>();
+ List<SqlListenerColumnMeta> meta = new ArrayList<>();
String cacheName;
String tableName;
@@ -340,7 +340,7 @@ public class OdbcRequestHandler {
if (!matches(field.getKey(), req.columnName()))
continue;
- OdbcColumnMeta columnMeta = new OdbcColumnMeta(req.cacheName(), table.name(),
+ SqlListenerColumnMeta columnMeta = new SqlListenerColumnMeta(req.cacheName(), table.name(),
field.getKey(), field.getValue());
if (!meta.contains(columnMeta))
@@ -497,19 +497,19 @@ public class OdbcRequestHandler {
/**
* Convert metadata in collection from {@link GridQueryFieldMetadata} to
- * {@link OdbcColumnMeta}.
+ * {@link SqlListenerColumnMeta}.
*
* @param meta Internal query field metadata.
* @return Odbc query field metadata.
*/
- private static Collection<OdbcColumnMeta> convertMetadata(Collection<?> meta) {
- List<OdbcColumnMeta> res = new ArrayList<>();
+ private static Collection<SqlListenerColumnMeta> convertMetadata(Collection<?> meta) {
+ List<SqlListenerColumnMeta> res = new ArrayList<>();
if (meta != null) {
for (Object info : meta) {
assert info instanceof GridQueryFieldMetadata;
- res.add(new OdbcColumnMeta((GridQueryFieldMetadata)info));
+ res.add(new SqlListenerColumnMeta((GridQueryFieldMetadata)info));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
index 668ce6a..8bf1959 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
@@ -24,7 +24,7 @@ import org.apache.ignite.IgniteException;
*/
public class OdbcUtils {
/** Latest version. */
- public static final OdbcProtocolVersion VER_LATEST = OdbcProtocolVersion.VER_2_1_0;
+ public static final SqlListenerProtocolVersion VER_LATEST = SqlListenerProtocolVersion.VER_2_1_0;
/**
* Add quotation marks at the beginning and end of the string.
@@ -69,57 +69,57 @@ public class OdbcUtils {
assert odbcDataType != null;
switch (odbcDataType.toUpperCase()) {
case OdbcTypes.SQL_BIGINT:
- return IgniteTypes.BIGINT;
+ return SqlListenerDataTypes.BIGINT;
case OdbcTypes.SQL_BINARY:
case OdbcTypes.SQL_LONGVARBINARY:
case OdbcTypes.SQL_VARBINARY:
- return IgniteTypes.BINARY;
+ return SqlListenerDataTypes.BINARY;
case OdbcTypes.SQL_BIT:
- return IgniteTypes.BIT;
+ return SqlListenerDataTypes.BIT;
case OdbcTypes.SQL_CHAR:
- return IgniteTypes.CHAR;
+ return SqlListenerDataTypes.CHAR;
case OdbcTypes.SQL_DECIMAL:
case OdbcTypes.SQL_NUMERIC:
- return IgniteTypes.DECIMAL;
+ return SqlListenerDataTypes.DECIMAL;
case OdbcTypes.SQL_LONGVARCHAR:
case OdbcTypes.SQL_VARCHAR:
case OdbcTypes.SQL_WCHAR:
case OdbcTypes.SQL_WLONGVARCHAR:
case OdbcTypes.SQL_WVARCHAR:
- return IgniteTypes.VARCHAR;
+ return SqlListenerDataTypes.VARCHAR;
case OdbcTypes.SQL_DOUBLE:
case OdbcTypes.SQL_FLOAT:
- return IgniteTypes.DOUBLE;
+ return SqlListenerDataTypes.DOUBLE;
case OdbcTypes.SQL_REAL:
- return IgniteTypes.REAL;
+ return SqlListenerDataTypes.REAL;
case OdbcTypes.SQL_GUID:
- return IgniteTypes.UUID;
+ return SqlListenerDataTypes.UUID;
case OdbcTypes.SQL_SMALLINT:
- return IgniteTypes.SMALLINT;
+ return SqlListenerDataTypes.SMALLINT;
case OdbcTypes.SQL_INTEGER:
- return IgniteTypes.INTEGER;
+ return SqlListenerDataTypes.INTEGER;
case OdbcTypes.SQL_DATE:
- return IgniteTypes.DATE;
+ return SqlListenerDataTypes.DATE;
case OdbcTypes.SQL_TIME:
- return IgniteTypes.TIME;
+ return SqlListenerDataTypes.TIME;
case OdbcTypes.SQL_TIMESTAMP:
- return IgniteTypes.TIMESTAMP;
+ return SqlListenerDataTypes.TIMESTAMP;
case OdbcTypes.SQL_TINYINT:
- return IgniteTypes.TINYINT;
+ return SqlListenerDataTypes.TINYINT;
//No support for interval types
case OdbcTypes.SQL_INTERVAL_SECOND:
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java
new file mode 100644
index 0000000..a8e124f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java
@@ -0,0 +1,81 @@
+/*
+ * 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.IgniteCheckedException;
+import org.apache.ignite.internal.util.nio.GridNioParser;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * This class implements stream parser based on {@link SqlListenerNioServerBuffer}.
+ * <p>
+ * The rule for this parser is that every message sent over the stream is prepended with
+ * 4-byte integer header containing message size. So, the stream structure is as follows:
+ * <pre>
+ * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
+ * | MSG_SIZE | MESSAGE | MSG_SIZE | MESSAGE |
+ * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
+ * </pre>
+ */
+public class SqlListenerBufferedParser implements GridNioParser {
+ /** Buffer metadata key. */
+ private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
+
+ /** {@inheritDoc} */
+ @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException {
+ SqlListenerNioServerBuffer nioBuf = ses.meta(BUF_META_KEY);
+
+ // Decode for a given session is called per one thread, so there should not be any concurrency issues.
+ // However, we make some additional checks.
+ if (nioBuf == null) {
+ nioBuf = new SqlListenerNioServerBuffer();
+
+ SqlListenerNioServerBuffer old = ses.addMeta(BUF_META_KEY, nioBuf);
+
+ assert old == null;
+ }
+
+ return nioBuf.read(buf);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
+ byte[] msg0 = (byte[])msg;
+
+ ByteBuffer res = ByteBuffer.allocate(msg0.length + 4);
+
+ res.order(ByteOrder.LITTLE_ENDIAN);
+
+ res.putInt(msg0.length);
+ res.put(msg0);
+
+ res.flip();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return SqlListenerBufferedParser.class.getSimpleName();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/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
new file mode 100644
index 0000000..73133a1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerColumnMeta.java
@@ -0,0 +1,110 @@
+/*
+ * 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/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
new file mode 100644
index 0000000..0f0bfdd
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+/**
+ * Data type names usable in SQL queries
+ * after escape sequence transformation
+ */
+public class SqlListenerDataTypes {
+ /** Type name for 64-bit integer */
+ static final String BIGINT = "BIGINT";
+
+ /** Type name for byte array */
+ static final String BINARY = "BINARY";
+
+ /** Type name for boolean flag */
+ static final String BIT = "BIT";
+
+ /** Type name for unicode string */
+ static final String CHAR = "CHAR";
+
+ /** Type name for decimal number */
+ static final String DECIMAL = "DECIMAL";
+
+ /** Type name for unicode string */
+ static final String VARCHAR = "VARCHAR";
+
+ /** Type name for floating point number */
+ static final String DOUBLE = "DOUBLE";
+
+ /** Type name for single precision floating point number */
+ static final String REAL = "REAL";
+
+ /** Type name for universally unique identifier */
+ static final String UUID = "UUID";
+
+ /** Type name for 16-bit integer */
+ static final String SMALLINT = "SMALLINT";
+
+ /** Type name for 32-bit integer */
+ static final String INTEGER = "INTEGER";
+
+ /** Type name for 8-bit integer */
+ static final String TINYINT = "TINYINT";
+
+ /** Type name for date */
+ static final String DATE = "DATE";
+
+ /** Type name for time */
+ static final String TIME = "TIME";
+
+ /** Type name for timestamp */
+ static final String TIMESTAMP = "TIMESTAMP";
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java
new file mode 100644
index 0000000..cf8a0ad
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java
@@ -0,0 +1,114 @@
+/*
+ * 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.IgniteCheckedException;
+import org.jetbrains.annotations.Nullable;
+
+import java.nio.ByteBuffer;
+
+/**
+ * NIO server buffer.
+ */
+public class SqlListenerNioServerBuffer {
+ /** Current message data. */
+ private byte[] data;
+
+ /** Count of received bytes of the current message. */
+ private int cnt = -4;
+
+ /** Current message size. */
+ private int msgSize;
+
+ /**
+ * Reset buffer state.
+ */
+ public void reset() {
+ msgSize = 0;
+ cnt = -4;
+ data = null;
+ }
+
+ /**
+ * Checks whether the byte array is filled.
+ *
+ * @return Flag indicating whether byte array is filled or not.
+ */
+ public boolean isFilled() {
+ return cnt > 0 && cnt == msgSize;
+ }
+
+ /**
+ * Get data withing the buffer.
+ *
+ * @return Data.
+ */
+ public byte[] data() {
+ return data;
+ }
+
+ /**
+ * @param buf Buffer.
+ * @return Message bytes or {@code null} if message is not fully read yet.
+ * @throws IgniteCheckedException If failed to parse message.
+ */
+ @Nullable public byte[] read(ByteBuffer buf) throws IgniteCheckedException {
+ if (cnt < 0) {
+ for (; cnt < 0 && buf.hasRemaining(); cnt++)
+ msgSize |= (buf.get() & 0xFF) << (8*(4 + cnt));
+
+ if (cnt < 0)
+ return null;
+
+ // If count is 0 then message size should be inited.
+ if (msgSize <= 0)
+ throw new IgniteCheckedException("Invalid message size: " + msgSize);
+
+ data = new byte[msgSize];
+ }
+
+ assert msgSize > 0;
+ assert cnt >= 0;
+
+ int remaining = buf.remaining();
+
+ // If there are more bytes in buffer.
+ if (remaining > 0) {
+ int missing = msgSize - cnt;
+
+ // Read only up to message size.
+ if (missing > 0) {
+ int len = missing < remaining ? missing : remaining;
+
+ buf.get(data, cnt, len);
+
+ cnt += len;
+ }
+ }
+
+ if (cnt == msgSize) {
+ byte[] data0 = data;
+
+ reset();
+
+ return data0;
+ }
+ else
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f09d8a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java
new file mode 100644
index 0000000..372188c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java
@@ -0,0 +1,88 @@
+/*
+ * 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 protocol version.
+ */
+public enum SqlListenerProtocolVersion {
+ /** Version 2.1.0. */
+ VER_2_1_0(makeVersion(2, 1, 0), "2.1.0"),
+
+ /** Unknown version. */
+ UNKNOWN(Long.MIN_VALUE, "UNKNOWN");
+
+ /** Mask to get 2 lowest bytes of the value and cast to long. */
+ private static final long LONG_MASK = 0x000000000000FFFFL;
+
+ /** Long value for version. */
+ private final long longVal;
+
+ /** Since string. */
+ private final String since;
+
+ /**
+ * Constructor.
+ *
+ * @param longVal Long value.
+ * @param since Since string.
+ */
+ SqlListenerProtocolVersion(long longVal, String since) {
+ this.longVal = longVal;
+ this.since = since;
+ }
+
+ /**
+ * Make long value for the version.
+ *
+ * @param major Major version.
+ * @param minor Minor version.
+ * @param maintenance Maintenance version.
+ * @return Long value for the version.
+ */
+ private static long makeVersion(int major, int minor, int maintenance) {
+ return ((major & LONG_MASK) << 48) | ((minor & LONG_MASK) << 32) | ((maintenance & LONG_MASK) << 16);
+ }
+
+ /**
+ * @param longVal Long value.
+ * @return Protocol version.
+ */
+ public static SqlListenerProtocolVersion fromLong(long longVal) {
+ for (SqlListenerProtocolVersion ver : SqlListenerProtocolVersion.values()) {
+ if (ver.longValue() == longVal)
+ return ver;
+ }
+
+ return UNKNOWN;
+ }
+
+ /**
+ * @return Long value.
+ */
+ public long longValue() {
+ return longVal;
+ }
+
+ /**
+ * @return Ignite version when introduced.
+ */
+ public String since() {
+ return since;
+ }
+}