IGNITE-1786: Simplifications.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d55dc369 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d55dc369 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d55dc369 Branch: refs/heads/ignite-1786 Commit: d55dc36908a2c229de38c72d7f096a94274e74a5 Parents: 8b16efc Author: vozerov-gridgain <voze...@gridgain.com> Authored: Wed Jan 27 15:22:28 2016 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Wed Jan 27 15:22:28 2016 +0300 ---------------------------------------------------------------------- .../internal/processors/odbc/OdbcProcessor.java | 59 ++++++-------------- .../processors/odbc/OdbcProtocolHandler.java | 8 --- .../internal/processors/odbc/OdbcTcpServer.java | 4 +- 3 files changed, 19 insertions(+), 52 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/d55dc369/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java index 4d49ac7..b1044cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java @@ -19,11 +19,9 @@ package org.apache.ignite.internal.processors.odbc; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.GridProcessorAdapter; import org.apache.ignite.internal.util.GridSpinReadWriteLock; -import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.marshaller.Marshaller; /** @@ -45,12 +43,6 @@ public class OdbcProcessor extends GridProcessorAdapter { @Override public OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException { return handle0(req); } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req) { - return new GridFinishedFuture<>( - new IgniteCheckedException("Failed to handle request (asynchronous handling is not implemented).")); - } }; /** @@ -63,44 +55,30 @@ public class OdbcProcessor extends GridProcessorAdapter { if (!busyLock.tryReadLock()) throw new IgniteCheckedException("Failed to handle request (received request while stopping grid)."); - OdbcResponse rsp = null; - try { - rsp = handleRequest(req); - } - finally { - busyLock.readUnlock(); - } + if (log.isDebugEnabled()) + log.debug("Received request from client: " + req); - return rsp; - } + OdbcResponse rsp; - /** - * Handle request. - * - * @param req Request. - * @return Response. - */ - private OdbcResponse handleRequest(final OdbcRequest req) throws IgniteCheckedException { - if (log.isDebugEnabled()) - log.debug("Received request from client: " + req); + try { + rsp = handler == null ? null : handler.handle(req); - OdbcResponse rsp; + if (rsp == null) + throw new IgniteCheckedException("Failed to find registered handler for command: " + req.command()); + } + catch (Exception e) { + if (log.isDebugEnabled()) + log.debug("Failed to handle request [req=" + req + ", e=" + e + "]"); - try { - rsp = handler == null ? null : handler.handle(req); + rsp = new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage()); + } - if (rsp == null) - throw new IgniteCheckedException("Failed to find registered handler for command: " + req.command()); + return rsp; } - catch (Exception e) { - if (log.isDebugEnabled()) - log.debug("Failed to handle request [req=" + req + ", e=" + e + "]"); - - rsp = new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage()); + finally { + busyLock.readUnlock(); } - - return rsp; } /** @@ -115,12 +93,10 @@ public class OdbcProcessor extends GridProcessorAdapter { /** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { if (isOdbcEnabled()) { - Marshaller marsh = ctx.config().getMarshaller(); if (marsh != null && !(marsh instanceof BinaryMarshaller)) - throw new IgniteCheckedException("Failed to start processor " + - "(ODBC may only be used with BinaryMarshaller)."); + throw new IgniteCheckedException("ODBC may only be used with BinaryMarshaller."); // Register handler. handler = new OdbcCommandHandler(ctx); @@ -139,7 +115,6 @@ public class OdbcProcessor extends GridProcessorAdapter { /** {@inheritDoc} */ @Override public void onKernalStart() throws IgniteCheckedException { if (isOdbcEnabled()) { - if (log.isDebugEnabled()) log.debug("ODBC processor started."); } http://git-wip-us.apache.org/repos/asf/ignite/blob/d55dc369/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java index bfc58d2..962054a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java @@ -32,12 +32,4 @@ public interface OdbcProtocolHandler { * @throws IgniteCheckedException In case of error. */ OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException; - - /** - * Handle request asynchronously. - * - * @param req Request. - * @return Future. - */ - IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req); } http://git-wip-us.apache.org/repos/asf/ignite/blob/d55dc369/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java index 739a22f..159b04a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java @@ -108,7 +108,7 @@ public class OdbcTcpServer { * @return Host address. * @throws IOException If failed to resolve host. */ - private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException { + private static InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException { String host = null; OdbcConfiguration odbcCfg = cfg.getOdbcConfiguration(); @@ -134,7 +134,7 @@ public class OdbcTcpServer { * server was unable to start. */ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> listener, - GridNioParser parser, OdbcConfiguration cfg) { + GridNioParser parser, OdbcConfiguration cfg) { try { GridNioFilter codec = new GridNioCodecFilter(parser, log, false);