incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [41/45] git commit: Reset the indexes in the client before client is used and when testing connections.
Date Sun, 26 Oct 2014 17:55:39 GMT
Reset the indexes in the client before client is used and when testing connections.


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

Branch: refs/heads/blur-384-random-port-cleanup
Commit: d42374690912e3b9682125ec75e6f6755c66bfb6
Parents: 2683f4b
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Oct 21 18:12:01 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Oct 21 18:12:01 2014 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/blur/thrift/ClientPool.java  | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d4237469/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 d77ebb7..68ac9b4 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
@@ -226,14 +226,23 @@ public class ClientPool {
       if (client.isStale()) {
         // Test client
         if (testClient(connection, client)) {
-          return client;
+          return refresh(client);
         }
       } else {
-        return client;
+        return refresh(client);
       }
     }
   }
 
+  private Client refresh(WeightedClient client) throws IOException {
+    try {
+      client.refresh();
+    } catch (TException e) {
+      throw new IOException(e);
+    }
+    return client;
+  }
+
   public Client newClient(Connection connection) throws TTransportException, IOException
{
     String host = connection.getHost();
     int port = connection.getPort();
@@ -264,6 +273,7 @@ public class ClientPool {
   private static boolean testClient(Connection connection, WeightedClient weightedClient)
{
     LOG.debug("Testing client, could be stale. Client [{0}] for connection [{1}]", weightedClient,
connection);
     try {
+      weightedClient.refresh();
       weightedClient.ping();
       weightedClient.touch();
       return true;


Mime
View raw message