http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java deleted file mode 100644 index 01e4ef5..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java +++ /dev/null @@ -1,191 +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.protocol; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.configuration.ConnectorConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.OdbcConfiguration; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.odbc.GridOdbcProtocolHandler; -import org.apache.ignite.internal.processors.odbc.request.GridOdbcRequest; -import org.apache.ignite.internal.util.nio.*; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgnitePortProtocol; - -import java.io.IOException; -import java.net.InetAddress; -import java.nio.ByteOrder; - -/** - * TCP server that handles communication with ODBC driver. - */ -public class GridTcpOdbcServer { - - /** Server. */ - private GridNioServer<GridOdbcRequest> srv; - - /** NIO server listener. */ - private GridNioServerListener<GridOdbcRequest> lsnr; - - /** Logger. */ - protected final IgniteLogger log; - - /** Context. */ - protected final GridKernalContext ctx; - - /** Host used by this protocol. */ - protected InetAddress host; - - /** Port used by this protocol. */ - protected int port; - - /** */ - public String name() { - return "ODBC server"; - } - - public GridTcpOdbcServer(GridKernalContext ctx) { - assert ctx != null; - assert ctx.config().getConnectorConfiguration() != null; - - this.ctx = ctx; - - log = ctx.log(getClass()); - } - - @SuppressWarnings("BusyWait") - public void start(final GridOdbcProtocolHandler hnd) throws IgniteCheckedException { - OdbcConfiguration cfg = ctx.config().getOdbcConfiguration(); - - assert cfg != null; - - lsnr = new GridTcpOdbcNioListener(log, this, ctx, hnd); - - GridNioParser parser = new GridOdbcParser(ctx); - - try { - host = resolveOdbcTcpHost(ctx.config()); - - int odbcPort = cfg.getPort(); - - if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) { - port = odbcPort; - - System.out.println("ODBC Server has started on TCP port " + port); - - return; - } - - U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " + - "[odbcPort=" + odbcPort + ", host=" + host + ']'); - } - catch (IOException e) { - U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(), - "Failed to start " + name() + " on port " + port + ". " + - "Check restTcpHost configuration property."); - } - } - - /** */ - public void onKernalStart() { - } - - /** */ - public void stop() { - if (srv != null) { - ctx.ports().deregisterPorts(getClass()); - - srv.stop(); - } - } - - /** - * Resolves host for server using grid configuration. - * - * @param cfg Grid configuration. - * @return Host address. - * @throws IOException If failed to resolve host. - */ - private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException { - String host = null; - - ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration(); - - if (connectionCfg != null) - host = connectionCfg.getHost(); - - if (host == null) - host = cfg.getLocalHost(); - - return U.resolveLocalHost(host); - } - - /** - * Tries to start server with given parameters. - * - * @param hostAddr Host on which server should be bound. - * @param port Port on which server should be bound. - * @param lsnr Server message listener. - * @param parser Server message parser. - * @param cfg Configuration for other parameters. - * @return {@code True} if server successfully started, {@code false} if port is used and - * server was unable to start. - */ - private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<GridOdbcRequest> lsnr, - GridNioParser parser, OdbcConfiguration cfg) { - try { - GridNioFilter codec = new GridNioCodecFilter(parser, log, false); - - GridNioFilter[] filters; - - filters = new GridNioFilter[] { codec }; - - srv = GridNioServer.<GridOdbcRequest>builder() - .address(hostAddr) - .port(port) - .listener(lsnr) - .logger(log) - .selectorCount(cfg.getSelectorCount()) - .gridName(ctx.gridName()) - .tcpNoDelay(cfg.isNoDelay()) - .directBuffer(cfg.isDirectBuffer()) - .byteOrder(ByteOrder.nativeOrder()) - .socketSendBufferSize(cfg.getSendBufferSize()) - .socketReceiveBufferSize(cfg.getReceiveBufferSize()) - .sendQueueLimit(cfg.getSendQueueLimit()) - .filters(filters) - .directMode(false) - .build(); - - srv.idleTimeout(cfg.getIdleTimeout()); - - srv.start(); - - ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass()); - - return true; - } - catch (IgniteCheckedException e) { - if (log.isDebugEnabled()) - log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage()); - - return false; - } - } -}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java new file mode 100644 index 0000000..602f859 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java @@ -0,0 +1,345 @@ +/* + * 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.protocol; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.binary.*; +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.cache.binary.CacheObjectBinaryProcessorImpl; +import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta; +import org.apache.ignite.internal.processors.odbc.OdbcTableMeta; +import org.apache.ignite.internal.processors.odbc.request.*; +import org.apache.ignite.internal.processors.odbc.response.*; +import org.apache.ignite.internal.util.nio.GridNioParser; +import org.apache.ignite.internal.util.nio.GridNioSession; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Collection; + + +/** + * ODBC protocol parser. + */ +public class OdbcParser implements GridNioParser { + /** Initial output stream capacity. */ + private static final int INIT_CAP = 1024; + + /** Length in bytes of the remaining message part. */ + int leftToReceive = 0; + + /** Already received bytes of current message. */ + ByteBuffer currentMessage = null; + + /** Context. */ + protected final GridKernalContext ctx; + + /** Marshaller. */ + private final GridBinaryMarshaller marsh; + + OdbcParser(GridKernalContext context) { + ctx = context; + + CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects(); + + marsh = cacheObjProc.marshaller(); + } + + /** + * Process data chunk and try to construct new message using stored and freshly received data. + * @param buf Fresh data buffer. + * @return Instance of the {@link BinaryReaderExImpl} positioned to read from the beginning of the message on + * success and null otherwise. + */ + private BinaryRawReaderEx tryConstructMessage(ByteBuffer buf) { + if (leftToReceive != 0) { + // Still receiving message + int toConsume = Math.min(leftToReceive, buf.remaining()); + + currentMessage.put(buf.array(), buf.arrayOffset(), toConsume); + leftToReceive -= toConsume; + + buf.position(buf.position() + toConsume); + + if (leftToReceive != 0) + return null; + + BinaryInputStream stream = new BinaryHeapInputStream(currentMessage.array()); + + BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null); + + currentMessage = null; + + return reader; + } + + // Receiving new message + // Getting message length. It's in the first four bytes of the message. + BinaryInputStream stream = new BinaryHeapInputStream(buf.array()); + + BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null); + + int messageLen = reader.readInt(); + buf.getInt(); + + int remaining = buf.remaining(); + + if (messageLen > remaining) { + leftToReceive = messageLen - remaining; + + currentMessage = ByteBuffer.allocate(messageLen); + currentMessage.put(buf); + + return null; + } + + buf.position(buf.position() + messageLen); + + return reader; + } + + /** {@inheritDoc} */ + @Nullable @Override public OdbcRequest decode(GridNioSession ses, ByteBuffer buf) throws IOException, + IgniteCheckedException { + BinaryRawReaderEx messageReader = tryConstructMessage(buf); + + return messageReader == null ? null : readRequest(ses, messageReader); + } + + /** {@inheritDoc} */ + @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException { + assert msg != null; + assert msg instanceof OdbcResponse; + + System.out.println("Encoding query processing result"); + + BinaryRawWriterEx writer = marsh.writer(new BinaryHeapOutputStream(INIT_CAP)); + + // Reserving space for the message length. + int msgLenPos = writer.reserveInt(); + + writeResponse(ses, writer, (OdbcResponse)msg); + + int msgLenWithHdr = writer.out().position() - msgLenPos; + + int msgLen = msgLenWithHdr - 4; + + writer.writeInt(msgLenPos, msgLen); + + ByteBuffer buf = ByteBuffer.allocate(msgLenWithHdr); + + buf.put(writer.out().array(), msgLenPos, msgLenWithHdr); + + buf.flip(); + + return buf; + } + + /** + * Read ODBC request from the raw data using provided {@link BinaryReaderExImpl} instance. + * @param ses Current session. + * @param reader Reader positioned to read the request. + * @return Instance of the {@link OdbcRequest}. + * @throws IOException if the type of the request is unknown to the parser. + */ + private OdbcRequest readRequest(GridNioSession ses, BinaryRawReaderEx reader) throws IOException { + OdbcRequest res; + + byte cmd = reader.readByte(); + + switch (cmd) { + case OdbcRequest.EXECUTE_SQL_QUERY: { + String cache = reader.readString(); + String sql = reader.readString(); + int argsNum = reader.readInt(); + + System.out.println("Message EXECUTE_SQL_QUERY:"); + System.out.println("cache: " + cache); + System.out.println("query: " + sql); + System.out.println("argsNum: " + argsNum); + + Object[] params = new Object[argsNum]; + + for (int i = 0; i < argsNum; ++i) + params[i] = reader.readObjectDetached(); + + res = new OdbcQueryExecuteRequest(cache, sql, params); + break; + } + + case OdbcRequest.FETCH_SQL_QUERY: { + long queryId = reader.readLong(); + int pageSize = reader.readInt(); + + System.out.println("Message FETCH_SQL_QUERY:"); + System.out.println("queryId: " + queryId); + System.out.println("pageSize: " + pageSize); + + res = new OdbcQueryFetchRequest(queryId, pageSize); + break; + } + + case OdbcRequest.CLOSE_SQL_QUERY: { + long queryId = reader.readLong(); + + System.out.println("Message CLOSE_SQL_QUERY:"); + System.out.println("queryId: " + queryId); + + res = new OdbcQueryCloseRequest(queryId); + break; + } + + case OdbcRequest.GET_COLUMNS_META: { + String cache = reader.readString(); + String table = reader.readString(); + String column = reader.readString(); + + System.out.println("Message GET_COLUMNS_META:"); + System.out.println("cache: " + cache); + System.out.println("table: " + table); + System.out.println("column: " + column); + + res = new OdbcQueryGetColumnsMetaRequest(cache, table, column); + break; + } + + case OdbcRequest.GET_TABLES_META: { + String catalog = reader.readString(); + String schema = reader.readString(); + String table = reader.readString(); + String tableType = reader.readString(); + + System.out.println("Message GET_COLUMNS_META:"); + System.out.println("catalog: " + catalog); + System.out.println("schema: " + schema); + System.out.println("table: " + table); + System.out.println("tableType: " + tableType); + + res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType); + break; + } + + default: + throw new IOException("Failed to parse incoming packet (unknown command type) [ses=" + ses + + ", cmd=[" + Byte.toString(cmd) + ']'); + } + + return res; + } + + /** + * Write ODBC response using provided {@link BinaryRawWriterEx} instance. + * @param ses Current session. + * @param writer Writer. + * @param rsp ODBC response that should be written. + * @throws IOException if the type of the response is unknown to the parser. + */ + private void writeResponse(GridNioSession ses, BinaryRawWriterEx writer, OdbcResponse rsp) throws IOException { + // Writing status + writer.writeByte((byte)rsp.getSuccessStatus()); + + if (rsp.getSuccessStatus() != OdbcResponse.STATUS_SUCCESS) { + writer.writeString(rsp.getError()); + + return; + } + + Object res0 = rsp.getResponse(); + + if (res0 instanceof OdbcQueryExecuteResult) { + OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0; + + System.out.println("Resulting query ID: " + res.getQueryId()); + + writer.writeLong(res.getQueryId()); + + Collection<OdbcColumnMeta> metas = res.getColumnsMetadata(); + + assert metas != null; + + writer.writeInt(metas.size()); + + for (OdbcColumnMeta meta : metas) + meta.writeBinary(writer, marsh.context()); + + } else if (res0 instanceof OdbcQueryFetchResult) { + OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0; + + System.out.println("Resulting query ID: " + res.getQueryId()); + + writer.writeLong(res.getQueryId()); + + Collection<?> items0 = res.getItems(); + + assert items0 != null; + + Collection<Collection<Object>> items = (Collection<Collection<Object>>)items0; + + writer.writeBoolean(res.getLast()); + + writer.writeInt(items.size()); + + for (Collection<Object> row : items) { + if (row != null) { + writer.writeInt(row.size()); + + for (Object obj : row) { + if (obj != null) + writer.writeObjectDetached(obj); + } + } + } + } else if (res0 instanceof OdbcQueryCloseResult) { + OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0; + + System.out.println("Resulting query ID: " + res.getQueryId()); + + writer.writeLong(res.getQueryId()); + + } else if (res0 instanceof OdbcQueryGetColumnsMetaResult) { + OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0; + + Collection<OdbcColumnMeta> columnsMeta = res.getMeta(); + + assert columnsMeta != null; + + writer.writeInt(columnsMeta.size()); + + for (OdbcColumnMeta columnMeta : columnsMeta) + columnMeta.writeBinary(writer, marsh.context()); + + } else if (res0 instanceof OdbcQueryGetTablesMetaResult) { + OdbcQueryGetTablesMetaResult res = (OdbcQueryGetTablesMetaResult) res0; + + Collection<OdbcTableMeta> tablesMeta = res.getMeta(); + + assert tablesMeta != null; + + writer.writeInt(tablesMeta.size()); + + for (OdbcTableMeta tableMeta : tablesMeta) + tableMeta.writeBinary(writer); + + } else { + throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]"); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java new file mode 100644 index 0000000..656a477 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java @@ -0,0 +1,102 @@ +/* + * 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.protocol; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.odbc.OdbcProtocolHandler; +import org.apache.ignite.internal.processors.odbc.request.OdbcRequest; +import org.apache.ignite.internal.processors.odbc.response.OdbcResponse; +import org.apache.ignite.internal.util.nio.GridNioFuture; +import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter; +import org.apache.ignite.internal.util.nio.GridNioSession; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Listener for ODBC driver connection. + */ +public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest> { + /** Server. */ + private OdbcTcpServer srv; + + /** Logger. */ + protected final IgniteLogger log; + + /** Context. */ + protected final GridKernalContext ctx; + + /** Protocol handler. */ + private OdbcProtocolHandler hnd; + + OdbcTcpNioListener(IgniteLogger log, OdbcTcpServer srv, GridKernalContext ctx, OdbcProtocolHandler hnd) { + this.log = log; + this.srv = srv; + this.ctx = ctx; + this.hnd = hnd; + } + + @Override + public void onConnected(GridNioSession ses) { + System.out.println("Driver connected"); + } + + @Override + public void onDisconnected(GridNioSession ses, @Nullable Exception e) { + System.out.println("Driver disconnected"); + + if (e != null) { + if (e instanceof RuntimeException) + U.error(log, "Failed to process request from remote client: " + ses, e); + else + U.warn(log, "Closed client session due to exception [ses=" + ses + ", msg=" + e.getMessage() + ']'); + } + } + + @Override + public void onMessage(GridNioSession ses, OdbcRequest msg) { + assert msg != null; + + System.out.println("Query: " + msg.command()); + + OdbcResponse res; + + try { + res = hnd.handle(msg); + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to process client request: " + msg, e); + + res = new OdbcResponse(OdbcResponse.STATUS_FAILED, + "Failed to process client request: " + e.getMessage()); + } + + System.out.println("Resulting success status: " + res.getSuccessStatus()); + + GridNioFuture<?> sf = ses.send(res); + + // Check if send failed. + if (sf.isDone()) { + try { + sf.get(); + } catch (Exception e) { + U.error(log, "Failed to process client request [ses=" + ses + ", msg=" + msg + ']', e); + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java new file mode 100644 index 0000000..4fbd326 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java @@ -0,0 +1,191 @@ +/* + * 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.protocol; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.configuration.ConnectorConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.OdbcConfiguration; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.odbc.OdbcProtocolHandler; +import org.apache.ignite.internal.processors.odbc.request.OdbcRequest; +import org.apache.ignite.internal.util.nio.*; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.spi.IgnitePortProtocol; + +import java.io.IOException; +import java.net.InetAddress; +import java.nio.ByteOrder; + +/** + * TCP server that handles communication with ODBC driver. + */ +public class OdbcTcpServer { + + /** Server. */ + private GridNioServer<OdbcRequest> srv; + + /** NIO server listener. */ + private GridNioServerListener<OdbcRequest> lsnr; + + /** Logger. */ + protected final IgniteLogger log; + + /** Context. */ + protected final GridKernalContext ctx; + + /** Host used by this protocol. */ + protected InetAddress host; + + /** Port used by this protocol. */ + protected int port; + + /** */ + public String name() { + return "ODBC server"; + } + + public OdbcTcpServer(GridKernalContext ctx) { + assert ctx != null; + assert ctx.config().getConnectorConfiguration() != null; + + this.ctx = ctx; + + log = ctx.log(getClass()); + } + + @SuppressWarnings("BusyWait") + public void start(final OdbcProtocolHandler hnd) throws IgniteCheckedException { + OdbcConfiguration cfg = ctx.config().getOdbcConfiguration(); + + assert cfg != null; + + lsnr = new OdbcTcpNioListener(log, this, ctx, hnd); + + GridNioParser parser = new OdbcParser(ctx); + + try { + host = resolveOdbcTcpHost(ctx.config()); + + int odbcPort = cfg.getPort(); + + if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) { + port = odbcPort; + + System.out.println("ODBC Server has started on TCP port " + port); + + return; + } + + U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " + + "[odbcPort=" + odbcPort + ", host=" + host + ']'); + } + catch (IOException e) { + U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(), + "Failed to start " + name() + " on port " + port + ". " + + "Check restTcpHost configuration property."); + } + } + + /** */ + public void onKernalStart() { + } + + /** */ + public void stop() { + if (srv != null) { + ctx.ports().deregisterPorts(getClass()); + + srv.stop(); + } + } + + /** + * Resolves host for server using grid configuration. + * + * @param cfg Grid configuration. + * @return Host address. + * @throws IOException If failed to resolve host. + */ + private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException { + String host = null; + + ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration(); + + if (connectionCfg != null) + host = connectionCfg.getHost(); + + if (host == null) + host = cfg.getLocalHost(); + + return U.resolveLocalHost(host); + } + + /** + * Tries to start server with given parameters. + * + * @param hostAddr Host on which server should be bound. + * @param port Port on which server should be bound. + * @param lsnr Server message listener. + * @param parser Server message parser. + * @param cfg Configuration for other parameters. + * @return {@code True} if server successfully started, {@code false} if port is used and + * server was unable to start. + */ + private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> lsnr, + GridNioParser parser, OdbcConfiguration cfg) { + try { + GridNioFilter codec = new GridNioCodecFilter(parser, log, false); + + GridNioFilter[] filters; + + filters = new GridNioFilter[] { codec }; + + srv = GridNioServer.<OdbcRequest>builder() + .address(hostAddr) + .port(port) + .listener(lsnr) + .logger(log) + .selectorCount(cfg.getSelectorCount()) + .gridName(ctx.gridName()) + .tcpNoDelay(cfg.isNoDelay()) + .directBuffer(cfg.isDirectBuffer()) + .byteOrder(ByteOrder.nativeOrder()) + .socketSendBufferSize(cfg.getSendBufferSize()) + .socketReceiveBufferSize(cfg.getReceiveBufferSize()) + .sendQueueLimit(cfg.getSendQueueLimit()) + .filters(filters) + .directMode(false) + .build(); + + srv.idleTimeout(cfg.getIdleTimeout()); + + srv.start(); + + ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass()); + + return true; + } + catch (IgniteCheckedException e) { + if (log.isDebugEnabled()) + log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage()); + + return false; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java deleted file mode 100644 index c3738e2..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.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.request; - -/** - * ODBC command request. - */ -public class GridOdbcRequest { - /** Execute sql query. */ - public static final int EXECUTE_SQL_QUERY = 1; - - /** Fetch query results. */ - public static final int FETCH_SQL_QUERY = 2; - - /** Close query. */ - public static final int CLOSE_SQL_QUERY = 3; - - /** Get columns meta query. */ - public static final int GET_COLUMNS_META = 4; - - /** Get columns meta query. */ - public static final int GET_TABLES_META = 5; - - /** Command. */ - private int cmd; - - /** - * @param cmd Command type. - */ - public GridOdbcRequest(int cmd) { - this.cmd = cmd; - } - - /** - * @return Command. - */ - public int command() { - return cmd; - } - - /** - * @param cmd Command. - */ - public void command(int cmd) { - this.cmd = cmd; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java new file mode 100644 index 0000000..8ebcca1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java @@ -0,0 +1,47 @@ +/* + * 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.request; + +/** + * ODBC query close request. + */ +public class OdbcQueryCloseRequest extends OdbcRequest { + /** Query ID. */ + private long queryId; + + /** + * @param queryId Query ID. + */ + public OdbcQueryCloseRequest(long queryId) { + super(CLOSE_SQL_QUERY); + this.queryId = queryId; + } + + /** + * @param queryId Query ID. + */ + public void cacheName(long queryId) { + this.queryId = queryId; + } + + /** + * @return Query ID. + */ + public long queryId() { + return queryId; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java new file mode 100644 index 0000000..a5da36a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java @@ -0,0 +1,85 @@ +/* + * 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.request; + +/** + * ODBC query execute request. + */ +public class OdbcQueryExecuteRequest extends OdbcRequest { + /** Cache name. */ + private String cacheName; + + /** Sql query. */ + private String sqlQry; + + /** Sql query arguments. */ + private 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; + this.sqlQry = sqlQry; + this.args = args; + } + + /** + * @param sqlQry Sql query. + */ + public void sqlQuery(String sqlQry) { + this.sqlQry = sqlQry; + } + + /** + * @return Sql query. + */ + public String sqlQuery() { + return sqlQry; + } + + /** + * @param args Sql query arguments. + */ + public void arguments(Object[] args) { + this.args = args; + } + + /** + * @return Sql query arguments. + */ + public Object[] arguments() { + return args; + } + + /** + * @param cacheName Cache name. + */ + public void cacheName(String cacheName) { + this.cacheName = cacheName; + } + + /** + * @return Cache name. + */ + public String cacheName() { + return cacheName; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java new file mode 100644 index 0000000..d30ecf7 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java @@ -0,0 +1,66 @@ +/* + * 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.request; + +/** + * ODBC query fetch request. + */ +public class OdbcQueryFetchRequest extends OdbcRequest { + /** Query ID. */ + private long queryId; + + /** Page size - maximum number of rows to return. */ + private Integer 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; + } + + /** + * @param pageSize Page size. + */ + public void pageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + /** + * @return Page size. + */ + public int pageSize() { + return pageSize; + } + + /** + * @param queryId Query ID. + */ + public void cacheName(long queryId) { + this.queryId = queryId; + } + + /** + * @return Query ID. + */ + public long queryId() { + return queryId; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java new file mode 100644 index 0000000..3ab2a16 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java @@ -0,0 +1,84 @@ +/* + * 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.request; + +/** + * ODBC query get columns meta request. + */ +public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest { + /** Cache name. */ + private String cacheName; + + /** Table name. */ + private String tableName; + + /** Column name. */ + private String columnName; + + /** + * @param cacheName Cache name. + */ + public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) { + super(GET_COLUMNS_META); + + this.cacheName = cacheName; + this.tableName = tableName; + this.columnName = columnName; + } + + /** + * @param cacheName Cache name. + */ + public void cacheName(String cacheName) { + this.cacheName = cacheName; + } + + /** + * @return Cache name. + */ + public String cacheName() { + return cacheName; + } + + /** + * @param tableName Table name. + */ + public void tableName(String tableName) { + this.tableName = tableName; + } + + /** + * @return Table name. + */ + public String tableName() { + return tableName; + } + + /** + * @param columnName Column name. + */ + public void columnName(String columnName) { + this.columnName = columnName; + } + + /** + * @return Column name. + */ + public String columnName() { + return columnName; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java new file mode 100644 index 0000000..811091c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java @@ -0,0 +1,105 @@ +/* + * 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.request; + +/** + * ODBC query get tables meta request. + */ +public class OdbcQueryGetTablesMetaRequest extends OdbcRequest { + /** Catalog search pattern. */ + private String catalog; + + /** Schema search pattern. */ + private String schema; + + /** Table search pattern. */ + private String table; + + /** Table type search pattern. */ + private 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(GET_TABLES_META); + + this.catalog = catalog; + this.schema = schema; + this.table = table; + this.tableType = tableType; + } + + /** + * @param catalog Catalog search pattern. + */ + public void catalog(String catalog) { + this.catalog = catalog; + } + + /** + * @return catalog search pattern. + */ + public String catalog() { + return catalog; + } + + /** + * @param schema Schema search pattern. + */ + public void schema(String schema) { + this.schema = schema; + } + + /** + * @return Schema search pattern. + */ + public String schema() { + return schema; + } + + /** + * @param table Schema search pattern. + */ + public void table(String table) { + this.table = table; + } + + /** + * @return Table search pattern. + */ + public String table() { + return table; + } + + /** + * @param tableType Table type search pattern. + */ + public void tableType(String tableType) { + this.tableType = tableType; + } + + /** + * @return Table type search pattern. + */ + public String tableType() { + return tableType; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java new file mode 100644 index 0000000..63bd747 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java @@ -0,0 +1,61 @@ +/* + * 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.request; + +/** + * ODBC command request. + */ +public class OdbcRequest { + /** Execute sql query. */ + public static final int EXECUTE_SQL_QUERY = 1; + + /** Fetch query results. */ + public static final int FETCH_SQL_QUERY = 2; + + /** Close query. */ + public static final int CLOSE_SQL_QUERY = 3; + + /** Get columns meta query. */ + public static final int GET_COLUMNS_META = 4; + + /** Get columns meta query. */ + public static final int GET_TABLES_META = 5; + + /** Command. */ + private int cmd; + + /** + * @param cmd Command type. + */ + public OdbcRequest(int cmd) { + this.cmd = cmd; + } + + /** + * @return Command. + */ + public int command() { + return cmd; + } + + /** + * @param cmd Command. + */ + public void command(int cmd) { + this.cmd = cmd; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java deleted file mode 100644 index 4ddbec4..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java +++ /dev/null @@ -1,47 +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.request; - -/** - * ODBC query close request. - */ -public class QueryCloseRequest extends GridOdbcRequest { - /** Query ID. */ - private long queryId; - - /** - * @param queryId Query ID. - */ - public QueryCloseRequest(long queryId) { - super(CLOSE_SQL_QUERY); - this.queryId = queryId; - } - - /** - * @param queryId Query ID. - */ - public void cacheName(long queryId) { - this.queryId = queryId; - } - - /** - * @return Query ID. - */ - public long queryId() { - return queryId; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java deleted file mode 100644 index 9a16894..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.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.request; - -/** - * ODBC query execute request. - */ -public class QueryExecuteRequest extends GridOdbcRequest { - /** Cache name. */ - private String cacheName; - - /** Sql query. */ - private String sqlQry; - - /** Sql query arguments. */ - private Object[] args; - - /** - * @param cacheName Cache name. - * @param sqlQry SQL query. - * @param args Arguments list. - */ - public QueryExecuteRequest(String cacheName, String sqlQry, Object[] args) { - super(EXECUTE_SQL_QUERY); - this.cacheName = cacheName; - this.sqlQry = sqlQry; - this.args = args; - } - - /** - * @param sqlQry Sql query. - */ - public void sqlQuery(String sqlQry) { - this.sqlQry = sqlQry; - } - - /** - * @return Sql query. - */ - public String sqlQuery() { - return sqlQry; - } - - /** - * @param args Sql query arguments. - */ - public void arguments(Object[] args) { - this.args = args; - } - - /** - * @return Sql query arguments. - */ - public Object[] arguments() { - return args; - } - - /** - * @param cacheName Cache name. - */ - public void cacheName(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String cacheName() { - return cacheName; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java deleted file mode 100644 index 3f671dd..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.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.request; - -/** - * ODBC query fetch request. - */ -public class QueryFetchRequest extends GridOdbcRequest { - /** Query ID. */ - private long queryId; - - /** Page size - maximum number of rows to return. */ - private Integer pageSize; - - /** - * @param queryId Query ID. - * @param pageSize Page size. - */ - public QueryFetchRequest(long queryId, int pageSize) { - super(FETCH_SQL_QUERY); - this.queryId = queryId; - this.pageSize = pageSize; - } - - /** - * @param pageSize Page size. - */ - public void pageSize(Integer pageSize) { - this.pageSize = pageSize; - } - - /** - * @return Page size. - */ - public int pageSize() { - return pageSize; - } - - /** - * @param queryId Query ID. - */ - public void cacheName(long queryId) { - this.queryId = queryId; - } - - /** - * @return Query ID. - */ - public long queryId() { - return queryId; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java deleted file mode 100644 index 255ef41..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java +++ /dev/null @@ -1,84 +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.request; - -/** - * ODBC query get columns meta request. - */ -public class QueryGetColumnsMetaRequest extends GridOdbcRequest { - /** Cache name. */ - private String cacheName; - - /** Table name. */ - private String tableName; - - /** Column name. */ - private String columnName; - - /** - * @param cacheName Cache name. - */ - public QueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) { - super(GET_COLUMNS_META); - - this.cacheName = cacheName; - this.tableName = tableName; - this.columnName = columnName; - } - - /** - * @param cacheName Cache name. - */ - public void cacheName(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String cacheName() { - return cacheName; - } - - /** - * @param tableName Table name. - */ - public void tableName(String tableName) { - this.tableName = tableName; - } - - /** - * @return Table name. - */ - public String tableName() { - return tableName; - } - - /** - * @param columnName Column name. - */ - public void columnName(String columnName) { - this.columnName = columnName; - } - - /** - * @return Column name. - */ - public String columnName() { - return columnName; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java deleted file mode 100644 index c92dcd7..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java +++ /dev/null @@ -1,105 +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.request; - -/** - * ODBC query get tables meta request. - */ -public class QueryGetTablesMetaRequest extends GridOdbcRequest { - /** Catalog search pattern. */ - private String catalog; - - /** Schema search pattern. */ - private String schema; - - /** Table search pattern. */ - private String table; - - /** Table type search pattern. */ - private String tableType; - - /** - * @param catalog Catalog search pattern. - * @param schema Schema search pattern. - * @param table Table search pattern. - * @param tableType Table type search pattern. - */ - public QueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) { - super(GET_TABLES_META); - - this.catalog = catalog; - this.schema = schema; - this.table = table; - this.tableType = tableType; - } - - /** - * @param catalog Catalog search pattern. - */ - public void catalog(String catalog) { - this.catalog = catalog; - } - - /** - * @return catalog search pattern. - */ - public String catalog() { - return catalog; - } - - /** - * @param schema Schema search pattern. - */ - public void schema(String schema) { - this.schema = schema; - } - - /** - * @return Schema search pattern. - */ - public String schema() { - return schema; - } - - /** - * @param table Schema search pattern. - */ - public void table(String table) { - this.table = table; - } - - /** - * @return Table search pattern. - */ - public String table() { - return table; - } - - /** - * @param tableType Table type search pattern. - */ - public void tableType(String tableType) { - this.tableType = tableType; - } - - /** - * @return Table type search pattern. - */ - public String tableType() { - return tableType; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java deleted file mode 100644 index 2167272..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java +++ /dev/null @@ -1,107 +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.response; - -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.jetbrains.annotations.Nullable; - -/** - * ODBC protocol response. - */ -public class GridOdbcResponse { - - /** Command succeeded. */ - public static final int STATUS_SUCCESS = 0; - - /** Command failed. */ - public static final int STATUS_FAILED = 1; - - /** Success status. */ - @SuppressWarnings("RedundantFieldInitialization") - private int successStatus = STATUS_SUCCESS; - - /** Error. */ - private String err; - - /** Response object. */ - @GridToStringInclude - private Object obj; - - /** - * Constructs successful rest response. - * - * @param obj Response object. - */ - public GridOdbcResponse(Object obj) { - successStatus = STATUS_SUCCESS; - this.obj = obj; - } - - /** - * Constructs failed rest response. - * - * @param status Response status. - * @param err Error, {@code null} if success is {@code true}. - */ - public GridOdbcResponse(int status, @Nullable String err) { - assert status != STATUS_SUCCESS; - - successStatus = status; - this.err = err; - } - - /** - * @return Success flag. - */ - public int getSuccessStatus() { - return successStatus; - } - - /** - * @return Response object. - */ - public Object getResponse() { - return obj; - } - - /** - * @param obj Response object. - */ - public void setResponse(@Nullable Object obj) { - this.obj = obj; - } - - /** - * @return Error. - */ - public String getError() { - return err; - } - - /** - * @param err Error. - */ - public void setError(String err) { - this.err = err; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridOdbcResponse.class, this); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java new file mode 100644 index 0000000..c8cdd2c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java @@ -0,0 +1,39 @@ +/* + * 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.response; + +/** + * Query result. + */ +public class OdbcQueryCloseResult { + /** Query ID. */ + private 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/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java new file mode 100644 index 0000000..119470e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java @@ -0,0 +1,55 @@ +/* + * 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.response; + +import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta; + +import java.util.Collection; + +/** + * Query execute result. + */ +public class OdbcQueryExecuteResult { + /** Query ID. */ + private long queryId; + + /** Fields metadata. */ + private 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/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java new file mode 100644 index 0000000..8385301 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java @@ -0,0 +1,75 @@ +/* + * 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.response; + +import java.util.Collection; + +/** + * Query fetch result. + */ +public class OdbcQueryFetchResult { + /** Query ID. */ + private long queryId; + + /** Query result rows. */ + private Collection<?> items = null; + + /** Flag indicating the query has no unfetched results. */ + private boolean last = false; + + /** + * @param queryId Query ID. + */ + public OdbcQueryFetchResult(long queryId){ + this.queryId = queryId; + } + + /** + * @return Query ID. + */ + public long getQueryId() { + return queryId; + } + + /** + * @param items Query result rows. + */ + public void setItems(Collection<?> items) { + this.items = items; + } + + /** + * @return Query result rows. + */ + public Collection<?> getItems() { + return items; + } + + /** + * @param last Flag indicating the query has no unfetched results. + */ + public void setLast(boolean last) { + this.last = last; + } + + /** + * @return Flag indicating the query has no unfetched results. + */ + public boolean getLast() { + return last; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java new file mode 100644 index 0000000..46373ba --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java @@ -0,0 +1,43 @@ +/* + * 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.response; + +import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta; + +import java.util.Collection; + +/** + * Query get columns meta result. + */ +public class OdbcQueryGetColumnsMetaResult { + /** Query result rows. */ + private Collection<OdbcColumnMeta> meta; + + /** + * @param meta Column metadata. + */ + public OdbcQueryGetColumnsMetaResult(Collection<OdbcColumnMeta> meta) { + this.meta = meta; + } + + /** + * @return Query result rows. + */ + public Collection<OdbcColumnMeta> getMeta() { + return meta; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java new file mode 100644 index 0000000..3d3cb86 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java @@ -0,0 +1,43 @@ +/* + * 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.response; + +import org.apache.ignite.internal.processors.odbc.OdbcTableMeta; + +import java.util.Collection; + +/** + * Query get columns meta result. + */ +public class OdbcQueryGetTablesMetaResult { + /** Query result rows. */ + private Collection<OdbcTableMeta> meta; + + /** + * @param meta Column metadata. + */ + public OdbcQueryGetTablesMetaResult(Collection<OdbcTableMeta> meta) { + this.meta = meta; + } + + /** + * @return Query result rows. + */ + public Collection<OdbcTableMeta> getMeta() { + return meta; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java new file mode 100644 index 0000000..038275d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java @@ -0,0 +1,107 @@ +/* + * 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.response; + +import org.apache.ignite.internal.util.tostring.GridToStringInclude; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.jetbrains.annotations.Nullable; + +/** + * ODBC protocol response. + */ +public class OdbcResponse { + + /** Command succeeded. */ + public static final int STATUS_SUCCESS = 0; + + /** Command failed. */ + public static final int STATUS_FAILED = 1; + + /** Success status. */ + @SuppressWarnings("RedundantFieldInitialization") + private int successStatus = STATUS_SUCCESS; + + /** Error. */ + private String err; + + /** Response object. */ + @GridToStringInclude + private Object obj; + + /** + * Constructs successful rest response. + * + * @param obj Response object. + */ + public OdbcResponse(Object obj) { + successStatus = STATUS_SUCCESS; + this.obj = obj; + } + + /** + * Constructs failed rest response. + * + * @param status Response status. + * @param err Error, {@code null} if success is {@code true}. + */ + public OdbcResponse(int status, @Nullable String err) { + assert status != STATUS_SUCCESS; + + successStatus = status; + this.err = err; + } + + /** + * @return Success flag. + */ + public int getSuccessStatus() { + return successStatus; + } + + /** + * @return Response object. + */ + public Object getResponse() { + return obj; + } + + /** + * @param obj Response object. + */ + public void setResponse(@Nullable Object obj) { + this.obj = obj; + } + + /** + * @return Error. + */ + public String getError() { + return err; + } + + /** + * @param err Error. + */ + public void setError(String err) { + this.err = err; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(OdbcResponse.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java deleted file mode 100644 index 2d7521c..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java +++ /dev/null @@ -1,39 +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.response; - -/** - * Query result. - */ -public class QueryCloseResult { - /** Query ID. */ - private long queryId; - - /** - * @param queryId Query ID. - */ - public QueryCloseResult(long queryId){ - this.queryId = queryId; - } - - /** - * @return Query ID. - */ - public long getQueryId() { - return queryId; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java deleted file mode 100644 index aa4c928..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java +++ /dev/null @@ -1,55 +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.response; - -import org.apache.ignite.internal.processors.odbc.GridOdbcColumnMeta; - -import java.util.Collection; - -/** - * Query execute result. - */ -public class QueryExecuteResult { - /** Query ID. */ - private long queryId; - - /** Fields metadata. */ - private Collection<GridOdbcColumnMeta> columnsMeta; - - /** - * @param queryId Query ID. - * @param columnsMeta Columns metadata. - */ - public QueryExecuteResult(long queryId,Collection<GridOdbcColumnMeta> columnsMeta){ - this.queryId = queryId; - this.columnsMeta = columnsMeta; - } - - /** - * @return Query ID. - */ - public long getQueryId() { - return queryId; - } - - /** - * @return Columns metadata. - */ - public Collection<GridOdbcColumnMeta> getColumnsMetadata() { - return columnsMeta; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java deleted file mode 100644 index 17cf396..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java +++ /dev/null @@ -1,75 +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.response; - -import java.util.Collection; - -/** - * Query fetch result. - */ -public class QueryFetchResult { - /** Query ID. */ - private long queryId; - - /** Query result rows. */ - private Collection<?> items = null; - - /** Flag indicating the query has no unfetched results. */ - private boolean last = false; - - /** - * @param queryId Query ID. - */ - public QueryFetchResult(long queryId){ - this.queryId = queryId; - } - - /** - * @return Query ID. - */ - public long getQueryId() { - return queryId; - } - - /** - * @param items Query result rows. - */ - public void setItems(Collection<?> items) { - this.items = items; - } - - /** - * @return Query result rows. - */ - public Collection<?> getItems() { - return items; - } - - /** - * @param last Flag indicating the query has no unfetched results. - */ - public void setLast(boolean last) { - this.last = last; - } - - /** - * @return Flag indicating the query has no unfetched results. - */ - public boolean getLast() { - return last; - } -}
