accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [20/50] [abbrv] git commit: ACCUMULO-1477 made master create new connection when getting tserver status
Date Wed, 31 Jul 2013 15:13:57 GMT
ACCUMULO-1477 made master create new connection when getting tserver status

git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/1.4@1488368 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/07b18f25
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/07b18f25
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/07b18f25

Branch: refs/heads/master
Commit: 07b18f2559c3d759b2d56f70c3291a17245251a2
Parents: e5dad25
Author: Keith Turner <kturner@apache.org>
Authored: Fri May 31 19:45:38 2013 +0000
Committer: Keith Turner <kturner@apache.org>
Committed: Fri May 31 19:45:38 2013 +0000

----------------------------------------------------------------------
 .../apache/accumulo/core/util/ThriftUtil.java   | 33 ++++++++++++++++++++
 .../accumulo/server/master/LiveTServerSet.java  | 14 +++++++--
 .../apache/accumulo/server/master/Master.java   |  2 +-
 .../master/tserverOps/ShutdownTServer.java      |  2 +-
 4 files changed, 46 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/07b18f25/src/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java b/src/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
index 22f735c..1b1cdd7 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.core.util;
 
+import java.io.IOException;
 import java.net.InetSocketAddress;
 
 import org.apache.accumulo.cloudtrace.instrument.thrift.TraceWrap;
@@ -29,6 +30,7 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.security.thrift.ThriftSecurityException;
 import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
 import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
 import org.apache.thrift.TServiceClient;
 import org.apache.thrift.TServiceClientFactory;
 import org.apache.thrift.protocol.TCompactProtocol;
@@ -125,6 +127,37 @@ public class ThriftUtil {
     }
   }
   
+  /**
+   * create a transport that is not pooled
+   */
+  public static TTransport createTransport(String address, int port, AccumuloConfiguration
conf) throws TException {
+    TTransport transport = null;
+    
+    try {
+      transport = TTimeoutTransport.create(org.apache.accumulo.core.util.AddressUtil.parseAddress(address,
port),
+          conf.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT));
+      transport = ThriftUtil.transportFactory().getTransport(transport);
+      transport.open();
+      TTransport tmp = transport;
+      transport = null;
+      return tmp;
+    } catch (IOException ex) {
+      throw new TTransportException(ex);
+    } finally {
+      if (transport != null)
+        transport.close();
+    }
+    
+
+  }
+
+  /**
+   * create a transport that is not pooled
+   */
+  public static TTransport createTransport(InetSocketAddress address, AccumuloConfiguration
conf) throws TException {
+    return createTransport(address.getAddress().getHostAddress(), address.getPort(), conf);
+  }
+
   public static TTransportFactory transportFactory() {
     return transportFactory;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07b18f25/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
b/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
index b298004..95243a9 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
@@ -49,6 +49,7 @@ import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransport;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NoNodeException;
 import org.apache.zookeeper.KeeperException.NotEmptyException;
@@ -97,12 +98,19 @@ public class LiveTServerSet implements Watcher {
       }
     }
     
-    public TabletServerStatus getTableMap() throws TException, ThriftSecurityException {
-      TabletClientService.Iface client = ThriftUtil.getClient(new TabletClientService.Client.Factory(),
address, ServerConfiguration.getSystemConfiguration());
+    public TabletServerStatus getTableMap(boolean usePooledConnection) throws TException,
ThriftSecurityException {
+      
+      if (usePooledConnection == true)
+        throw new UnsupportedOperationException();
+      
+      TTransport transport = ThriftUtil.createTransport(address, ServerConfiguration.getSystemConfiguration());
+      
       try {
+        TabletClientService.Iface client = ThriftUtil.createClient(new TabletClientService.Client.Factory(),
transport);
         return client.getTabletServerStatus(null, SecurityConstants.getSystemCredentials());
       } finally {
-        ThriftUtil.returnClient(client);
+        if (transport != null)
+          transport.close();
       }
     }
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07b18f25/src/server/src/main/java/org/apache/accumulo/server/master/Master.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/master/Master.java b/src/server/src/main/java/org/apache/accumulo/server/master/Master.java
index b486343..9970ee8 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/master/Master.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/master/Master.java
@@ -2037,7 +2037,7 @@ public class Master implements LiveTServerSet.Listener, LoggerWatcher,
TableObse
     Set<TServerInstance> currentServers = tserverSet.getCurrentServers();
     for (TServerInstance server : currentServers) {
       try {
-        TabletServerStatus status = tserverSet.getConnection(server).getTableMap();
+        TabletServerStatus status = tserverSet.getConnection(server).getTableMap(false);
         result.put(server, status);
         // TODO maybe remove from bad servers
       } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07b18f25/src/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
b/src/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
index 28c025b..2af04e1 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
@@ -70,7 +70,7 @@ public class ShutdownTServer extends MasterRepo {
       TServerConnection connection = m.getConnection(server);
       if (connection != null) {
         try {
-          TabletServerStatus status = connection.getTableMap();
+          TabletServerStatus status = connection.getTableMap(false);
           if (status.tableMap != null && status.tableMap.isEmpty()) {
             log.info("tablet server hosts no tablets " + server);
             connection.halt(m.getMasterLock());


Mime
View raw message