incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: Working on BLUR-204.
Date Thu, 15 Aug 2013 19:00:51 GMT
Working on BLUR-204.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/6f7f71a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/6f7f71a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/6f7f71a4

Branch: refs/heads/master
Commit: 6f7f71a4d49f849a45a0a441681ac15fbde69f34
Parents: 089c62c
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Aug 15 15:00:22 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Aug 15 15:00:22 2013 -0400

----------------------------------------------------------------------
 .../blur/server/ShardServerEventHandler.java    |  2 +-
 .../apache/blur/thrift/BlurClientManager.java   | 10 ++++
 .../java/org/apache/blur/thrift/ClientPool.java |  4 +-
 .../java/org/apache/blur/thrift/Connection.java | 53 +++++++++++++++-----
 .../apache/blur/thrift/generated/ErrorType.java |  5 +-
 .../src/main/scripts/interface/Blur.thrift      |  3 +-
 .../main/scripts/interface/gen-html/Blur.html   |  1 +
 .../apache/blur/thrift/generated/ErrorType.java |  5 +-
 .../main/scripts/interface/gen-js/Blur_types.js |  3 +-
 .../scripts/interface/gen-perl/Blur/Types.pm    |  1 +
 .../main/scripts/interface/gen-rb/blur_types.rb |  5 +-
 11 files changed, 72 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java b/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
index 55fb8d4..1926fa4 100644
--- a/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
+++ b/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
@@ -79,7 +79,7 @@ public class ShardServerEventHandler implements TServerEventHandler {
 
   @Override
   public void deleteContext(ServerContext serverContext, TProtocol input, TProtocol output)
{
-    LOG.debug("Client disconnected");
+    LOG.info("Client disconnected");
     ShardServerContext context = (ShardServerContext) serverContext;
     context.close();
     _connections.decrementAndGet();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java b/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java
index 1c41d48..25773a9 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java
@@ -17,6 +17,7 @@ package org.apache.blur.thrift;
  * limitations under the License.
  */
 import java.io.IOException;
+import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -38,6 +39,7 @@ import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransportException;
 import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.Blur.Client;
 import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.ErrorType;
 
 public class BlurClientManager {
 
@@ -175,6 +177,10 @@ public class BlurClientManager {
           if (cause instanceof TTransportException) {
             TTransportException t = (TTransportException) cause;
             if (handleError(connection, client, retries, command, t, maxRetries, backOffTime,
maxBackOffTime)) {
+              Throwable c = t.getCause();
+              if (cause instanceof SocketTimeoutException) {
+                throw new BlurException(c.getMessage(), BException.toString(c), ErrorType.REQUEST_TIMEOUT);
+              }
               throw t;
             }
           } else {
@@ -182,6 +188,10 @@ public class BlurClientManager {
           }
         } catch (TTransportException e) {
           if (handleError(connection, client, retries, command, e, maxRetries, backOffTime,
maxBackOffTime)) {
+            Throwable c = e.getCause();
+            if (c instanceof SocketTimeoutException) {
+              throw new BlurException(c.getMessage(), BException.toString(c), ErrorType.REQUEST_TIMEOUT);
+            }
             throw e;
           }
         } finally {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/blur-thrift/src/main/java/org/apache/blur/thrift/ClientPool.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/ClientPool.java b/blur-thrift/src/main/java/org/apache/blur/thrift/ClientPool.java
index 5e7136c..92544a3 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/ClientPool.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/ClientPool.java
@@ -108,8 +108,10 @@ public class ClientPool {
     } else {
       socket = new Socket();
     }
+    int timeout = connection.getTimeout();
     socket.setTcpNoDelay(true);
-    socket.connect(new InetSocketAddress(host, port));
+    socket.setSoTimeout(timeout);
+    socket.connect(new InetSocketAddress(host, port), timeout);
     trans = new TSocket(socket);
 
     TProtocol proto = new TBinaryProtocol(new TFramedTransport(trans));

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/blur-thrift/src/main/java/org/apache/blur/thrift/Connection.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/Connection.java b/blur-thrift/src/main/java/org/apache/blur/thrift/Connection.java
index 7290e39..5124105 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/Connection.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/Connection.java
@@ -1,5 +1,7 @@
 package org.apache.blur.thrift;
 
+import java.util.concurrent.TimeUnit;
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with this
@@ -18,11 +20,14 @@ package org.apache.blur.thrift;
  */
 public class Connection {
 
-  private String _host = null;
-  private int _port = -1;
-  private String _proxyHost = null;
-  private int _proxyPort = -1;
-  private boolean _proxy = false;
+  public final static int DEFAULT_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(60);
+
+  private final String _host;
+  private final int _port;
+  private final String _proxyHost;
+  private final int _proxyPort;
+  private final boolean _proxy;
+  private final int _timeout;
 
   public Connection(String connectionStr) {
     int index = connectionStr.indexOf(':');
@@ -38,23 +43,42 @@ public class Connection {
       } else {
         _host = connectionStr.substring(0, index);
         _port = Integer.parseInt(connectionStr.substring(index + 1));
+        _proxyHost = null;
+        _proxyPort = -1;
+        _proxy = false;
       }
+      _timeout = DEFAULT_TIMEOUT;
     } else {
-      throw new RuntimeException("Connection string of [" + connectionStr + "] does not match
'host1:port' or 'host1:port/proxyhost1:proxyport'");
+      throw new RuntimeException("Connection string of [" + connectionStr
+          + "] does not match 'host1:port' or 'host1:port/proxyhost1:proxyport'");
     }
   }
 
+  public Connection(String host, int port, int timeout) {
+    this(host, port, null, -1, timeout);
+  }
+
   public Connection(String host, int port, String proxyHost, int proxyPort) {
+    this(host, port, proxyHost, proxyPort, DEFAULT_TIMEOUT);
+  }
+
+  public Connection(String host, int port, String proxyHost, int proxyPort, int timeout)
{
     _port = port;
     _host = host;
-    _proxyHost = proxyHost;
-    _proxyPort = proxyPort;
-    _proxy = true;
+    if (proxyHost == null) {
+      _proxyHost = null;
+      _proxyPort = -1;
+      _proxy = false;
+    } else {
+      _proxyHost = proxyHost;
+      _proxyPort = proxyPort;
+      _proxy = true;
+    }
+    _timeout = timeout;
   }
 
   public Connection(String host, int port) {
-    _port = port;
-    _host = host;
+    this(host, port, null, -1);
   }
 
   public String getHost() {
@@ -77,6 +101,10 @@ public class Connection {
     return _proxyHost;
   }
 
+  public int getTimeout() {
+    return _timeout;
+  }
+
   @Override
   public int hashCode() {
     final int prime = 31;
@@ -119,7 +147,8 @@ public class Connection {
 
   @Override
   public String toString() {
-    return "Connection [_host=" + _host + ", _port=" + _port + ", _proxy=" + _proxy + ",
_proxyHost=" + _proxyHost + ", _proxyPort=" + _proxyPort + "]";
+    return "Connection [_host=" + _host + ", _port=" + _port + ", _proxy=" + _proxy + ",
_proxyHost=" + _proxyHost
+        + ", _proxyPort=" + _proxyPort + "]";
   }
 
   public Object getConnectionStr() {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/blur-thrift/src/main/java/org/apache/blur/thrift/generated/ErrorType.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/ErrorType.java b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/ErrorType.java
index 85a2970..19e8e60 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/ErrorType.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/ErrorType.java
@@ -34,7 +34,8 @@ public enum ErrorType implements org.apache.blur.thirdparty.thrift_0_9_0.TEnum
{
   UNKNOWN(0),
   QUERY_CANCEL(1),
   QUERY_TIMEOUT(2),
-  BACK_PRESSURE(3);
+  BACK_PRESSURE(3),
+  REQUEST_TIMEOUT(4);
 
   private final int value;
 
@@ -63,6 +64,8 @@ public enum ErrorType implements org.apache.blur.thirdparty.thrift_0_9_0.TEnum
{
         return QUERY_TIMEOUT;
       case 3:
         return BACK_PRESSURE;
+      case 4:
+        return REQUEST_TIMEOUT;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/distribution/src/main/scripts/interface/Blur.thrift
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/interface/Blur.thrift b/distribution/src/main/scripts/interface/Blur.thrift
index 0609c9e..6d99f7b 100644
--- a/distribution/src/main/scripts/interface/Blur.thrift
+++ b/distribution/src/main/scripts/interface/Blur.thrift
@@ -23,7 +23,8 @@ enum ErrorType {
   UNKNOWN,
   QUERY_CANCEL,
   QUERY_TIMEOUT,
-  BACK_PRESSURE
+  BACK_PRESSURE,
+  REQUEST_TIMEOUT
 }
 
 /** 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/distribution/src/main/scripts/interface/gen-html/Blur.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/interface/gen-html/Blur.html b/distribution/src/main/scripts/interface/gen-html/Blur.html
index 9b61559..8c45baa 100644
--- a/distribution/src/main/scripts/interface/gen-html/Blur.html
+++ b/distribution/src/main/scripts/interface/gen-html/Blur.html
@@ -86,6 +86,7 @@
 <tr><td><code>QUERY_CANCEL</code></td><td><code>1</code></td></tr>
 <tr><td><code>QUERY_TIMEOUT</code></td><td><code>2</code></td></tr>
 <tr><td><code>BACK_PRESSURE</code></td><td><code>3</code></td></tr>
+<tr><td><code>REQUEST_TIMEOUT</code></td><td><code>4</code></td></tr>
 </table></div>
 <div class="definition"><h3 id="Enum_ScoreType">Enumeration: ScoreType</h3>
 The scoring type used during a SuperQuery to score multi Record hits within a ColumnFamily.<br/><br/>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/distribution/src/main/scripts/interface/gen-java/org/apache/blur/thrift/generated/ErrorType.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/interface/gen-java/org/apache/blur/thrift/generated/ErrorType.java
b/distribution/src/main/scripts/interface/gen-java/org/apache/blur/thrift/generated/ErrorType.java
index 85a2970..19e8e60 100644
--- a/distribution/src/main/scripts/interface/gen-java/org/apache/blur/thrift/generated/ErrorType.java
+++ b/distribution/src/main/scripts/interface/gen-java/org/apache/blur/thrift/generated/ErrorType.java
@@ -34,7 +34,8 @@ public enum ErrorType implements org.apache.blur.thirdparty.thrift_0_9_0.TEnum
{
   UNKNOWN(0),
   QUERY_CANCEL(1),
   QUERY_TIMEOUT(2),
-  BACK_PRESSURE(3);
+  BACK_PRESSURE(3),
+  REQUEST_TIMEOUT(4);
 
   private final int value;
 
@@ -63,6 +64,8 @@ public enum ErrorType implements org.apache.blur.thirdparty.thrift_0_9_0.TEnum
{
         return QUERY_TIMEOUT;
       case 3:
         return BACK_PRESSURE;
+      case 4:
+        return REQUEST_TIMEOUT;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/distribution/src/main/scripts/interface/gen-js/Blur_types.js
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/interface/gen-js/Blur_types.js b/distribution/src/main/scripts/interface/gen-js/Blur_types.js
index bf01243..c562713 100644
--- a/distribution/src/main/scripts/interface/gen-js/Blur_types.js
+++ b/distribution/src/main/scripts/interface/gen-js/Blur_types.js
@@ -8,7 +8,8 @@ ErrorType = {
 'UNKNOWN' : 0,
 'QUERY_CANCEL' : 1,
 'QUERY_TIMEOUT' : 2,
-'BACK_PRESSURE' : 3
+'BACK_PRESSURE' : 3,
+'REQUEST_TIMEOUT' : 4
 };
 ScoreType = {
 'SUPER' : 0,

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/distribution/src/main/scripts/interface/gen-perl/Blur/Types.pm
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/interface/gen-perl/Blur/Types.pm b/distribution/src/main/scripts/interface/gen-perl/Blur/Types.pm
index 579e73c..15b969e 100644
--- a/distribution/src/main/scripts/interface/gen-perl/Blur/Types.pm
+++ b/distribution/src/main/scripts/interface/gen-perl/Blur/Types.pm
@@ -13,6 +13,7 @@ use constant UNKNOWN => 0;
 use constant QUERY_CANCEL => 1;
 use constant QUERY_TIMEOUT => 2;
 use constant BACK_PRESSURE => 3;
+use constant REQUEST_TIMEOUT => 4;
 package Blur::ScoreType;
 use constant SUPER => 0;
 use constant AGGREGATE => 1;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6f7f71a4/distribution/src/main/scripts/interface/gen-rb/blur_types.rb
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/interface/gen-rb/blur_types.rb b/distribution/src/main/scripts/interface/gen-rb/blur_types.rb
index 86eb4c7..dc2293b 100644
--- a/distribution/src/main/scripts/interface/gen-rb/blur_types.rb
+++ b/distribution/src/main/scripts/interface/gen-rb/blur_types.rb
@@ -12,8 +12,9 @@ module Blur
     QUERY_CANCEL = 1
     QUERY_TIMEOUT = 2
     BACK_PRESSURE = 3
-    VALUE_MAP = {0 => "UNKNOWN", 1 => "QUERY_CANCEL", 2 => "QUERY_TIMEOUT", 3 =>
"BACK_PRESSURE"}
-    VALID_VALUES = Set.new([UNKNOWN, QUERY_CANCEL, QUERY_TIMEOUT, BACK_PRESSURE]).freeze
+    REQUEST_TIMEOUT = 4
+    VALUE_MAP = {0 => "UNKNOWN", 1 => "QUERY_CANCEL", 2 => "QUERY_TIMEOUT", 3 =>
"BACK_PRESSURE", 4 => "REQUEST_TIMEOUT"}
+    VALID_VALUES = Set.new([UNKNOWN, QUERY_CANCEL, QUERY_TIMEOUT, BACK_PRESSURE, REQUEST_TIMEOUT]).freeze
   end
 
   module ScoreType


Mime
View raw message