You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/03/21 16:56:44 UTC

svn commit: r1459374 - in /accumulo/branches/1.5: core/src/main/java/org/apache/accumulo/core/client/admin/ core/src/main/java/org/apache/accumulo/core/util/ server/src/main/java/org/apache/accumulo/server/master/ server/src/main/java/org/apache/accumu...

Author: kturner
Date: Thu Mar 21 15:56:44 2013
New Revision: 1459374

URL: http://svn.apache.org/r1459374
Log:
ACCUMULO-513 made master always form a new connection when getting tserver status info

Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
    accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
    accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/Master.java
    accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java?rev=1459374&r1=1459373&r2=1459374&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java Thu Mar 21 15:56:44 2013
@@ -33,8 +33,10 @@ import org.apache.accumulo.core.client.i
 import org.apache.accumulo.core.client.impl.thrift.ClientService;
 import org.apache.accumulo.core.client.impl.thrift.ConfigurationType;
 import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.master.thrift.MasterClientService;
 import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
 import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client;
 import org.apache.accumulo.core.util.ArgumentChecker;
 import org.apache.accumulo.core.util.ThriftUtil;
@@ -42,6 +44,7 @@ import org.apache.accumulo.core.zookeepe
 import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.apache.accumulo.trace.instrument.Tracer;
 import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
 /**
@@ -219,9 +222,10 @@ public class InstanceOperationsImpl impl
    */
   @Override
   public void ping(String tserver) throws AccumuloException {
-    Client client = null;
+    TTransport transport = null;
     try {
-      client = ThriftUtil.getTServerClient(tserver, instance.getConfiguration());
+      transport = ThriftUtil.createTransport(tserver, instance.getConfiguration().getPort(Property.TSERV_CLIENTPORT), instance.getConfiguration());
+      TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport);
       client.getTabletServerStatus(Tracer.traceInfo(), credentials);
     } catch (TTransportException e) {
       throw new AccumuloException(e);
@@ -230,8 +234,8 @@ public class InstanceOperationsImpl impl
     } catch (TException e) {
       throw new AccumuloException(e);
     } finally {
-      if (client != null) {
-        ThriftUtil.returnClient(client);
+      if (transport != null) {
+        transport.close();
       }
     }
   }

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java?rev=1459374&r1=1459373&r2=1459374&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java Thu Mar 21 15:56:44 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.core.util;
 
+import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.HashMap;
 import java.util.Map;
@@ -164,6 +165,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;
   }

Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java?rev=1459374&r1=1459373&r2=1459374&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java Thu Mar 21 15:56:44 2013
@@ -49,6 +49,7 @@ import org.apache.accumulo.trace.instrum
 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;
@@ -98,12 +99,19 @@ public class LiveTServerSet implements W
       }
     }
     
-    public TabletServerStatus getTableMap() throws TException, ThriftSecurityException {
-      TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, conf);
+    public TabletServerStatus getTableMap(boolean usePooledConnection) throws TException, ThriftSecurityException {
+      
+      if (usePooledConnection == true)
+        throw new UnsupportedOperationException();
+      
+      TTransport transport = ThriftUtil.createTransport(address, conf);
+      
       try {
+        TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport);
         return client.getTabletServerStatus(Tracer.traceInfo(), SecurityConstants.getSystemCredentials());
       } finally {
-        ThriftUtil.returnClient(client);
+        if (transport != null)
+          transport.close();
       }
     }
     

Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/Master.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/Master.java?rev=1459374&r1=1459373&r2=1459374&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/Master.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/Master.java Thu Mar 21 15:56:44 2013
@@ -2005,7 +2005,7 @@ public class Master implements LiveTServ
           TServerConnection connection = tserverSet.getConnection(server);
           if (connection == null)
             throw new IOException("No connection to " + server);
-          TabletServerStatus status = connection.getTableMap();
+          TabletServerStatus status = connection.getTableMap(false);
           result.put(server, status);
         } finally {
           t.setName(oldName);

Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java?rev=1459374&r1=1459373&r2=1459374&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java Thu Mar 21 15:56:44 2013
@@ -70,7 +70,7 @@ public class ShutdownTServer extends Mas
       TServerConnection connection = master.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(master.getMasterLock());