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/09/24 05:07:22 UTC
git commit: ACCUMULO-1585 Replaced most InetSocketAddress usage with
HostAndPort to avoid DNS and reverse DNS lookups
Updated Branches:
refs/heads/master 79b34858d -> 3de0c1ec4
ACCUMULO-1585 Replaced most InetSocketAddress usage with HostAndPort to avoid DNS and reverse DNS lookups
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3de0c1ec
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3de0c1ec
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3de0c1ec
Branch: refs/heads/master
Commit: 3de0c1ec44d476fe1465eb05d33c32de3ccf1068
Parents: 79b3485
Author: Keith Turner <kt...@apache.org>
Authored: Mon Sep 23 22:51:20 2013 -0400
Committer: Keith Turner <kt...@apache.org>
Committed: Mon Sep 23 22:51:20 2013 -0400
----------------------------------------------------------------------
core/pom.xml | 4 ++
.../core/client/impl/ThriftTransportPool.java | 13 ++---
.../apache/accumulo/core/util/AddressUtil.java | 46 +++-------------
.../accumulo/core/util/ServerServices.java | 14 ++---
.../accumulo/core/util/TTimeoutTransport.java | 7 +++
.../apache/accumulo/core/util/ThriftUtil.java | 7 +--
.../accumulo/core/util/AddressUtilTest.java | 57 --------------------
.../server/gc/GarbageCollectWriteAheadLogs.java | 9 ++--
.../server/gc/SimpleGarbageCollector.java | 11 ++--
.../accumulo/server/master/LiveTServerSet.java | 11 ++--
.../apache/accumulo/server/master/Master.java | 3 +-
.../server/master/state/TServerInstance.java | 17 +++---
.../master/state/ZooTabletStateStore.java | 10 ++--
.../master/tserverOps/ShutdownTServer.java | 6 +--
.../apache/accumulo/server/monitor/Monitor.java | 7 +--
.../server/monitor/ZooKeeperStatus.java | 9 ++--
.../server/monitor/servlets/MasterServlet.java | 6 +--
.../monitor/servlets/TServersServlet.java | 10 ++--
.../monitor/util/celltypes/TServerLinkType.java | 6 +--
.../server/tabletserver/TabletServer.java | 15 +++---
.../org/apache/accumulo/server/util/Admin.java | 9 ++--
.../accumulo/server/util/LocalityCheck.java | 7 +--
.../accumulo/server/util/TServerUtils.java | 26 ++++-----
.../accumulo/server/master/TestMergeState.java | 5 +-
.../balancer/ChaoticLoadBalancerTest.java | 12 ++---
.../balancer/DefaultLoadBalancerTest.java | 22 ++++----
.../master/balancer/TableLoadBalancerTest.java | 9 ++--
.../master/state/RootTabletStateStoreTest.java | 5 +-
.../accumulo/test/functional/ZombieTServer.java | 9 ++--
.../metadata/MetadataBatchScanTest.java | 5 +-
.../performance/scan/CollectTabletStats.java | 4 +-
.../test/performance/thrift/NullTserver.java | 6 +--
32 files changed, 155 insertions(+), 232 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 7e2addf..6d6ba9f 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -30,6 +30,10 @@
<artifactId>jcommander</artifactId>
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftTransportPool.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftTransportPool.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftTransportPool.java
index 834084c..f12a9c3 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftTransportPool.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftTransportPool.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.core.client.impl;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.security.SecurityPermission;
import java.util.ArrayList;
import java.util.Collections;
@@ -34,15 +33,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.Daemon;
import org.apache.accumulo.core.util.Pair;
import org.apache.accumulo.core.util.TTimeoutTransport;
import org.apache.accumulo.core.util.ThriftUtil;
import org.apache.log4j.Logger;
+import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
+import com.google.common.net.HostAndPort;
+
public class ThriftTransportPool {
private static SecurityPermission TRANSPORT_POOL_PERMISSION = new SecurityPermission("transportPoolPermission");
@@ -358,8 +359,8 @@ public class ThriftTransportPool {
private ThriftTransportPool() {}
- public TTransport getTransportWithDefaultTimeout(InetSocketAddress addr, AccumuloConfiguration conf) throws TTransportException {
- return getTransport(String.format("%s:%d", addr.getAddress().getHostAddress(), addr.getPort()), conf.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT));
+ public TTransport getTransportWithDefaultTimeout(HostAndPort addr, AccumuloConfiguration conf) throws TTransportException {
+ return getTransport(String.format("%s:%d", addr.getHostText(), addr.getPort()), conf.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT));
}
public TTransport getTransport(String location, long milliseconds) throws TTransportException {
@@ -455,10 +456,10 @@ public class ThriftTransportPool {
private TTransport createNewTransport(ThriftTransportKey cacheKey) throws TTransportException {
TTransport transport;
if (cacheKey.getTimeout() == 0) {
- transport = AddressUtil.createTSocket(cacheKey.getLocation(), cacheKey.getPort());
+ transport = new TSocket(cacheKey.getLocation(), cacheKey.getPort());
} else {
try {
- transport = TTimeoutTransport.create(AddressUtil.parseAddress(cacheKey.getLocation(), cacheKey.getPort()), cacheKey.getTimeout());
+ transport = TTimeoutTransport.create(HostAndPort.fromParts(cacheKey.getLocation(), cacheKey.getPort()), cacheKey.getTimeout());
} catch (IOException ex) {
throw new TTransportException(ex);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/src/main/java/org/apache/accumulo/core/util/AddressUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/AddressUtil.java b/core/src/main/java/org/apache/accumulo/core/util/AddressUtil.java
index c045773..49d689e 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/AddressUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/AddressUtil.java
@@ -16,48 +16,16 @@
*/
package org.apache.accumulo.core.util;
-import java.net.InetSocketAddress;
-
-import org.apache.hadoop.io.Text;
-import org.apache.thrift.transport.TSocket;
+import com.google.common.net.HostAndPort;
public class AddressUtil {
- static public InetSocketAddress parseAddress(String address, int defaultPort) throws NumberFormatException {
- String[] parts = extractPartsFromAddress(address);
- if (parts.length == 2) {
- if (parts[1].isEmpty())
- return new InetSocketAddress(parts[0], defaultPort);
- return new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
- }
- return new InetSocketAddress(address, defaultPort);
- }
-
- static public InetSocketAddress parseAddress(String address) throws NumberFormatException {
- String[] parts = extractPartsFromAddress(address);
- if (parts.length == 2)
- return new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
- else
- throw new IllegalArgumentException("Address was expected to contain port. address=" + address);
- }
- static public InetSocketAddress parseAddress(Text address, int defaultPort) {
- return parseAddress(address.toString(), defaultPort);
- }
-
- static public TSocket createTSocket(String address, int defaultPort) {
- InetSocketAddress addr = parseAddress(address, defaultPort);
- return new TSocket(addr.getHostName(), addr.getPort());
- }
-
- static public String toString(InetSocketAddress addr) {
- return addr.getAddress().getHostAddress() + ":" + addr.getPort();
- }
- static private String[] extractPartsFromAddress(String address) {
- String[] parts = address.split(":", 2);
- if (address.contains("+"))
- parts = address.split("\\+", 2);
-
- return parts;
+ static public HostAndPort parseAddress(String address) throws NumberFormatException {
+ HostAndPort hap = HostAndPort.fromString(address);
+ if (!hap.hasPort())
+ throw new IllegalArgumentException("Address was expected to contain port. address=" + address);
+
+ return hap;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java b/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
index 037c4a9..2891cdb 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
@@ -16,9 +16,10 @@
*/
package org.apache.accumulo.core.util;
-import java.net.InetSocketAddress;
import java.util.EnumMap;
+import com.google.common.net.HostAndPort;
+
public class ServerServices implements Comparable<ServerServices> {
public static enum Service {
TSERV_CLIENT, GC_CLIENT;
@@ -48,15 +49,8 @@ public class ServerServices implements Comparable<ServerServices> {
return services.get(service);
}
- public InetSocketAddress getAddress(Service service) {
- String address = getAddressString(service);
- String[] parts = address.split(":", 2);
- if (parts.length == 2) {
- if (parts[1].isEmpty())
- throw new IllegalArgumentException("Address was expected to have port but didn't. address=" + address);
- return new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
- }
- throw new IllegalArgumentException("Address was expected to have port but didn't. address=" + address);
+ public HostAndPort getAddress(Service service) {
+ return AddressUtil.parseAddress(getAddressString(service));
}
// DON'T CHANGE THIS; WE'RE USING IT FOR SERIALIZATION!!!
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/src/main/java/org/apache/accumulo/core/util/TTimeoutTransport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/TTimeoutTransport.java b/core/src/main/java/org/apache/accumulo/core/util/TTimeoutTransport.java
index 0aebc39..a66b268 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/TTimeoutTransport.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/TTimeoutTransport.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.spi.SelectorProvider;
@@ -30,6 +31,8 @@ import org.apache.hadoop.net.NetUtils;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransport;
+import com.google.common.net.HostAndPort;
+
public class TTimeoutTransport {
private static InputStream getInputStream(Socket socket, long timeout) {
@@ -41,6 +44,10 @@ public class TTimeoutTransport {
}
}
+ public static TTransport create(HostAndPort addr, long timeoutMillis) throws IOException {
+ return create(new InetSocketAddress(addr.getHostText(), addr.getPort()), timeoutMillis);
+ }
+
public static TTransport create(SocketAddress addr, long timeoutMillis) throws IOException {
Socket socket = SelectorProvider.provider().openSocketChannel().socket();
socket.setSoLinger(false, 0);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java b/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
index 49fd561..fc18440 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ThriftUtil.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.core.util;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
@@ -45,6 +44,8 @@ import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.apache.thrift.transport.TTransportFactory;
+import com.google.common.net.HostAndPort;
+
public class ThriftUtil {
private static final Logger log = Logger.getLogger(ThriftUtil.class);
@@ -85,7 +86,7 @@ public class ThriftUtil {
return factory.getClient(protocolFactory.getProtocol(transport), protocolFactory.getProtocol(transport));
}
- static public <T extends TServiceClient> T getClient(TServiceClientFactory<T> factory, InetSocketAddress address, AccumuloConfiguration conf)
+ static public <T extends TServiceClient> T getClient(TServiceClientFactory<T> factory, HostAndPort address, AccumuloConfiguration conf)
throws TTransportException {
return createClient(factory, ThriftTransportPool.getInstance().getTransportWithDefaultTimeout(address, conf));
}
@@ -164,7 +165,7 @@ public class ThriftUtil {
/**
* create a transport that is not pooled
*/
- public static TTransport createTransport(InetSocketAddress address, AccumuloConfiguration conf) throws TException {
+ public static TTransport createTransport(HostAndPort address, AccumuloConfiguration conf) throws TException {
TTransport transport = null;
try {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/core/src/test/java/org/apache/accumulo/core/util/AddressUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/AddressUtilTest.java b/core/src/test/java/org/apache/accumulo/core/util/AddressUtilTest.java
deleted file mode 100644
index a695fd4..0000000
--- a/core/src/test/java/org/apache/accumulo/core/util/AddressUtilTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.util;
-
-import java.net.InetSocketAddress;
-
-import junit.framework.TestCase;
-
-import org.apache.hadoop.io.Text;
-import org.apache.thrift.transport.TSocket;
-
-/**
- * Test the AddressUtil class.
- *
- */
-public class AddressUtilTest extends TestCase {
- public void testAddress() {
- InetSocketAddress addr = AddressUtil.parseAddress("127.0.0.1", 12345);
- assertTrue(addr.equals(new InetSocketAddress("127.0.0.1", 12345)));
- InetSocketAddress addr2 = AddressUtil.parseAddress("127.0.0.1:1234", 12345);
- assertTrue(addr2.equals(new InetSocketAddress("127.0.0.1", 1234)));
- InetSocketAddress addr3 = AddressUtil.parseAddress("127.0.0.1:", 12345);
- assertTrue(addr3.equals(new InetSocketAddress("127.0.0.1", 12345)));
- InetSocketAddress addr4 = AddressUtil.parseAddress("127.0.0.1+456");
- assertTrue(addr4.equals(new InetSocketAddress("127.0.0.1", 456)));
- try {
- AddressUtil.parseAddress("127.0.0.1:junk", 12345);
- fail("Number Format Exception Not Thrown");
- } catch (NumberFormatException ex) {
- assertTrue(true);
- }
- InetSocketAddress addr5 = AddressUtil.parseAddress(new Text("127.0.0.1:543"), 12345);
- assertTrue(addr5.equals(new InetSocketAddress("127.0.0.1", 543)));
- TSocket sock = AddressUtil.createTSocket("127.0.0.11111", 0);
- // lame:
- assertTrue(sock != null);
- }
-
- public void testToString() {
- assertTrue(AddressUtil.toString(new InetSocketAddress("127.0.0.1", 1234)).equals("127.0.0.1:1234"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java b/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
index 2ce40b5..f6f08cd 100644
--- a/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
+++ b/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.gc;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -54,6 +53,8 @@ import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.apache.zookeeper.KeeperException;
+import com.google.common.net.HostAndPort;
+
public class GarbageCollectWriteAheadLogs {
private static final Logger log = Logger.getLogger(GarbageCollectWriteAheadLogs.class);
@@ -116,9 +117,9 @@ public class GarbageCollectWriteAheadLogs {
}
}
- boolean holdsLock(InetSocketAddress addr) {
+ boolean holdsLock(HostAndPort addr) {
try {
- String zpath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + org.apache.accumulo.core.util.AddressUtil.toString(addr);
+ String zpath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + addr.toString();
List<String> children = ZooReaderWriter.getInstance().getChildren(zpath);
return !(children == null || children.isEmpty());
} catch (KeeperException.NoNodeException ex) {
@@ -147,7 +148,7 @@ public class GarbageCollectWriteAheadLogs {
}
}
} else {
- InetSocketAddress address = AddressUtil.parseAddress(entry.getKey());
+ HostAndPort address = AddressUtil.parseAddress(entry.getKey());
if (!holdsLock(address)) {
for (Path path : entry.getValue()) {
log.debug("Removing WAL for offline server " + path);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java b/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
index 92100ec..817aa74 100644
--- a/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
+++ b/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.gc;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
@@ -103,6 +102,7 @@ import org.apache.log4j.Logger;
import org.apache.zookeeper.KeeperException;
import com.beust.jcommander.Parameter;
+import com.google.common.net.HostAndPort;
public class SimpleGarbageCollector implements Iface {
private static final Text EMPTY_TEXT = new Text();
@@ -368,8 +368,7 @@ public class SimpleGarbageCollector implements Iface {
}
}
- private void getZooLock(InetSocketAddress addr) throws KeeperException, InterruptedException {
- String address = addr.getHostName() + ":" + addr.getPort();
+ private void getZooLock(HostAndPort addr) throws KeeperException, InterruptedException {
String path = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZGC_LOCK;
LockWatcher lockWatcher = new LockWatcher() {
@@ -393,18 +392,18 @@ public class SimpleGarbageCollector implements Iface {
while (true) {
lock = new ZooLock(path);
- if (lock.tryLock(lockWatcher, new ServerServices(address, Service.GC_CLIENT).toString().getBytes())) {
+ if (lock.tryLock(lockWatcher, new ServerServices(addr.toString(), Service.GC_CLIENT).toString().getBytes())) {
break;
}
UtilWaitThread.sleep(1000);
}
}
- private InetSocketAddress startStatsService() throws UnknownHostException {
+ private HostAndPort startStatsService() throws UnknownHostException {
Processor<Iface> processor = new Processor<Iface>(TraceWrap.service(this));
int port = instance.getConfiguration().getPort(Property.GC_PORT);
long maxMessageSize = instance.getConfiguration().getMemoryInBytes(Property.GENERAL_MAX_MESSAGE_SIZE);
- InetSocketAddress result = new InetSocketAddress(opts.getAddress(), port);
+ HostAndPort result = HostAndPort.fromParts(opts.getAddress(), port);
try {
port = TServerUtils.startTServer(result, processor, this.getClass().getSimpleName(), "GC Monitor Service", 2, 1000, maxMessageSize).address.getPort();
} catch (Exception ex) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java b/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
index ad8f656..3eef065 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.master;
import static org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy.SKIP;
-import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.HashSet;
@@ -57,6 +56,8 @@ import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.Stat;
+import com.google.common.net.HostAndPort;
+
public class LiveTServerSet implements Watcher {
public interface Listener {
@@ -71,9 +72,9 @@ public class LiveTServerSet implements Watcher {
private ZooCache zooCache;
public class TServerConnection {
- private final InetSocketAddress address;
+ private final HostAndPort address;
- public TServerConnection(InetSocketAddress addr) throws TException {
+ public TServerConnection(HostAndPort addr) throws TException {
address = addr;
}
@@ -293,7 +294,7 @@ public class LiveTServerSet implements Watcher {
} else {
locklessServers.remove(zPath);
ServerServices services = new ServerServices(new String(lockData));
- InetSocketAddress client = services.getAddress(ServerServices.Service.TSERV_CLIENT);
+ HostAndPort client = services.getAddress(ServerServices.Service.TSERV_CLIENT);
TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
if (info == null) {
@@ -363,7 +364,7 @@ public class LiveTServerSet implements Watcher {
}
public synchronized TServerInstance find(String tabletServer) {
- InetSocketAddress addr = AddressUtil.parseAddress(tabletServer);
+ HostAndPort addr = AddressUtil.parseAddress(tabletServer);
for (Entry<String,TServerInfo> entry : current.entrySet()) {
if (entry.getValue().instance.getLocation().equals(addr))
return entry.getValue().instance;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/master/Master.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/Master.java b/server/src/main/java/org/apache/accumulo/server/master/Master.java
index fec6d79..499f274 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/Master.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/Master.java
@@ -77,7 +77,6 @@ import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.Credentials;
import org.apache.accumulo.core.security.SecurityUtil;
import org.apache.accumulo.core.security.thrift.TCredentials;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.accumulo.core.util.Daemon;
import org.apache.accumulo.core.util.UtilWaitThread;
@@ -1516,7 +1515,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver, CurrentSt
ServerAddress sa = TServerUtils.startServer(getSystemConfiguration(), hostname, Property.MASTER_CLIENTPORT, processor, "Master",
"Master Client Service Handler", null, Property.MASTER_MINTHREADS, Property.MASTER_THREADCHECK, Property.GENERAL_MAX_MESSAGE_SIZE);
clientService = sa.server;
- String address = AddressUtil.toString(sa.address);
+ String address = sa.address.toString();
log.info("Setting master lock data to " + address);
masterLock.replaceLockData(address.getBytes());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java b/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
index 753a3cf..4de64a8 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.server.master.state;
import java.io.Serializable;
-import java.net.InetSocketAddress;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
@@ -25,6 +24,8 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
import org.apache.accumulo.core.util.AddressUtil;
import org.apache.hadoop.io.Text;
+import com.google.common.net.HostAndPort;
+
/**
* A tablet is assigned to a tablet server at the given address as long as it is alive and well. When the tablet server is restarted, the instance information
* it advertises will change. Therefore tablet assignments can be considered out-of-date if the tablet server instance information has been changed.
@@ -34,17 +35,17 @@ public class TServerInstance implements Comparable<TServerInstance>, Serializabl
private static final long serialVersionUID = 1L;
- private InetSocketAddress location;
+ private HostAndPort location;
private String session;
private String cachedStringRepresentation;
- public TServerInstance(InetSocketAddress address, String session) {
+ public TServerInstance(HostAndPort address, String session) {
this.location = address;
this.session = session;
this.cachedStringRepresentation = hostPort() + "[" + session + "]";
}
- public TServerInstance(InetSocketAddress address, long session) {
+ public TServerInstance(HostAndPort address, long session) {
this(address, Long.toHexString(session));
}
@@ -102,11 +103,11 @@ public class TServerInstance implements Comparable<TServerInstance>, Serializabl
}
public String host() {
- return getLocation().getAddress().getHostAddress();
+ return getLocation().getHostText();
}
public String hostPort() {
- return org.apache.accumulo.core.util.AddressUtil.toString(getLocation());
+ return getLocation().toString();
}
public Text asColumnQualifier() {
@@ -114,10 +115,10 @@ public class TServerInstance implements Comparable<TServerInstance>, Serializabl
}
public Value asMutationValue() {
- return new Value(org.apache.accumulo.core.util.AddressUtil.toString(getLocation()).getBytes());
+ return new Value(getLocation().toString().getBytes());
}
- public InetSocketAddress getLocation() {
+ public HostAndPort getLocation() {
return location;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
index 199c8c1..47eed06 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
@@ -17,18 +17,18 @@
package org.apache.accumulo.server.master.state;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.server.util.MetadataTableUtil;
import org.apache.commons.lang.NotImplementedException;
import org.apache.log4j.Logger;
+import com.google.common.net.HostAndPort;
+
public class ZooTabletStateStore extends TabletStateStore {
private static final Logger log = Logger.getLogger(ZooTabletStateStore.class);
@@ -106,7 +106,7 @@ public class ZooTabletStateStore extends TabletStateStore {
protected TServerInstance parse(byte[] current) {
String str = new String(current);
String[] parts = str.split("[|]", 2);
- InetSocketAddress address = AddressUtil.parseAddress(parts[0], 0);
+ HostAndPort address = HostAndPort.fromString(parts[0]);
if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) {
return new TServerInstance(address, parts[1]);
} else {
@@ -122,7 +122,7 @@ public class ZooTabletStateStore extends TabletStateStore {
Assignment assignment = assignments.iterator().next();
if (assignment.tablet.compareTo(RootTable.EXTENT) != 0)
throw new IllegalArgumentException("You can only store the root tablet location");
- String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession();
+ String value = assignment.server.getLocation() + "|" + assignment.server.getSession();
Iterator<TabletLocationState> currentIter = iterator();
TabletLocationState current = currentIter.next();
if (current.current != null) {
@@ -138,7 +138,7 @@ public class ZooTabletStateStore extends TabletStateStore {
Assignment assignment = assignments.iterator().next();
if (assignment.tablet.compareTo(RootTable.EXTENT) != 0)
throw new IllegalArgumentException("You can only store the root tablet location");
- String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession();
+ String value = assignment.server.getLocation() + "|" + assignment.server.getSession();
Iterator<TabletLocationState> currentIter = iterator();
TabletLocationState current = currentIter.next();
if (current.current != null) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java b/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
index d411ac4..1a196a4 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tserverOps/ShutdownTServer.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.master.tserverOps;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.fate.Repo;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
@@ -54,10 +53,9 @@ public class ShutdownTServer extends MasterRepo {
public Repo<Master> call(long tid, Master master) throws Exception {
// suppress assignment of tablets to the server
if (force) {
- String tserver = AddressUtil.toString(server.getLocation());
- String path = ZooUtil.getRoot(master.getInstance()) + Constants.ZTSERVERS + "/" + tserver;
+ String path = ZooUtil.getRoot(master.getInstance()) + Constants.ZTSERVERS + "/" + server.getLocation();
ZooLock.deleteLock(path);
- path = ZooUtil.getRoot(master.getInstance()) + Constants.ZDEADTSERVERS + "/" + tserver;
+ path = ZooUtil.getRoot(master.getInstance()) + Constants.ZDEADTSERVERS + "/" + server.getLocation();
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
zoo.putPersistentData(path, "forced down".getBytes(), NodeExistsPolicy.OVERWRITE);
return null;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java b/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
index e0a1e9d..650f5b9 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.server.monitor;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -81,6 +80,8 @@ import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
+import com.google.common.net.HostAndPort;
+
/**
* Serve master statistics with an embedded web server.
*/
@@ -417,7 +418,7 @@ public class Monitor {
private static GCStatus fetchGcStatus() {
GCStatus result = null;
- InetSocketAddress address = null;
+ HostAndPort address = null;
try {
// Read the gc location from its lock
Instance instance = HdfsZooInstance.getInstance();
@@ -496,7 +497,7 @@ public class Monitor {
server.start();
try {
- String monitorAddress = org.apache.accumulo.core.util.AddressUtil.toString(new InetSocketAddress(hostname, server.getPort()));
+ String monitorAddress = HostAndPort.fromParts(hostname, server.getPort()).toString();
ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(instance) + Constants.ZMONITOR, monitorAddress.getBytes(),
NodeExistsPolicy.OVERWRITE);
log.info("Set monitor address in zookeeper to " + monitorAddress);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java b/server/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
index c3ef3a0..2eff791 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.server.monitor;
-import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -29,6 +28,8 @@ import org.apache.log4j.Logger;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
+import com.google.common.net.HostAndPort;
+
public class ZooKeeperStatus implements Runnable {
private static final Logger log = Logger.getLogger(ZooKeeperStatus.class);
@@ -91,11 +92,11 @@ public class ZooKeeperStatus implements Runnable {
String[] parts = keeper.split(":");
TTransport transport = null;
try {
- InetSocketAddress addr;
+ HostAndPort addr;
if (parts.length > 1)
- addr = new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
+ addr = HostAndPort.fromParts(parts[0], Integer.parseInt(parts[1]));
else
- addr = new InetSocketAddress(parts[0], 2181);
+ addr = HostAndPort.fromParts(parts[0], 2181);
transport = TTimeoutTransport.create(addr, 10 * 1000l);
transport.write("stat\n".getBytes(), 0, 5);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/monitor/servlets/MasterServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/MasterServlet.java b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/MasterServlet.java
index 9c0f6f3..8960395 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/MasterServlet.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/MasterServlet.java
@@ -55,7 +55,7 @@ public class MasterServlet extends BasicServlet {
@Override
protected String getTitle(HttpServletRequest req) {
List<String> masters = Monitor.getInstance().getMasterLocations();
- return "Master Server" + (masters.size() == 0 ? "" : ":" + AddressUtil.parseAddress(masters.get(0)).getHostName());
+ return "Master Server" + (masters.size() == 0 ? "" : ":" + AddressUtil.parseAddress(masters.get(0)).getHostText());
}
@Override
@@ -149,7 +149,7 @@ public class MasterServlet extends BasicServlet {
masterStatus.addSortableColumn("OS Load", new NumberType<Double>(0., guessHighLoad * 1., 0., guessHighLoad * 3.),
"The one-minute load average on the computer that runs the monitor web server.");
TableRow row = masterStatus.prepareRow();
- row.add(masters.size() == 0 ? "<div class='error'>Down</div>" : AddressUtil.parseAddress(masters.get(0)).getHostName());
+ row.add(masters.size() == 0 ? "<div class='error'>Down</div>" : AddressUtil.parseAddress(masters.get(0)).getHostText());
row.add(Monitor.getMmi().tServerInfo.size());
row.add(slaves.size());
row.add("<a href='/gc'>" + gcStatus + "</a>");
@@ -182,7 +182,7 @@ public class MasterServlet extends BasicServlet {
if (server.logSorts != null) {
for (RecoveryStatus recovery : server.logSorts) {
TableRow row = recoveryTable.prepareRow();
- row.add(AddressUtil.parseAddress(server.name).getHostName());
+ row.add(AddressUtil.parseAddress(server.name).getHostText());
row.add(recovery.name);
row.add((long) recovery.runtime);
row.add(recovery.progress);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/monitor/servlets/TServersServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/TServersServlet.java b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/TServersServlet.java
index c8548dd..b0b300b 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/TServersServlet.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/TServersServlet.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.server.monitor.servlets;
import java.lang.management.ManagementFactory;
-import java.net.InetSocketAddress;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -35,7 +34,6 @@ import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.core.tabletserver.thrift.ActionStats;
import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.Duration;
import org.apache.accumulo.core.util.ThriftUtil;
import org.apache.accumulo.server.master.state.TabletServerState;
@@ -55,6 +53,8 @@ import org.apache.accumulo.server.tabletserver.TabletStatsKeeper;
import org.apache.accumulo.trace.instrument.Tracer;
import org.apache.commons.codec.binary.Base64;
+import com.google.common.net.HostAndPort;
+
public class TServersServlet extends BasicServlet {
private static final long serialVersionUID = 1L;
@@ -119,7 +119,7 @@ public class TServersServlet extends BasicServlet {
double currentMajorStdDev = 0;
TabletStats total = new TabletStats(null, new ActionStats(), new ActionStats(), new ActionStats(), 0, 0, 0, 0);
- InetSocketAddress address = AddressUtil.parseAddress(tserverAddress, -1);
+ HostAndPort address = HostAndPort.fromString(tserverAddress);
TabletStats historical = new TabletStats(null, new ActionStats(), new ActionStats(), new ActionStats(), 0, 0, 0, 0);
List<TabletStats> tsStats = new ArrayList<TabletStats>();
try {
@@ -246,9 +246,9 @@ public class TServersServlet extends BasicServlet {
opHistoryDetails.generate(req, sb);
}
- private void doDetailTable(HttpServletRequest req, StringBuilder sb, InetSocketAddress address, int numTablets, TabletStats total, TabletStats historical) {
+ private void doDetailTable(HttpServletRequest req, StringBuilder sb, HostAndPort address, int numTablets, TabletStats total, TabletStats historical) {
Table detailTable = new Table("tServerDetail", "Details");
- detailTable.setSubCaption(address.getHostName() + ":" + address.getPort());
+ detailTable.setSubCaption(address.getHostText() + ":" + address.getPort());
detailTable.addSortableColumn("Hosted Tablets", new NumberType<Integer>(), null);
detailTable.addSortableColumn("Entries", new NumberType<Long>(), null);
detailTable.addSortableColumn("Minor Compacting", new NumberType<Integer>(), null);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/monitor/util/celltypes/TServerLinkType.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/util/celltypes/TServerLinkType.java b/server/src/main/java/org/apache/accumulo/server/monitor/util/celltypes/TServerLinkType.java
index 13d99df..8081f30 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/util/celltypes/TServerLinkType.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/util/celltypes/TServerLinkType.java
@@ -16,10 +16,7 @@
*/
package org.apache.accumulo.server.monitor.util.celltypes;
-import java.net.InetSocketAddress;
-
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
-import org.apache.accumulo.core.util.AddressUtil;
public class TServerLinkType extends CellType<TabletServerStatus> {
@@ -38,8 +35,7 @@ public class TServerLinkType extends CellType<TabletServerStatus> {
public static String displayName(String address) {
if (address == null)
return "--Unknown--";
- InetSocketAddress inetAddress = AddressUtil.parseAddress(address, 0);
- return inetAddress.getHostName() + ":" + inetAddress.getPort();
+ return address;
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java b/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
index 8959d4f..ce22534 100644
--- a/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
+++ b/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
@@ -22,7 +22,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
-import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
@@ -223,6 +222,8 @@ import org.apache.thrift.server.TServer;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException;
+import com.google.common.net.HostAndPort;
+
enum ScanRunState {
QUEUED, RUNNING, FINISHED
}
@@ -2892,7 +2893,7 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
// used for stopping the server and MasterListener thread
private volatile boolean serverStopRequested = false;
- private InetSocketAddress clientAddress;
+ private HostAndPort clientAddress;
private TabletServerResourceManager resourceManager;
private SecurityOperation security;
@@ -2935,7 +2936,7 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
MetadataTableUtil.addLogEntry(SystemCredentials.get(), entry, getLock());
}
- private InetSocketAddress startServer(AccumuloConfiguration conf, String address, Property portHint, TProcessor processor, String threadName) throws UnknownHostException {
+ private HostAndPort startServer(AccumuloConfiguration conf, String address, Property portHint, TProcessor processor, String threadName) throws UnknownHostException {
Property maxMessageSizeProperty = (conf.get(Property.TSERV_MAX_MESSAGE_SIZE) != null ? Property.TSERV_MAX_MESSAGE_SIZE : Property.GENERAL_MAX_MESSAGE_SIZE);
ServerAddress sp = TServerUtils.startServer(conf, address, portHint, processor, this.getClass().getSimpleName(), threadName, Property.TSERV_PORTSEARCH,
Property.TSERV_MINTHREADS, Property.TSERV_THREADCHECK, maxMessageSizeProperty);
@@ -2976,11 +2977,11 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
ThriftUtil.returnClient(client);
}
- private InetSocketAddress startTabletClientService() throws UnknownHostException {
+ private HostAndPort startTabletClientService() throws UnknownHostException {
// start listening for client connection last
Iface tch = TraceWrap.service(new ThriftClientHandler());
Processor<Iface> processor = new Processor<Iface>(tch);
- InetSocketAddress address = startServer(getSystemConfiguration(), clientAddress.getHostName(), Property.TSERV_CLIENTPORT, processor, "Thrift Client Server");
+ HostAndPort address = startServer(getSystemConfiguration(), clientAddress.getHostText(), Property.TSERV_CLIENTPORT, processor, "Thrift Client Server");
log.info("address = " + address);
return address;
}
@@ -3332,7 +3333,7 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
public String getClientAddressString() {
if (clientAddress == null)
return null;
- return clientAddress.getHostName() + ":" + clientAddress.getPort();
+ return clientAddress.getHostText() + ":" + clientAddress.getPort();
}
TServerInstance getTabletSession() {
@@ -3351,7 +3352,7 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
public void config(String hostname) {
log.info("Tablet server starting on " + hostname);
security = AuditedSecurityOperation.getInstance();
- clientAddress = new InetSocketAddress(hostname, 0);
+ clientAddress = HostAndPort.fromParts(hostname, 0);
logger = new TabletServerLogger(this, getSystemConfiguration().getMemoryInBytes(Property.TSERV_WALOG_MAX_SIZE));
try {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/util/Admin.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/src/main/java/org/apache/accumulo/server/util/Admin.java
index 74581a5..fe84e52 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/Admin.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/Admin.java
@@ -20,10 +20,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.net.InetSocketAddress;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
@@ -58,6 +54,7 @@ import org.apache.log4j.Logger;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
+import com.google.common.net.HostAndPort;
public class Admin {
private static final Logger log = Logger.getLogger(Admin.class);
@@ -296,8 +293,8 @@ public class Admin {
private static void stopTabletServer(final Instance instance, final Credentials creds, List<String> servers, final boolean force) throws AccumuloException,
AccumuloSecurityException {
for (String server : servers) {
- InetSocketAddress address = AddressUtil.parseAddress(server);
- final String finalServer = org.apache.accumulo.core.util.AddressUtil.toString(address);
+ HostAndPort address = AddressUtil.parseAddress(server);
+ final String finalServer = address.toString();
log.info("Stopping server " + finalServer);
MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() {
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/util/LocalityCheck.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/LocalityCheck.java b/server/src/main/java/org/apache/accumulo/server/util/LocalityCheck.java
index f7a57d8..112a619 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/LocalityCheck.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/LocalityCheck.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.server.util;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -39,6 +38,8 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import com.google.common.net.HostAndPort;
+
public class LocalityCheck {
public int run(String[] args) throws Exception {
@@ -91,8 +92,8 @@ public class LocalityCheck {
for (BlockLocation blockLocation : fileBlockLocations) {
allBlocks++;
for (String location : blockLocation.getHosts()) {
- InetSocketAddress inetSocketAddress = new InetSocketAddress(location, 0);
- if (inetSocketAddress.getAddress().getHostAddress().equals(host)) {
+ HostAndPort hap = HostAndPort.fromParts(location, 0);
+ if (hap.getHostText().equals(host)) {
matchingBlocks++;
break;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java b/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
index fe49cfd..fd052c0 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
@@ -50,6 +50,8 @@ import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
+import com.google.common.net.HostAndPort;
+
public class TServerUtils {
private static final Logger log = Logger.getLogger(TServerUtils.class);
@@ -57,9 +59,9 @@ public class TServerUtils {
public static class ServerAddress {
public final TServer server;
- public final InetSocketAddress address;
+ public final HostAndPort address;
- public ServerAddress(TServer server, InetSocketAddress address) {
+ public ServerAddress(TServer server, HostAndPort address) {
this.server = server;
this.address = address;
}
@@ -118,7 +120,7 @@ public class TServerUtils {
if (port > 65535)
port = 1024 + port % (65535 - 1024);
try {
- InetSocketAddress addr = new InetSocketAddress(address, port);
+ HostAndPort addr = HostAndPort.fromParts(address, port);
return TServerUtils.startTServer(addr, timedProcessor, serverName, threadName, minThreads, timeBetweenThreadChecks, maxMessageSize);
} catch (Exception ex) {
log.info("Unable to use port " + port + ", retrying. (Thread Name = " + threadName + ")");
@@ -213,11 +215,11 @@ public class TServerUtils {
}
}
- public static ServerAddress startHsHaServer(InetSocketAddress address, TProcessor processor, final String serverName, String threadName, final int numThreads,
+ public static ServerAddress startHsHaServer(HostAndPort address, TProcessor processor, final String serverName, String threadName, final int numThreads,
long timeBetweenThreadChecks, long maxMessageSize) throws TTransportException {
- TNonblockingServerSocket transport = new TNonblockingServerSocket(address);
+ TNonblockingServerSocket transport = new TNonblockingServerSocket(new InetSocketAddress(address.getHostText(), address.getPort()));
// check for the special "bind to everything address"
- String hostname = address.getAddress().getHostAddress();
+ String hostname = address.getHostText();
if (hostname.equals("0.0.0.0")) {
// can't get the address from the bind, so we'll do our best to invent our hostname
try {
@@ -264,10 +266,10 @@ public class TServerUtils {
}, timeBetweenThreadChecks, timeBetweenThreadChecks);
options.executorService(pool);
options.processorFactory(new TProcessorFactory(processor));
- return new ServerAddress(new THsHaServer(options), new InetSocketAddress(hostname, port));
+ return new ServerAddress(new THsHaServer(options), HostAndPort.fromParts(hostname, port));
}
- public static ServerAddress startThreadPoolServer(InetSocketAddress address, TProcessor processor, String serverName, String threadName, int numThreads)
+ public static ServerAddress startThreadPoolServer(HostAndPort address, TProcessor processor, String serverName, String threadName, int numThreads)
throws TTransportException {
// if port is zero, then we must bind to get the port number
@@ -275,8 +277,8 @@ public class TServerUtils {
try {
sock = ServerSocketChannel.open().socket();
sock.setReuseAddress(true);
- sock.bind(address);
- address = new InetSocketAddress(address.getHostName(), sock.getLocalPort());
+ sock.bind(new InetSocketAddress(address.getHostText(), address.getPort()));
+ address = HostAndPort.fromParts(address.getHostText(), sock.getLocalPort());
} catch (IOException ex) {
throw new TTransportException(ex);
}
@@ -288,12 +290,12 @@ public class TServerUtils {
return new ServerAddress(new TThreadPoolServer(options), address);
}
- public static ServerAddress startTServer(InetSocketAddress address, TProcessor processor, String serverName, String threadName, int numThreads, long timeBetweenThreadChecks, long maxMessageSize)
+ public static ServerAddress startTServer(HostAndPort address, TProcessor processor, String serverName, String threadName, int numThreads, long timeBetweenThreadChecks, long maxMessageSize)
throws TTransportException {
return startTServer(address, new TimedProcessor(processor, serverName, threadName), serverName, threadName, numThreads, timeBetweenThreadChecks, maxMessageSize);
}
- public static ServerAddress startTServer(InetSocketAddress address, TimedProcessor processor, String serverName, String threadName, int numThreads, long timeBetweenThreadChecks, long maxMessageSize)
+ public static ServerAddress startTServer(HostAndPort address, TimedProcessor processor, String serverName, String threadName, int numThreads, long timeBetweenThreadChecks, long maxMessageSize)
throws TTransportException {
ServerAddress result = startHsHaServer(address, processor, serverName, threadName, numThreads, timeBetweenThreadChecks, maxMessageSize);
// ServerPort result = startThreadPoolServer(port, processor, serverName, threadName, -1);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/test/java/org/apache/accumulo/server/master/TestMergeState.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/TestMergeState.java b/server/src/test/java/org/apache/accumulo/server/master/TestMergeState.java
index 48e1e14..0500a7a 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/TestMergeState.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/TestMergeState.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.server.master;
-import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@@ -52,6 +51,8 @@ import org.apache.hadoop.io.Text;
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.net.HostAndPort;
+
/**
*
*/
@@ -59,7 +60,7 @@ public class TestMergeState {
class MockCurrentState implements CurrentState {
- TServerInstance someTServer = new TServerInstance(new InetSocketAddress("127.0.0.1", 1234), 0x123456);
+ TServerInstance someTServer = new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1234), 0x123456);
MergeInfo mergeInfo;
MockCurrentState(MergeInfo info) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java b/server/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java
index c6b4626..e741e7a 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.master.balancer;
import static org.junit.Assert.assertEquals;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -34,13 +33,14 @@ import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.master.thrift.TableInfo;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.server.master.state.TServerInstance;
import org.apache.accumulo.server.master.state.TabletMigration;
import org.apache.hadoop.io.Text;
import org.apache.thrift.TException;
import org.junit.Test;
+import com.google.common.net.HostAndPort;
+
public class ChaoticLoadBalancerTest {
class FakeTServer {
@@ -82,9 +82,9 @@ public class ChaoticLoadBalancerTest {
@Test
public void testAssignMigrations() {
servers.clear();
- servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1234), "a"), new FakeTServer());
- servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1235), "b"), new FakeTServer());
- servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1236), "c"), new FakeTServer());
+ servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1234), "a"), new FakeTServer());
+ servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1235), "b"), new FakeTServer());
+ servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1236), "c"), new FakeTServer());
Map<KeyExtent,TServerInstance> metadataTable = new TreeMap<KeyExtent,TServerInstance>();
String table = "t1";
metadataTable.put(makeExtent(table, null, null), null);
@@ -125,7 +125,7 @@ public class ChaoticLoadBalancerTest {
servers.clear();
for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
String cString = Character.toString(c);
- InetSocketAddress fakeAddress = AddressUtil.parseAddress("127.0.0.1", c);
+ HostAndPort fakeAddress = HostAndPort.fromParts("127.0.0.1", c);
String fakeInstance = cString;
TServerInstance tsi = new TServerInstance(fakeAddress, fakeInstance);
FakeTServer fakeTServer = new FakeTServer();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java b/server/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
index 2dddbc4..4543a00 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java
@@ -16,32 +16,34 @@
*/
package org.apache.accumulo.server.master.balancer;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.Map.Entry;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.master.thrift.TableInfo;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
-import org.apache.accumulo.core.util.AddressUtil;
-import org.apache.accumulo.server.master.balancer.DefaultLoadBalancer;
import org.apache.accumulo.server.master.state.TServerInstance;
import org.apache.accumulo.server.master.state.TabletMigration;
import org.apache.hadoop.io.Text;
import org.apache.thrift.TException;
import org.junit.Test;
+import com.google.common.net.HostAndPort;
+
public class DefaultLoadBalancerTest {
class FakeTServer {
@@ -83,9 +85,9 @@ public class DefaultLoadBalancerTest {
@Test
public void testAssignMigrations() {
servers.clear();
- servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1234), "a"), new FakeTServer());
- servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1235), "b"), new FakeTServer());
- servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1236), "c"), new FakeTServer());
+ servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1234), "a"), new FakeTServer());
+ servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1235), "b"), new FakeTServer());
+ servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1236), "c"), new FakeTServer());
List<KeyExtent> metadataTable = new ArrayList<KeyExtent>();
String table = "t1";
metadataTable.add(makeExtent(table, null, null));
@@ -160,7 +162,7 @@ public class DefaultLoadBalancerTest {
servers.clear();
for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
String cString = Character.toString(c);
- InetSocketAddress fakeAddress = AddressUtil.parseAddress("127.0.0.1", (int) c);
+ HostAndPort fakeAddress = HostAndPort.fromParts("127.0.0.1", (int) c);
String fakeInstance = cString;
TServerInstance tsi = new TServerInstance(fakeAddress, fakeInstance);
FakeTServer fakeTServer = new FakeTServer();
@@ -202,7 +204,7 @@ public class DefaultLoadBalancerTest {
// make 26 servers
for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
String cString = Character.toString(c);
- InetSocketAddress fakeAddress = AddressUtil.parseAddress("127.0.0.1", (int) c);
+ HostAndPort fakeAddress = HostAndPort.fromParts("127.0.0.1", (int) c);
String fakeInstance = cString;
TServerInstance tsi = new TServerInstance(fakeAddress, fakeInstance);
FakeTServer fakeTServer = new FakeTServer();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java b/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 71ba50d..82e5885 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@ -34,7 +34,6 @@ import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.master.thrift.TableInfo;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.server.master.state.TServerInstance;
import org.apache.accumulo.server.master.state.TabletMigration;
import org.apache.hadoop.io.Text;
@@ -42,10 +41,12 @@ import org.apache.thrift.TException;
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.net.HostAndPort;
+
public class TableLoadBalancerTest {
static private TServerInstance mkts(String address, String session) throws Exception {
- return new TServerInstance(AddressUtil.parseAddress(address, 1234), session);
+ return new TServerInstance(HostAndPort.fromParts(address, 1234), session);
}
static private TabletServerStatus status(Object... config) {
@@ -132,7 +133,7 @@ public class TableLoadBalancerTest {
c.tableOperations().create("t2");
c.tableOperations().create("t3");
state = new TreeMap<TServerInstance,TabletServerStatus>();
- TServerInstance svr = mkts("10.0.0.1:1234", "0x01020304");
+ TServerInstance svr = mkts("10.0.0.1", "0x01020304");
state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
Set<KeyExtent> migrations = Collections.emptySet();
@@ -141,7 +142,7 @@ public class TableLoadBalancerTest {
tls.balance(state, migrations, migrationsOut);
Assert.assertEquals(0, migrationsOut.size());
- state.put(mkts("10.0.0.2:1234", "0x02030405"), status());
+ state.put(mkts("10.0.0.2", "0x02030405"), status());
tls = new TableLoadBalancer();
tls.balance(state, migrations, migrationsOut);
int count = 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/server/src/test/java/org/apache/accumulo/server/master/state/RootTabletStateStoreTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/state/RootTabletStateStoreTest.java b/server/src/test/java/org/apache/accumulo/server/master/state/RootTabletStateStoreTest.java
index a5613ea..4ae0140 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/state/RootTabletStateStoreTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/state/RootTabletStateStoreTest.java
@@ -29,12 +29,13 @@ import java.util.List;
import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException;
import org.apache.hadoop.io.Text;
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.net.HostAndPort;
+
public class RootTabletStateStoreTest {
static class Node {
@@ -148,7 +149,7 @@ public class RootTabletStateStoreTest {
ZooTabletStateStore tstore = new ZooTabletStateStore(new FakeZooStore());
KeyExtent root = RootTable.EXTENT;
String sessionId = "this is my unique session data";
- TServerInstance server = new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 10000), sessionId);
+ TServerInstance server = new TServerInstance(HostAndPort.fromParts("127.0.0.1", 10000), sessionId);
List<Assignment> assignments = Collections.singletonList(new Assignment(root, server));
tstore.setFutureLocations(assignments);
int count = 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
index ab40304..09ed966 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.test.functional;
-import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Random;
@@ -28,7 +27,6 @@ import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Iface;
import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Processor;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.ServerServices;
import org.apache.accumulo.core.util.ServerServices.Service;
import org.apache.accumulo.core.util.UtilWaitThread;
@@ -47,6 +45,8 @@ import org.apache.accumulo.trace.thrift.TInfo;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
+import com.google.common.net.HostAndPort;
+
/**
* Tablet server that creates a lock in zookeeper, responds to one status request, and then hangs on subsequent requests. Exits with code zero if halted.
*/
@@ -98,9 +98,10 @@ public class ZombieTServer {
TransactionWatcher watcher = new TransactionWatcher();
final ThriftClientHandler tch = new ThriftClientHandler(instance, watcher);
Processor<Iface> processor = new Processor<Iface>(tch);
- ServerAddress serverPort = TServerUtils.startTServer(new InetSocketAddress(port), processor, "ZombieTServer", "walking dead", 2, 1000, 10*1024*1024);
+ ServerAddress serverPort = TServerUtils.startTServer(HostAndPort.fromParts("0.0.0.0", port), processor, "ZombieTServer", "walking dead", 2, 1000,
+ 10 * 1024 * 1024);
- String addressString = AddressUtil.toString(serverPort.address);
+ String addressString = serverPort.address.toString();
String zPath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + addressString;
ZooReaderWriter zoo = ZooReaderWriter.getInstance();
zoo.putPersistentData(zPath, new byte[] {}, NodeExistsPolicy.SKIP);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
index 3545170..c6ad74f 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
@@ -39,12 +39,13 @@ import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.Stat;
import org.apache.accumulo.server.master.state.TServerInstance;
import org.apache.accumulo.server.security.SystemCredentials;
import org.apache.hadoop.io.Text;
+import com.google.common.net.HostAndPort;
+
/**
* This little program can be used to write a lot of entries to the !METADATA table and measure the performance of varying numbers of threads doing !METADATA
* lookups using the batch scanner.
@@ -87,7 +88,7 @@ public class MetadataBatchScanTest {
for (KeyExtent extent : extents) {
Mutation mut = extent.getPrevRowUpdateMutation();
- new TServerInstance(AddressUtil.parseAddress("192.168.1.100", 4567), "DEADBEEF").putLocation(mut);
+ new TServerInstance(HostAndPort.fromParts("192.168.1.100", 4567), "DEADBEEF").putLocation(mut);
bw.addMutation(mut);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
index 6c558bb..d40cf73 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
@@ -61,7 +61,6 @@ import org.apache.accumulo.core.iterators.system.VisibilityFilter;
import org.apache.accumulo.core.metadata.MetadataServicer;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.Credentials;
-import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.Stat;
import org.apache.accumulo.server.cli.ClientOnRequiredTable;
import org.apache.accumulo.server.conf.ServerConfiguration;
@@ -78,6 +77,7 @@ import org.apache.hadoop.io.Text;
import org.apache.log4j.Logger;
import com.beust.jcommander.Parameter;
+import com.google.common.net.HostAndPort;
public class CollectTabletStats {
private static final Logger log = Logger.getLogger(CollectTabletStats.class);
@@ -356,7 +356,7 @@ public class CollectTabletStats {
for (Entry<KeyExtent,String> entry : tabletLocations.entrySet()) {
String loc = entry.getValue();
if (loc != null) {
- boolean isLocal = AddressUtil.parseAddress(entry.getValue(), 4).getAddress().equals(localaddress);
+ boolean isLocal = HostAndPort.fromString(entry.getValue()).getHostText().equals(localaddress.getHostName());
if (selectLocalTablets && isLocal) {
candidates.add(entry.getKey());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3de0c1ec/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java b/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
index cd1b1a3..9bb7604 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.test.performance.thrift;
import java.net.InetAddress;
-import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
@@ -74,6 +73,7 @@ import org.apache.hadoop.io.Text;
import org.apache.thrift.TException;
import com.beust.jcommander.Parameter;
+import com.google.common.net.HostAndPort;
/**
* The purpose of this class is to server as fake tserver that is a data sink like /dev/null. NullTserver modifies the !METADATA location entries for a table to
@@ -242,9 +242,9 @@ public class NullTserver {
TransactionWatcher watcher = new TransactionWatcher();
ThriftClientHandler tch = new ThriftClientHandler(HdfsZooInstance.getInstance(), watcher);
Processor<Iface> processor = new Processor<Iface>(tch);
- TServerUtils.startTServer(new InetSocketAddress(opts.port), processor, "NullTServer", "null tserver", 2, 1000, 10 * 1024 * 1024);
+ TServerUtils.startTServer(HostAndPort.fromParts("0.0.0.0", opts.port), processor, "NullTServer", "null tserver", 2, 1000, 10 * 1024 * 1024);
- InetSocketAddress addr = new InetSocketAddress(InetAddress.getLocalHost(), opts.port);
+ HostAndPort addr = HostAndPort.fromParts(InetAddress.getLocalHost().getHostName(), opts.port);
// modify !METADATA
ZooKeeperInstance zki = new ZooKeeperInstance(opts.iname, opts.keepers);