ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-2677: ODBC: IgniteException is now thrown instead of IOException.
Date Sat, 20 Feb 2016 10:13:58 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1786 3c52e63b1 -> 0229baaaa


IGNITE-2677: ODBC: IgniteException is now thrown instead of IOException.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0229baaa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0229baaa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0229baaa

Branch: refs/heads/ignite-1786
Commit: 0229baaaab0b40d3a2a3ad0a340dec60196e1a40
Parents: 3c52e63
Author: isapego <isapego@gridgain.com>
Authored: Sat Feb 20 13:13:49 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Sat Feb 20 13:13:49 2016 +0300

----------------------------------------------------------------------
 .../processors/odbc/OdbcColumnMeta.java         |  8 ++---
 .../processors/odbc/OdbcNioListener.java        | 31 +++++---------------
 .../internal/processors/odbc/OdbcTableMeta.java |  5 +---
 3 files changed, 12 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0229baaa/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
index 757b24b..edea1cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
@@ -17,13 +17,12 @@
 
 package org.apache.ignite.internal.processors.odbc;
 
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.binary.BinaryClassDescriptor;
 import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 
-import java.io.IOException;
-
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.UNREGISTERED_TYPE_ID;
 
 /**
@@ -103,9 +102,8 @@ public class OdbcColumnMeta {
      *
      * @param writer Binary writer.
      * @param ctx Portable context.
-     * @throws IOException
      */
-    public void writeBinary(BinaryRawWriterEx writer, BinaryContext ctx) throws IOException
{
+    public void writeBinary(BinaryRawWriterEx writer, BinaryContext ctx) {
         writer.writeString(schemaName);
         writer.writeString(tableName);
         writer.writeString(columnName);
@@ -116,7 +114,7 @@ public class OdbcColumnMeta {
         BinaryClassDescriptor desc = ctx.descriptorForClass(dataType, false);
 
         if (desc == null)
-            throw new IOException("Object is not portable: [class=" + dataType + ']');
+            throw new IgniteException("Object is not portable: [class=" + dataType + ']');
 
         if (desc.registered())
             typeId = (byte)desc.typeId();

http://git-wip-us.apache.org/repos/asf/ignite/blob/0229baaa/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
index e25ae5b..c8b53e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioListener.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.odbc;
 
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.binary.BinaryReaderExImpl;
@@ -32,7 +33,6 @@ import org.apache.ignite.internal.util.nio.GridNioSession;
 import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
 import org.jetbrains.annotations.Nullable;
 
-import java.io.IOException;
 import java.util.Collection;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -98,8 +98,9 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]>
{
     @Override public void onMessage(GridNioSession ses, byte[] msg) {
         assert msg != null;
 
+        long reqId = REQ_ID_GEN.incrementAndGet();
+
         try {
-            long reqId = REQ_ID_GEN.incrementAndGet();
             long startTime = 0;
 
             OdbcRequest req = decode(msg);
@@ -129,25 +130,9 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]>
{
             ses.send(outMsg);
         }
         catch (Exception e) {
-            trySendErrorMessage(ses, e.getMessage());
-        }
-    }
-
-    /**
-     * Try to send simple response message to ODBC driver.
-     * @param ses Session.
-     * @param err Error message.
-     */
-    private void trySendErrorMessage(GridNioSession ses, String err) {
-        log.error(err);
-
-        try {
-            ses.send(encode(new OdbcResponse(OdbcResponse.STATUS_FAILED, err)));
-        }
-        catch (Exception e) {
-            // TODO: ???
+            log.error("Failed to process ODBC request [id=" + reqId + ", err=" + e + ']');
 
-            log.error("Can not send error response message: [err=" + e.getMessage() + ']');
+            ses.send(encode(new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage())));
         }
     }
 
@@ -157,7 +142,7 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]>
{
      * @param msg Message.
      * @return Assembled ODBC request.
      */
-    private OdbcRequest decode(byte[] msg) throws IOException {
+    private OdbcRequest decode(byte[] msg) {
         assert msg != null;
 
         BinaryInputStream stream = new BinaryHeapInputStream(msg);
@@ -224,7 +209,7 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]>
{
             }
 
             default:
-                throw new IOException("Unknown ODBC command: " + cmd);
+                throw new IgniteException("Unknown ODBC command: " + cmd);
         }
 
         return res;
@@ -236,7 +221,7 @@ public class OdbcNioListener extends GridNioServerListenerAdapter<byte[]>
{
      * @param msg Message.
      * @return Byte array.
      */
-    private byte[] encode(OdbcResponse msg) throws IOException {
+    private byte[] encode(OdbcResponse msg) {
         assert msg != null;
 
         // Creating new binary writer

http://git-wip-us.apache.org/repos/asf/ignite/blob/0229baaa/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
index e7f762e..fb7df50 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
@@ -19,8 +19,6 @@ package org.apache.ignite.internal.processors.odbc;
 
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 
-import java.io.IOException;
-
 /**
  * ODBC table-related metadata.
  */
@@ -77,9 +75,8 @@ public class OdbcTableMeta {
      * Write in a binary format.
      *
      * @param writer Binary writer.
-     * @throws IOException
      */
-    public void writeBinary(BinaryRawWriterEx writer) throws IOException {
+    public void writeBinary(BinaryRawWriterEx writer) {
         writer.writeString(catalog);
         writer.writeString(schema);
         writer.writeString(table);


Mime
View raw message