diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java index 4800afcb5033e..5e17a76212e8d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java @@ -285,8 +285,6 @@ public JdbcConnectionContext(GridKernalContext ctx, GridNioSession ses, GridSpin dataPageScanEnabled, updateBatchSize, concurrency, isolation, timeout, lb, ver, this); - - handler.start(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java index 451dfdcc79a49..fa73c4acc072e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java @@ -137,9 +137,6 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler, ClientT /** Busy lock. */ private final GridSpinBusyLock busyLock; - /** Worker. */ - private final JdbcRequestHandlerWorker worker; - /** Maximum allowed cursors. */ private final int maxCursors; @@ -248,10 +245,6 @@ public JdbcRequestHandler( this.protocolVer = protocolVer; log = connCtx.kernalContext().log(getClass()); - - // TODO IGNITE-9484 Do not create worker if there is a possibility to unbind TX from threads. - worker = new JdbcRequestHandlerWorker(connCtx.kernalContext().igniteInstanceName(), log, this, - connCtx.kernalContext()); } /** {@inheritDoc} */ @@ -288,14 +281,6 @@ public JdbcRequestHandler( } } - /** - * Start worker, if it's present. - */ - void start() { - if (worker != null) - worker.start(); - } - /** * Actually handle the request. * @param req Request. @@ -552,17 +537,6 @@ private JdbcResponse processBulkLoadFileBatch(JdbcBulkLoadBatchRequest req) { * or due to {@code IOException} during network operations. */ public void onDisconnect() { - if (worker != null) { - worker.cancel(); - - try { - worker.join(); - } - catch (InterruptedException e) { - // No-op. - } - } - for (JdbcCursor cursor : jdbcCursors.values()) U.close(cursor, log); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandlerWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandlerWorker.java deleted file mode 100644 index 965db4f98109f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandlerWorker.java +++ /dev/null @@ -1,130 +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.jdbc; - -import java.util.concurrent.LinkedBlockingQueue; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; -import org.apache.ignite.internal.processors.odbc.ClientListenerNioListener; -import org.apache.ignite.internal.processors.odbc.ClientListenerResponse; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.typedef.T2; -import org.apache.ignite.internal.util.typedef.internal.A; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.util.worker.GridWorker; -import org.jetbrains.annotations.Nullable; - -/** - * JDBC request handler worker to maintain single threaded transactional execution of SQL statements when MVCC is on.

- * This worker is intended for internal use as a temporary solution and from within {@link JdbcRequestHandler}, - * therefore it does not do any fine-grained lifecycle handling as it relies on existing guarantees from - * {@link ClientListenerNioListener}. - */ -class JdbcRequestHandlerWorker extends GridWorker { - /** Requests queue.*/ - private final LinkedBlockingQueue>> queue = - new LinkedBlockingQueue<>(); - - /** Handler.*/ - private final JdbcRequestHandler hnd; - - /** Context.*/ - private final GridKernalContext ctx; - - /** Response */ - private static final ClientListenerResponse ERR_RESPONSE = new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, - "Connection closed."); - - /** - * Constructor. - * @param igniteInstanceName Instance name. - * @param log Logger. - * @param hnd Handler. - * @param ctx Kernal context. - */ - JdbcRequestHandlerWorker(@Nullable String igniteInstanceName, IgniteLogger log, JdbcRequestHandler hnd, - GridKernalContext ctx) { - super(igniteInstanceName, "jdbc-request-handler-worker", log); - - A.notNull(hnd, "hnd"); - - this.hnd = hnd; - - this.ctx = ctx; - } - - /** - * Start this worker. - */ - void start() { - U.newThread(this).start(); - } - - /** {@inheritDoc} */ - @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException { - try { - while (!isCancelled()) { - T2> req = queue.take(); - - GridFutureAdapter fut = req.get2(); - - try { - JdbcResponse res = hnd.doHandle(req.get1()); - - fut.onDone(res); - } - catch (Exception e) { - fut.onDone(e); - } - } - } - finally { - // Notify indexing that this worker is being stopped. - try { - ctx.query().onClientDisconnect(); - } - catch (Exception ignored) { - // No-op. - } - - // Drain the queue on stop. - T2> req = queue.poll(); - - while (req != null) { - req.get2().onDone(ERR_RESPONSE); - - req = queue.poll(); - } - } - } - - /** - * Initiate request processing. - * @param req Request. - * @return Future to track request processing. - */ - GridFutureAdapter process(JdbcRequest req) { - GridFutureAdapter fut = new GridFutureAdapter<>(); - - queue.add(new T2<>(req, fut)); - - return fut; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java index 2bb58c5b0b749..096eef728aea3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java @@ -204,8 +204,6 @@ public OdbcConnectionContext(GridKernalContext ctx, GridNioSession ses, GridSpin replicatedOnly, collocated, skipReducerOnUpdate, qryEngine, ver, this); parser = new OdbcMessageParser(ctx, ver); - - handler.start(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java index 3ca6ec93055dc..168205d136435 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java @@ -92,9 +92,6 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler { /** Busy lock. */ private final GridSpinBusyLock busyLock; - /** Worker. */ - private final OdbcRequestHandlerWorker worker; - /** Maximum allowed cursors. */ private final int maxCursors; @@ -176,9 +173,6 @@ public OdbcRequestHandler( this.ver = ver; log = ctx.log(getClass()); - - // TODO IGNITE-9484 Do not create worker if there is a possibility to unbind TX from threads. - worker = new OdbcRequestHandlerWorker(ctx.igniteInstanceName(), log, this, ctx); } /** {@inheritDoc} */ @@ -190,14 +184,6 @@ public OdbcRequestHandler( return doHandle((OdbcRequest)req); } - /** - * Start worker, if it's present. - */ - void start() { - if (worker != null) - worker.start(); - } - /** * Handle ODBC request. * @param req ODBC request. @@ -264,17 +250,6 @@ public ClientListenerResponse doHandle(OdbcRequest req) { */ public void onDisconnect() { if (busyLock.enterBusy()) { - if (worker != null) { - worker.cancel(); - - try { - worker.join(); - } - catch (InterruptedException e) { - // No-op. - } - } - try { for (OdbcQueryResults res : qryResults.values()) res.closeAll(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandlerWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandlerWorker.java deleted file mode 100644 index 26c2b865c0d1f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandlerWorker.java +++ /dev/null @@ -1,130 +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; - -import java.util.concurrent.LinkedBlockingQueue; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; -import org.apache.ignite.internal.processors.odbc.ClientListenerNioListener; -import org.apache.ignite.internal.processors.odbc.ClientListenerResponse; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.typedef.T2; -import org.apache.ignite.internal.util.typedef.internal.A; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.util.worker.GridWorker; -import org.jetbrains.annotations.Nullable; - -/** - * ODBC request handler worker to maintain single threaded transactional execution of SQL statements when MVCC is on.

- * This worker is intended for internal use as a temporary solution and from within {@link OdbcRequestHandler}, - * therefore it does not do any fine-grained lifecycle handling as it relies on existing guarantees from - * {@link ClientListenerNioListener}. - */ -class OdbcRequestHandlerWorker extends GridWorker { - /** Requests queue.*/ - private final LinkedBlockingQueue>> queue = - new LinkedBlockingQueue<>(); - - /** Handler.*/ - private final OdbcRequestHandler hnd; - - /** Context.*/ - private final GridKernalContext ctx; - - /** Response */ - private static final ClientListenerResponse ERR_RESPONSE = new OdbcResponse(IgniteQueryErrorCode.UNKNOWN, - "Connection closed."); - - /** - * Constructor. - * @param igniteInstanceName Instance name. - * @param log Logger. - * @param hnd Handler. - * @param ctx Kernal context. - */ - OdbcRequestHandlerWorker(@Nullable String igniteInstanceName, IgniteLogger log, OdbcRequestHandler hnd, - GridKernalContext ctx) { - super(igniteInstanceName, "odbc-request-handler-worker", log); - - A.notNull(hnd, "hnd"); - - this.hnd = hnd; - - this.ctx = ctx; - } - - /** - * Start this worker. - */ - void start() { - U.newThread(this).start(); - } - - /** {@inheritDoc} */ - @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException { - try { - while (!isCancelled()) { - T2> req = queue.take(); - - GridFutureAdapter fut = req.get2(); - - try { - ClientListenerResponse res = hnd.doHandle(req.get1()); - - fut.onDone(res); - } - catch (Exception e) { - fut.onDone(e); - } - } - } - finally { - // Notify indexing that this worker is being stopped. - try { - ctx.query().onClientDisconnect(); - } - catch (Exception e) { - // No-op. - } - - // Drain the queue on stop. - T2> req = queue.poll(); - - while (req != null) { - req.get2().onDone(ERR_RESPONSE); - - req = queue.poll(); - } - } - } - - /** - * Initiate request processing. - * @param req Request. - * @return Future to track request processing. - */ - GridFutureAdapter process(OdbcRequest req) { - GridFutureAdapter fut = new GridFutureAdapter<>(); - - queue.add(new T2<>(req, fut)); - - return fut; - } -}