HBASE-10012 Hide ServerName constructor

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1543921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2013-11-20 20:02:25 +00:00
parent d9b983bb5e
commit bc7c3c7daa
62 changed files with 188 additions and 194 deletions

View File

@ -1041,7 +1041,7 @@ public class HRegionInfo implements Comparable<HRegionInfo> {
cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,
HConstants.STARTCODE_QUALIFIER); HConstants.STARTCODE_QUALIFIER);
if (cell == null || cell.getValueLength() == 0) return null; if (cell == null || cell.getValueLength() == 0) return null;
return new ServerName(hostAndPort, return ServerName.valueOf(hostAndPort,
Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
} }

View File

@ -96,7 +96,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
private byte [] bytes; private byte [] bytes;
public static final List<ServerName> EMPTY_SERVER_LIST = new ArrayList<ServerName>(0); public static final List<ServerName> EMPTY_SERVER_LIST = new ArrayList<ServerName>(0);
public ServerName(final String hostname, final int port, final long startcode) { private ServerName(final String hostname, final int port, final long startcode) {
// Drop the domain is there is one; no need of it in a local cluster. With it, we get long // Drop the domain is there is one; no need of it in a local cluster. With it, we get long
// unwieldy names. // unwieldy names.
this.hostnameOnly = hostname; this.hostnameOnly = hostname;
@ -116,12 +116,12 @@ public class ServerName implements Comparable<ServerName>, Serializable {
return parts[0]; return parts[0];
} }
public ServerName(final String serverName) { private ServerName(final String serverName) {
this(parseHostname(serverName), parsePort(serverName), this(parseHostname(serverName), parsePort(serverName),
parseStartcode(serverName)); parseStartcode(serverName));
} }
public ServerName(final String hostAndPort, final long startCode) { private ServerName(final String hostAndPort, final long startCode) {
this(Addressing.parseHostname(hostAndPort), this(Addressing.parseHostname(hostAndPort),
Addressing.parsePort(hostAndPort), startCode); Addressing.parsePort(hostAndPort), startCode);
} }
@ -147,6 +147,18 @@ public class ServerName implements Comparable<ServerName>, Serializable {
return Long.parseLong(serverName.substring(index + 1)); return Long.parseLong(serverName.substring(index + 1));
} }
public static ServerName valueOf(final String hostname, final int port, final long startcode) {
return new ServerName(hostname, port, startcode);
}
public static ServerName valueOf(final String serverName) {
return new ServerName(serverName);
}
public static ServerName valueOf(final String hostAndPort, final long startCode) {
return new ServerName(hostAndPort, startCode);
}
@Override @Override
public String toString() { public String toString() {
return getServerName(); return getServerName();
@ -301,11 +313,11 @@ public class ServerName implements Comparable<ServerName>, Serializable {
short version = Bytes.toShort(versionedBytes); short version = Bytes.toShort(versionedBytes);
if (version == VERSION) { if (version == VERSION) {
int length = versionedBytes.length - Bytes.SIZEOF_SHORT; int length = versionedBytes.length - Bytes.SIZEOF_SHORT;
return new ServerName(Bytes.toString(versionedBytes, Bytes.SIZEOF_SHORT, length)); return valueOf(Bytes.toString(versionedBytes, Bytes.SIZEOF_SHORT, length));
} }
// Presume the bytes were written with an old version of hbase and that the // Presume the bytes were written with an old version of hbase and that the
// bytes are actually a String of the form "'<hostname>' ':' '<port>'". // bytes are actually a String of the form "'<hostname>' ':' '<port>'".
return new ServerName(Bytes.toString(versionedBytes), NON_STARTCODE); return valueOf(Bytes.toString(versionedBytes), NON_STARTCODE);
} }
/** /**
@ -314,8 +326,8 @@ public class ServerName implements Comparable<ServerName>, Serializable {
* @return A ServerName instance. * @return A ServerName instance.
*/ */
public static ServerName parseServerName(final String str) { public static ServerName parseServerName(final String str) {
return SERVERNAME_PATTERN.matcher(str).matches()? new ServerName(str): return SERVERNAME_PATTERN.matcher(str).matches()? valueOf(str) :
new ServerName(str, NON_STARTCODE); valueOf(str, NON_STARTCODE);
} }
@ -346,7 +358,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
MetaRegionServer rss = MetaRegionServer rss =
MetaRegionServer.PARSER.parseFrom(data, prefixLen, data.length - prefixLen); MetaRegionServer.PARSER.parseFrom(data, prefixLen, data.length - prefixLen);
org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName sn = rss.getServer(); org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName sn = rss.getServer();
return new ServerName(sn.getHostName(), sn.getPort(), sn.getStartCode()); return valueOf(sn.getHostName(), sn.getPort(), sn.getStartCode());
} catch (InvalidProtocolBufferException e) { } catch (InvalidProtocolBufferException e) {
// A failed parse of the znode is pretty catastrophic. Rather than loop // A failed parse of the znode is pretty catastrophic. Rather than loop
// retrying hoping the bad bytes will changes, and rather than change // retrying hoping the bad bytes will changes, and rather than change
@ -368,6 +380,6 @@ public class ServerName implements Comparable<ServerName>, Serializable {
// Presume it a hostname:port format. // Presume it a hostname:port format.
String hostname = Addressing.parseHostname(str); String hostname = Addressing.parseHostname(str);
int port = Addressing.parsePort(str); int port = Addressing.parsePort(str);
return new ServerName(hostname, port, -1L); return valueOf(hostname, port, -1L);
} }
} }

View File

@ -1324,7 +1324,7 @@ public class HBaseAdmin implements Abortable, Closeable {
if (pair == null || pair.getFirst() == null) { if (pair == null || pair.getFirst() == null) {
throw new UnknownRegionException(Bytes.toStringBinary(regionname)); throw new UnknownRegionException(Bytes.toStringBinary(regionname));
} else { } else {
closeRegion(new ServerName(serverName), pair.getFirst()); closeRegion(ServerName.valueOf(serverName), pair.getFirst());
} }
} else { } else {
Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, regionname); Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, regionname);
@ -1368,7 +1368,7 @@ public class HBaseAdmin implements Abortable, Closeable {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The servername cannot be null or empty."); "The servername cannot be null or empty.");
} }
ServerName sn = new ServerName(serverName); ServerName sn = ServerName.valueOf(serverName);
AdminService.BlockingInterface admin = this.connection.getAdmin(sn); AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
// Close the region without updating zk state. // Close the region without updating zk state.
CloseRegionRequest request = CloseRegionRequest request =
@ -2126,7 +2126,7 @@ public class HBaseAdmin implements Abortable, Closeable {
String hostname = Addressing.parseHostname(hostnamePort); String hostname = Addressing.parseHostname(hostnamePort);
int port = Addressing.parsePort(hostnamePort); int port = Addressing.parsePort(hostnamePort);
AdminService.BlockingInterface admin = AdminService.BlockingInterface admin =
this.connection.getAdmin(new ServerName(hostname, port, 0)); this.connection.getAdmin(ServerName.valueOf(hostname, port, 0));
StopServerRequest request = RequestConverter.buildStopServerRequest( StopServerRequest request = RequestConverter.buildStopServerRequest(
"Called by admin client " + this.connection.toString()); "Called by admin client " + this.connection.toString());
try { try {
@ -2426,7 +2426,7 @@ public class HBaseAdmin implements Abortable, Closeable {
*/ */
public synchronized byte[][] rollHLogWriter(String serverName) public synchronized byte[][] rollHLogWriter(String serverName)
throws IOException, FailedLogCloseException { throws IOException, FailedLogCloseException {
ServerName sn = new ServerName(serverName); ServerName sn = ServerName.valueOf(serverName);
AdminService.BlockingInterface admin = this.connection.getAdmin(sn); AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest(); RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest();
try { try {

View File

@ -24,7 +24,6 @@ import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.ipc.RemoteException;
/** /**
* Subclass if the server knows the region is now on another server. * Subclass if the server knows the region is now on another server.
@ -63,7 +62,7 @@ public class RegionMovedException extends NotServingRegionException {
} }
public ServerName getServerName(){ public ServerName getServerName(){
return new ServerName(hostname, port, startCode); return ServerName.valueOf(hostname, port, startCode);
} }
public long getLocationSeqNum() { public long getLocationSeqNum() {

View File

@ -321,7 +321,7 @@ public final class ProtobufUtil {
if (proto.hasStartCode()) { if (proto.hasStartCode()) {
startCode = proto.getStartCode(); startCode = proto.getStartCode();
} }
return new ServerName(hostName, port, startCode); return ServerName.valueOf(hostName, port, startCode);
} }
/** /**

View File

@ -29,7 +29,6 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Action; import org.apache.hadoop.hbase.client.Action;
import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Delete;
@ -996,7 +995,7 @@ public final class RequestConverter {
buildRegionSpecifier(RegionSpecifierType.ENCODED_REGION_NAME,encodedRegionName)); buildRegionSpecifier(RegionSpecifierType.ENCODED_REGION_NAME,encodedRegionName));
if (destServerName != null) { if (destServerName != null) {
builder.setDestServerName( builder.setDestServerName(
ProtobufUtil.toServerName(new ServerName(Bytes.toString(destServerName)))); ProtobufUtil.toServerName(ServerName.valueOf(Bytes.toString(destServerName))));
} }
return builder.build(); return builder.build();
} }

View File

@ -58,8 +58,8 @@ public class TestAsyncProcess {
private static final byte[] FAILS = "FAILS".getBytes(); private static final byte[] FAILS = "FAILS".getBytes();
private static final Configuration conf = new Configuration(); private static final Configuration conf = new Configuration();
private static ServerName sn = new ServerName("localhost:10,1254"); private static ServerName sn = ServerName.valueOf("localhost:10,1254");
private static ServerName sn2 = new ServerName("localhost:140,12540"); private static ServerName sn2 = ServerName.valueOf("localhost:140,12540");
private static HRegionInfo hri1 = private static HRegionInfo hri1 =
new HRegionInfo(DUMMY_TABLE, DUMMY_BYTES_1, DUMMY_BYTES_2, false, 1); new HRegionInfo(DUMMY_TABLE, DUMMY_BYTES_1, DUMMY_BYTES_2, false, 1);
private static HRegionInfo hri2 = private static HRegionInfo hri2 =

View File

@ -95,7 +95,7 @@ public class TestClientNoCluster extends Configured implements Tool {
private static final Log LOG = LogFactory.getLog(TestClientNoCluster.class); private static final Log LOG = LogFactory.getLog(TestClientNoCluster.class);
private Configuration conf; private Configuration conf;
public static final ServerName META_SERVERNAME = public static final ServerName META_SERVERNAME =
new ServerName("meta.example.org", 60010, 12345); ServerName.valueOf("meta.example.org", 60010, 12345);
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
@ -651,7 +651,7 @@ public class TestClientNoCluster extends Configured implements Tool {
private static ServerName [] makeServerNames(final int count) { private static ServerName [] makeServerNames(final int count) {
ServerName [] sns = new ServerName[count]; ServerName [] sns = new ServerName[count];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
sns[i] = new ServerName("" + i + ".example.org", 60010, i); sns[i] = ServerName.valueOf("" + i + ".example.org", 60010, i);
} }
return sns; return sns;
} }

View File

@ -99,7 +99,7 @@ public class RollingBatchRestartRsAction extends BatchRestartRsAction {
final int count = 4; final int count = 4;
List<ServerName> serverNames = new ArrayList<ServerName>(count); List<ServerName> serverNames = new ArrayList<ServerName>(count);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
serverNames.add(new ServerName(i + ".example.org", i, i)); serverNames.add(ServerName.valueOf(i + ".example.org", i, i));
} }
return serverNames.toArray(new ServerName [] {}); return serverNames.toArray(new ServerName [] {});
} }

View File

@ -106,7 +106,7 @@ import com.google.common.collect.LinkedHashMultimap;
public class AssignmentManager extends ZooKeeperListener { public class AssignmentManager extends ZooKeeperListener {
private static final Log LOG = LogFactory.getLog(AssignmentManager.class); private static final Log LOG = LogFactory.getLog(AssignmentManager.class);
public static final ServerName HBCK_CODE_SERVERNAME = new ServerName(HConstants.HBCK_CODE_NAME, public static final ServerName HBCK_CODE_SERVERNAME = ServerName.valueOf(HConstants.HBCK_CODE_NAME,
-1, -1L); -1, -1L);
public static final String ASSIGNMENT_TIMEOUT = "hbase.master.assignment.timeoutmonitor.timeout"; public static final String ASSIGNMENT_TIMEOUT = "hbase.master.assignment.timeoutmonitor.timeout";

View File

@ -440,7 +440,7 @@ MasterServices, Server {
// Set our address. // Set our address.
this.isa = this.rpcServer.getListenerAddress(); this.isa = this.rpcServer.getListenerAddress();
// We don't want to pass isa's hostname here since it could be 0.0.0.0 // We don't want to pass isa's hostname here since it could be 0.0.0.0
this.serverName = new ServerName(hostname, this.isa.getPort(), System.currentTimeMillis()); this.serverName = ServerName.valueOf(hostname, this.isa.getPort(), System.currentTimeMillis());
this.rsFatals = new MemoryBoundedLogMessageBuffer( this.rsFatals = new MemoryBoundedLogMessageBuffer(
conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024)); conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024));
@ -1699,7 +1699,7 @@ MasterServices, Server {
regionState.getServerName()); regionState.getServerName());
dest = balancer.randomAssignment(hri, destServers); dest = balancer.randomAssignment(hri, destServers);
} else { } else {
dest = new ServerName(Bytes.toString(destServerName)); dest = ServerName.valueOf(Bytes.toString(destServerName));
if (dest.equals(regionState.getServerName())) { if (dest.equals(regionState.getServerName())) {
LOG.debug("Skipping move of region " + hri.getRegionNameAsString() LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
+ " because region already assigned to the same server " + dest + "."); + " because region already assigned to the same server " + dest + ".");

View File

@ -54,7 +54,6 @@ import org.apache.hadoop.hbase.master.balancer.FavoredNodeAssignmentHelper;
import org.apache.hadoop.hbase.master.balancer.FavoredNodesPlan; import org.apache.hadoop.hbase.master.balancer.FavoredNodesPlan;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.RequestConverter; import org.apache.hadoop.hbase.protobuf.RequestConverter;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.OpenRegionRequest;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface; import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest; import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse; import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse;
@ -401,15 +400,15 @@ public class RegionPlacementMaintainer {
List<ServerName> favoredServers = List<ServerName> favoredServers =
new ArrayList<ServerName>(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM); new ArrayList<ServerName>(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM);
ServerName s = servers.get(primaryAssignment[i] / slotsPerServer); ServerName s = servers.get(primaryAssignment[i] / slotsPerServer);
favoredServers.add(new ServerName(s.getHostname(), s.getPort(), favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
s = servers.get(secondaryAssignment[i] / slotsPerServer); s = servers.get(secondaryAssignment[i] / slotsPerServer);
favoredServers.add(new ServerName(s.getHostname(), s.getPort(), favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
s = servers.get(tertiaryAssignment[i] / slotsPerServer); s = servers.get(tertiaryAssignment[i] / slotsPerServer);
favoredServers.add(new ServerName(s.getHostname(), s.getPort(), favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
// Update the assignment plan // Update the assignment plan
plan.updateAssignmentPlan(regions.get(i), favoredServers); plan.updateAssignmentPlan(regions.get(i), favoredServers);
@ -434,17 +433,17 @@ public class RegionPlacementMaintainer {
new ArrayList<ServerName>(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM); new ArrayList<ServerName>(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM);
HRegionInfo currentRegion = regions.get(i); HRegionInfo currentRegion = regions.get(i);
ServerName s = primaryRSMap.get(currentRegion); ServerName s = primaryRSMap.get(currentRegion);
favoredServers.add(new ServerName(s.getHostname(), s.getPort(), favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
ServerName[] secondaryAndTertiary = ServerName[] secondaryAndTertiary =
secondaryAndTertiaryMap.get(currentRegion); secondaryAndTertiaryMap.get(currentRegion);
s = secondaryAndTertiary[0]; s = secondaryAndTertiary[0];
favoredServers.add(new ServerName(s.getHostname(), s.getPort(), favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
s = secondaryAndTertiary[1]; s = secondaryAndTertiary[1];
favoredServers.add(new ServerName(s.getHostname(), s.getPort(), favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
// Update the assignment plan // Update the assignment plan
plan.updateAssignmentPlan(regions.get(i), favoredServers); plan.updateAssignmentPlan(regions.get(i), favoredServers);
@ -943,7 +942,7 @@ public class RegionPlacementMaintainer {
List<ServerName> serverList = new ArrayList<ServerName>(); List<ServerName> serverList = new ArrayList<ServerName>();
for (String hostNameAndPort : favoredNodesArray) { for (String hostNameAndPort : favoredNodesArray) {
serverList.add(new ServerName(hostNameAndPort, ServerName.NON_STARTCODE)); serverList.add(ServerName.valueOf(hostNameAndPort, ServerName.NON_STARTCODE));
} }
return serverList; return serverList;
} }

View File

@ -211,7 +211,7 @@ public class ServerManager {
// is, reject the server and trigger its expiration. The next time it comes // is, reject the server and trigger its expiration. The next time it comes
// in, it should have been removed from serverAddressToServerInfo and queued // in, it should have been removed from serverAddressToServerInfo and queued
// for processing by ProcessServerShutdown. // for processing by ProcessServerShutdown.
ServerName sn = new ServerName(ia.getHostName(), port, serverStartcode); ServerName sn = ServerName.valueOf(ia.getHostName(), port, serverStartcode);
checkClockSkew(sn, serverCurrentTime); checkClockSkew(sn, serverCurrentTime);
checkIsDead(sn, "STARTUP"); checkIsDead(sn, "STARTUP");
if (!checkAlreadySameHostPortAndRecordNewServer( if (!checkAlreadySameHostPortAndRecordNewServer(

View File

@ -88,14 +88,14 @@ public class FavoredNodeLoadBalancer extends BaseLoadBalancer {
new HashMap<ServerName, ServerName>(); new HashMap<ServerName, ServerName>();
ServerManager serverMgr = super.services.getServerManager(); ServerManager serverMgr = super.services.getServerManager();
for (ServerName sn: serverMgr.getOnlineServersList()) { for (ServerName sn: serverMgr.getOnlineServersList()) {
ServerName s = new ServerName(sn.getHostname(), sn.getPort(), ServerName.NON_STARTCODE); ServerName s = ServerName.valueOf(sn.getHostname(), sn.getPort(), ServerName.NON_STARTCODE);
serverNameToServerNameWithoutCode.put(sn, s); serverNameToServerNameWithoutCode.put(sn, s);
serverNameWithoutCodeToServerName.put(s, sn); serverNameWithoutCodeToServerName.put(s, sn);
} }
for (Map.Entry<ServerName, List<HRegionInfo>> entry : clusterState.entrySet()) { for (Map.Entry<ServerName, List<HRegionInfo>> entry : clusterState.entrySet()) {
ServerName currentServer = entry.getKey(); ServerName currentServer = entry.getKey();
//get a server without the startcode for the currentServer //get a server without the startcode for the currentServer
ServerName currentServerWithoutStartCode = new ServerName(currentServer.getHostname(), ServerName currentServerWithoutStartCode = ServerName.valueOf(currentServer.getHostname(),
currentServer.getPort(), ServerName.NON_STARTCODE); currentServer.getPort(), ServerName.NON_STARTCODE);
List<HRegionInfo> list = entry.getValue(); List<HRegionInfo> list = entry.getValue();
for (HRegionInfo region : list) { for (HRegionInfo region : list) {
@ -332,13 +332,13 @@ public class FavoredNodeLoadBalancer extends BaseLoadBalancer {
// We don't care about the startcode; but only the hostname really // We don't care about the startcode; but only the hostname really
List<ServerName> favoredNodesForRegion = new ArrayList<ServerName>(3); List<ServerName> favoredNodesForRegion = new ArrayList<ServerName>(3);
ServerName sn = primaryRSMap.get(region); ServerName sn = primaryRSMap.get(region);
favoredNodesForRegion.add(new ServerName(sn.getHostname(), sn.getPort(), favoredNodesForRegion.add(ServerName.valueOf(sn.getHostname(), sn.getPort(),
ServerName.NON_STARTCODE)); ServerName.NON_STARTCODE));
ServerName[] secondaryAndTertiaryNodes = secondaryAndTertiaryRSMap.get(region); ServerName[] secondaryAndTertiaryNodes = secondaryAndTertiaryRSMap.get(region);
if (secondaryAndTertiaryNodes != null) { if (secondaryAndTertiaryNodes != null) {
favoredNodesForRegion.add(new ServerName(secondaryAndTertiaryNodes[0].getHostname(), favoredNodesForRegion.add(ServerName.valueOf(secondaryAndTertiaryNodes[0].getHostname(),
secondaryAndTertiaryNodes[0].getPort(), ServerName.NON_STARTCODE)); secondaryAndTertiaryNodes[0].getPort(), ServerName.NON_STARTCODE));
favoredNodesForRegion.add(new ServerName(secondaryAndTertiaryNodes[1].getHostname(), favoredNodesForRegion.add(ServerName.valueOf(secondaryAndTertiaryNodes[1].getHostname(),
secondaryAndTertiaryNodes[1].getPort(), ServerName.NON_STARTCODE)); secondaryAndTertiaryNodes[1].getPort(), ServerName.NON_STARTCODE));
} }
globalFavoredNodesAssignmentPlan.updateFavoredNodesMap(region, favoredNodesForRegion); globalFavoredNodesAssignmentPlan.updateFavoredNodesMap(region, favoredNodesForRegion);

View File

@ -378,7 +378,7 @@ public class NamespaceUpgrade implements Tool {
} }
ServerName fakeServer = new ServerName("nsupgrade",96,123); ServerName fakeServer = ServerName.valueOf("nsupgrade", 96, 123);
String metaLogName = HLogUtil.getHLogDirectoryName(fakeServer.toString()); String metaLogName = HLogUtil.getHLogDirectoryName(fakeServer.toString());
HLog metaHLog = HLogFactory.createMetaHLog(fs, rootDir, HLog metaHLog = HLogFactory.createMetaHLog(fs, rootDir,
metaLogName, conf, null, metaLogName, conf, null,

View File

@ -763,7 +763,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
this.abort("Failed to reach zk cluster when creating snapshot handler."); this.abort("Failed to reach zk cluster when creating snapshot handler.");
} }
this.tableLockManager = TableLockManager.createTableLockManager(conf, zooKeeper, this.tableLockManager = TableLockManager.createTableLockManager(conf, zooKeeper,
new ServerName(isa.getHostName(), isa.getPort(), startcode)); ServerName.valueOf(isa.getHostName(), isa.getPort(), startcode));
// register watcher for recovering regions // register watcher for recovering regions
if(this.distributedLogReplay) { if(this.distributedLogReplay) {
@ -1209,8 +1209,8 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
// The hostname the master sees us as. // The hostname the master sees us as.
if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) { if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
String hostnameFromMasterPOV = e.getValue(); String hostnameFromMasterPOV = e.getValue();
this.serverNameFromMasterPOV = new ServerName(hostnameFromMasterPOV, this.serverNameFromMasterPOV = ServerName.valueOf(hostnameFromMasterPOV,
this.isa.getPort(), this.startcode); this.isa.getPort(), this.startcode);
if (!hostnameFromMasterPOV.equals(this.isa.getHostName())) { if (!hostnameFromMasterPOV.equals(this.isa.getHostName())) {
LOG.info("Master passed us a different hostname to use; was=" + LOG.info("Master passed us a different hostname to use; was=" +
this.isa.getHostName() + ", but now=" + hostnameFromMasterPOV); this.isa.getHostName() + ", but now=" + hostnameFromMasterPOV);
@ -2236,7 +2236,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
public ServerName getServerName() { public ServerName getServerName() {
// Our servername could change after we talk to the master. // Our servername could change after we talk to the master.
return this.serverNameFromMasterPOV == null? return this.serverNameFromMasterPOV == null?
new ServerName(this.isa.getHostName(), this.isa.getPort(), this.startcode): ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), this.startcode) :
this.serverNameFromMasterPOV; this.serverNameFromMasterPOV;
} }

View File

@ -77,7 +77,7 @@ public class DrainingServerTracker extends ZooKeeperListener {
synchronized(this.drainingServers) { synchronized(this.drainingServers) {
this.drainingServers.clear(); this.drainingServers.clear();
for (String n: servers) { for (String n: servers) {
final ServerName sn = new ServerName(ZKUtil.getNodeName(n)); final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(n));
this.drainingServers.add(sn); this.drainingServers.add(sn);
this.serverManager.addServerToDrainList(sn); this.serverManager.addServerToDrainList(sn);
LOG.info("Draining RS node created, adding to list [" + LOG.info("Draining RS node created, adding to list [" +
@ -97,7 +97,7 @@ public class DrainingServerTracker extends ZooKeeperListener {
@Override @Override
public void nodeDeleted(final String path) { public void nodeDeleted(final String path) {
if(path.startsWith(watcher.drainingZNode)) { if(path.startsWith(watcher.drainingZNode)) {
final ServerName sn = new ServerName(ZKUtil.getNodeName(path)); final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path));
LOG.info("Draining RS node deleted, removing from list [" + LOG.info("Draining RS node deleted, removing from list [" +
sn + "]"); sn + "]");
remove(sn); remove(sn);

View File

@ -89,8 +89,8 @@ public class TestDrainingServer {
final HMaster master = Mockito.mock(HMaster.class); final HMaster master = Mockito.mock(HMaster.class);
final Server server = Mockito.mock(Server.class); final Server server = Mockito.mock(Server.class);
final ServerManager serverManager = Mockito.mock(ServerManager.class); final ServerManager serverManager = Mockito.mock(ServerManager.class);
final ServerName SERVERNAME_A = new ServerName("mockserver_a.org", 1000, 8000); final ServerName SERVERNAME_A = ServerName.valueOf("mockserver_a.org", 1000, 8000);
final ServerName SERVERNAME_B = new ServerName("mockserver_b.org", 1001, 8000); final ServerName SERVERNAME_B = ServerName.valueOf("mockserver_b.org", 1001, 8000);
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(conf); LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(conf);
CatalogTracker catalogTracker = Mockito.mock(CatalogTracker.class); CatalogTracker catalogTracker = Mockito.mock(CatalogTracker.class);
final HRegionInfo REGIONINFO = new HRegionInfo(TableName.valueOf("table_test"), final HRegionInfo REGIONINFO = new HRegionInfo(TableName.valueOf("table_test"),
@ -105,7 +105,7 @@ public class TestDrainingServer {
onlineServers.put(SERVERNAME_B, ServerLoad.EMPTY_SERVERLOAD); onlineServers.put(SERVERNAME_B, ServerLoad.EMPTY_SERVERLOAD);
Mockito.when(server.getConfiguration()).thenReturn(conf); Mockito.when(server.getConfiguration()).thenReturn(conf);
Mockito.when(server.getServerName()).thenReturn(new ServerName("masterMock,1,1")); Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("masterMock,1,1"));
Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher); Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher);
Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers); Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers);
@ -163,11 +163,11 @@ public class TestDrainingServer {
final HMaster master = Mockito.mock(HMaster.class); final HMaster master = Mockito.mock(HMaster.class);
final Server server = Mockito.mock(Server.class); final Server server = Mockito.mock(Server.class);
final ServerManager serverManager = Mockito.mock(ServerManager.class); final ServerManager serverManager = Mockito.mock(ServerManager.class);
final ServerName SERVERNAME_A = new ServerName("mockserverbulk_a.org", 1000, 8000); final ServerName SERVERNAME_A = ServerName.valueOf("mockserverbulk_a.org", 1000, 8000);
final ServerName SERVERNAME_B = new ServerName("mockserverbulk_b.org", 1001, 8000); final ServerName SERVERNAME_B = ServerName.valueOf("mockserverbulk_b.org", 1001, 8000);
final ServerName SERVERNAME_C = new ServerName("mockserverbulk_c.org", 1002, 8000); final ServerName SERVERNAME_C = ServerName.valueOf("mockserverbulk_c.org", 1002, 8000);
final ServerName SERVERNAME_D = new ServerName("mockserverbulk_d.org", 1003, 8000); final ServerName SERVERNAME_D = ServerName.valueOf("mockserverbulk_d.org", 1003, 8000);
final ServerName SERVERNAME_E = new ServerName("mockserverbulk_e.org", 1004, 8000); final ServerName SERVERNAME_E = ServerName.valueOf("mockserverbulk_e.org", 1004, 8000);
final Map<HRegionInfo, ServerName> bulk = new HashMap<HRegionInfo, ServerName>(); final Map<HRegionInfo, ServerName> bulk = new HashMap<HRegionInfo, ServerName>();
Set<ServerName> bunchServersAssigned = new HashSet<ServerName>(); Set<ServerName> bunchServersAssigned = new HashSet<ServerName>();
@ -202,7 +202,7 @@ public class TestDrainingServer {
"zkWatcher-BulkAssignTest", abortable, true); "zkWatcher-BulkAssignTest", abortable, true);
Mockito.when(server.getConfiguration()).thenReturn(conf); Mockito.when(server.getConfiguration()).thenReturn(conf);
Mockito.when(server.getServerName()).thenReturn(new ServerName("masterMock,1,1")); Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("masterMock,1,1"));
Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher); Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher);
Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers); Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers);

View File

@ -35,7 +35,7 @@ public class TestHRegionLocation {
*/ */
@Test @Test
public void testHashAndEqualsCode() { public void testHashAndEqualsCode() {
ServerName hsa1 = new ServerName("localhost", 1234, -1L); ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L);
HRegionLocation hrl1 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1); HRegionLocation hrl1 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1);
HRegionLocation hrl2 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1); HRegionLocation hrl2 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1);
assertEquals(hrl1.hashCode(), hrl2.hashCode()); assertEquals(hrl1.hashCode(), hrl2.hashCode());
@ -45,7 +45,7 @@ public class TestHRegionLocation {
// They are equal because they have same location even though they are // They are equal because they have same location even though they are
// carrying different regions or timestamp. // carrying different regions or timestamp.
assertTrue(hrl1.equals(hrl3)); assertTrue(hrl1.equals(hrl3));
ServerName hsa2 = new ServerName("localhost", 12345, -1L); ServerName hsa2 = ServerName.valueOf("localhost", 12345, -1L);
HRegionLocation hrl4 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2); HRegionLocation hrl4 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2);
// These have same HRI but different locations so should be different. // These have same HRI but different locations so should be different.
assertFalse(hrl3.equals(hrl4)); assertFalse(hrl3.equals(hrl4));
@ -56,17 +56,17 @@ public class TestHRegionLocation {
@Test @Test
public void testToString() { public void testToString() {
ServerName hsa1 = new ServerName("localhost", 1234, -1L); ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L);
HRegionLocation hrl1 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1); HRegionLocation hrl1 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1);
System.out.println(hrl1.toString()); System.out.println(hrl1.toString());
} }
@Test @Test
public void testCompareTo() { public void testCompareTo() {
ServerName hsa1 = new ServerName("localhost", 1234, -1L); ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L);
HRegionLocation hsl1 = HRegionLocation hsl1 =
new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1); new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1);
ServerName hsa2 = new ServerName("localhost", 1235, -1L); ServerName hsa2 = ServerName.valueOf("localhost", 1235, -1L);
HRegionLocation hsl2 = HRegionLocation hsl2 =
new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2); new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2);
assertTrue(hsl1.compareTo(hsl1) == 0); assertTrue(hsl1.compareTo(hsl1) == 0);

View File

@ -77,7 +77,7 @@ public class TestSerialization {
@Test @Test
public void testSplitLogTask() throws DeserializationException { public void testSplitLogTask() throws DeserializationException {
SplitLogTask slt = new SplitLogTask.Unassigned(new ServerName("mgr,1,1")); SplitLogTask slt = new SplitLogTask.Unassigned(ServerName.valueOf("mgr,1,1"));
byte [] bytes = slt.toByteArray(); byte [] bytes = slt.toByteArray();
SplitLogTask sltDeserialized = SplitLogTask.parseFrom(bytes); SplitLogTask sltDeserialized = SplitLogTask.parseFrom(bytes);
assertTrue(slt.equals(sltDeserialized)); assertTrue(slt.equals(sltDeserialized));

View File

@ -41,17 +41,17 @@ public class TestServerName {
assertEquals("x", ServerName.getHostNameMinusDomain("x")); assertEquals("x", ServerName.getHostNameMinusDomain("x"));
assertEquals("x", ServerName.getHostNameMinusDomain("x.y.z")); assertEquals("x", ServerName.getHostNameMinusDomain("x.y.z"));
assertEquals("asf000", ServerName.getHostNameMinusDomain("asf000.sp2.ygridcore.net")); assertEquals("asf000", ServerName.getHostNameMinusDomain("asf000.sp2.ygridcore.net"));
ServerName sn = new ServerName("asf000.sp2.ygridcore.net", 1, 1); ServerName sn = ServerName.valueOf("asf000.sp2.ygridcore.net", 1, 1);
assertEquals("asf000.sp2.ygridcore.net,1,1", sn.toString()); assertEquals("asf000.sp2.ygridcore.net,1,1", sn.toString());
} }
@Test @Test
public void testShortString() { public void testShortString() {
ServerName sn = new ServerName("asf000.sp2.ygridcore.net", 1, 1); ServerName sn = ServerName.valueOf("asf000.sp2.ygridcore.net", 1, 1);
assertEquals("asf000:1", sn.toShortString()); assertEquals("asf000:1", sn.toShortString());
sn = new ServerName("2607:f0d0:1002:0051:0000:0000:0000:0004", 1, 1); sn = ServerName.valueOf("2607:f0d0:1002:0051:0000:0000:0000:0004", 1, 1);
assertEquals("2607:f0d0:1002:0051:0000:0000:0000:0004:1", sn.toShortString()); assertEquals("2607:f0d0:1002:0051:0000:0000:0000:0004:1", sn.toShortString());
sn = new ServerName("1.1.1.1", 1, 1); sn = ServerName.valueOf("1.1.1.1", 1, 1);
assertEquals("1.1.1.1:1", sn.toShortString()); assertEquals("1.1.1.1:1", sn.toShortString());
} }
@ -68,7 +68,7 @@ public class TestServerName {
@Test public void testParseOfBytes() { @Test public void testParseOfBytes() {
final String snStr = "www.example.org,1234,5678"; final String snStr = "www.example.org,1234,5678";
ServerName sn = new ServerName(snStr); ServerName sn = ServerName.valueOf(snStr);
byte [] versionedBytes = sn.getVersionedBytes(); byte [] versionedBytes = sn.getVersionedBytes();
assertEquals(sn.toString(), ServerName.parseVersionedServerName(versionedBytes).toString()); assertEquals(sn.toString(), ServerName.parseVersionedServerName(versionedBytes).toString());
final String hostnamePortStr = sn.getHostAndPort(); final String hostnamePortStr = sn.getHostAndPort();
@ -81,9 +81,9 @@ public class TestServerName {
@Test @Test
public void testServerName() { public void testServerName() {
ServerName sn = new ServerName("www.example.org", 1234, 5678); ServerName sn = ServerName.valueOf("www.example.org", 1234, 5678);
ServerName sn2 = new ServerName("www.example.org", 1234, 5678); ServerName sn2 = ServerName.valueOf("www.example.org", 1234, 5678);
ServerName sn3 = new ServerName("www.example.org", 1234, 56789); ServerName sn3 = ServerName.valueOf("www.example.org", 1234, 56789);
assertTrue(sn.equals(sn2)); assertTrue(sn.equals(sn2));
assertFalse(sn.equals(sn3)); assertFalse(sn.equals(sn3));
assertEquals(sn.hashCode(), sn2.hashCode()); assertEquals(sn.hashCode(), sn2.hashCode());
@ -99,7 +99,7 @@ public class TestServerName {
@Test @Test
public void getServerStartcodeFromServerName() { public void getServerStartcodeFromServerName() {
ServerName sn = new ServerName("www.example.org", 1234, 5678); ServerName sn = ServerName.valueOf("www.example.org", 1234, 5678);
assertEquals(5678, assertEquals(5678,
ServerName.getServerStartcodeFromServerName(sn.toString())); ServerName.getServerStartcodeFromServerName(sn.toString()));
assertNotSame(5677, assertNotSame(5677,

View File

@ -72,7 +72,7 @@ public class TestCatalogTracker {
private static final Log LOG = LogFactory.getLog(TestCatalogTracker.class); private static final Log LOG = LogFactory.getLog(TestCatalogTracker.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final ServerName SN = private static final ServerName SN =
new ServerName("example.org", 1234, System.currentTimeMillis()); ServerName.valueOf("example.org", 1234, System.currentTimeMillis());
private ZooKeeperWatcher watcher; private ZooKeeperWatcher watcher;
private Abortable abortable; private Abortable abortable;
@ -137,7 +137,7 @@ public class TestCatalogTracker {
constructAndStartCatalogTracker(connection); constructAndStartCatalogTracker(connection);
MetaRegionTracker.setMetaLocation(this.watcher, MetaRegionTracker.setMetaLocation(this.watcher,
new ServerName("example.com", 1234, System.currentTimeMillis())); ServerName.valueOf("example.com", 1234, System.currentTimeMillis()));
} }
/** /**
@ -251,7 +251,7 @@ public class TestCatalogTracker {
final CatalogTracker ct = constructAndStartCatalogTracker(connection); final CatalogTracker ct = constructAndStartCatalogTracker(connection);
MetaRegionTracker.setMetaLocation(this.watcher, MetaRegionTracker.setMetaLocation(this.watcher,
new ServerName("example.com", 1234, System.currentTimeMillis())); ServerName.valueOf("example.com", 1234, System.currentTimeMillis()));
Assert.assertFalse(ct.verifyMetaRegionLocation(100)); Assert.assertFalse(ct.verifyMetaRegionLocation(100));
} }

View File

@ -137,7 +137,7 @@ public class TestMetaReaderEditorNoCluster {
ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(), ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(),
this.getClass().getSimpleName(), ABORTABLE, true); this.getClass().getSimpleName(), ABORTABLE, true);
// This is a servername we use in a few places below. // This is a servername we use in a few places below.
ServerName sn = new ServerName("example.com", 1234, System.currentTimeMillis()); ServerName sn = ServerName.valueOf("example.com", 1234, System.currentTimeMillis());
HConnection connection; HConnection connection;
CatalogTracker ct = null; CatalogTracker ct = null;

View File

@ -361,8 +361,8 @@ public class TestHCM {
final int nextPort = conn.getCachedLocation(TABLE_NAME, ROW).getPort() + 1; final int nextPort = conn.getCachedLocation(TABLE_NAME, ROW).getPort() + 1;
HRegionLocation loc = conn.getCachedLocation(TABLE_NAME, ROW); HRegionLocation loc = conn.getCachedLocation(TABLE_NAME, ROW);
conn.updateCachedLocation(loc.getRegionInfo(), loc, new ServerName("127.0.0.1", nextPort, conn.updateCachedLocation(loc.getRegionInfo(), loc, ServerName.valueOf("127.0.0.1", nextPort,
HConstants.LATEST_TIMESTAMP), HConstants.LATEST_TIMESTAMP); HConstants.LATEST_TIMESTAMP), HConstants.LATEST_TIMESTAMP);
Assert.assertEquals(conn.getCachedLocation(TABLE_NAME, ROW).getPort(), nextPort); Assert.assertEquals(conn.getCachedLocation(TABLE_NAME, ROW).getPort(), nextPort);
conn.forceDeleteCachedLocation(TABLE_NAME, ROW.clone()); conn.forceDeleteCachedLocation(TABLE_NAME, ROW.clone());
@ -553,34 +553,34 @@ public class TestHCM {
HRegionLocation location = conn.getCachedLocation(TABLE_NAME2, ROW); HRegionLocation location = conn.getCachedLocation(TABLE_NAME2, ROW);
assertNotNull(location); assertNotNull(location);
HRegionLocation anySource = new HRegionLocation(location.getRegionInfo(), new ServerName( HRegionLocation anySource = new HRegionLocation(location.getRegionInfo(), ServerName.valueOf(
location.getHostname(), location.getPort() - 1, 0L)); location.getHostname(), location.getPort() - 1, 0L));
// Same server as already in cache reporting - overwrites any value despite seqNum. // Same server as already in cache reporting - overwrites any value despite seqNum.
int nextPort = location.getPort() + 1; int nextPort = location.getPort() + 1;
conn.updateCachedLocation(location.getRegionInfo(), location, conn.updateCachedLocation(location.getRegionInfo(), location,
new ServerName("127.0.0.1", nextPort, 0), location.getSeqNum() - 1); ServerName.valueOf("127.0.0.1", nextPort, 0), location.getSeqNum() - 1);
location = conn.getCachedLocation(TABLE_NAME2, ROW); location = conn.getCachedLocation(TABLE_NAME2, ROW);
Assert.assertEquals(nextPort, location.getPort()); Assert.assertEquals(nextPort, location.getPort());
// No source specified - same. // No source specified - same.
nextPort = location.getPort() + 1; nextPort = location.getPort() + 1;
conn.updateCachedLocation(location.getRegionInfo(), location, conn.updateCachedLocation(location.getRegionInfo(), location,
new ServerName("127.0.0.1", nextPort, 0), location.getSeqNum() - 1); ServerName.valueOf("127.0.0.1", nextPort, 0), location.getSeqNum() - 1);
location = conn.getCachedLocation(TABLE_NAME2, ROW); location = conn.getCachedLocation(TABLE_NAME2, ROW);
Assert.assertEquals(nextPort, location.getPort()); Assert.assertEquals(nextPort, location.getPort());
// Higher seqNum - overwrites lower seqNum. // Higher seqNum - overwrites lower seqNum.
nextPort = location.getPort() + 1; nextPort = location.getPort() + 1;
conn.updateCachedLocation(location.getRegionInfo(), anySource, conn.updateCachedLocation(location.getRegionInfo(), anySource,
new ServerName("127.0.0.1", nextPort, 0), location.getSeqNum() + 1); ServerName.valueOf("127.0.0.1", nextPort, 0), location.getSeqNum() + 1);
location = conn.getCachedLocation(TABLE_NAME2, ROW); location = conn.getCachedLocation(TABLE_NAME2, ROW);
Assert.assertEquals(nextPort, location.getPort()); Assert.assertEquals(nextPort, location.getPort());
// Lower seqNum - does not overwrite higher seqNum. // Lower seqNum - does not overwrite higher seqNum.
nextPort = location.getPort() + 1; nextPort = location.getPort() + 1;
conn.updateCachedLocation(location.getRegionInfo(), anySource, conn.updateCachedLocation(location.getRegionInfo(), anySource,
new ServerName("127.0.0.1", nextPort, 0), location.getSeqNum() - 1); ServerName.valueOf("127.0.0.1", nextPort, 0), location.getSeqNum() - 1);
location = conn.getCachedLocation(TABLE_NAME2, ROW); location = conn.getCachedLocation(TABLE_NAME2, ROW);
Assert.assertEquals(nextPort - 1, location.getPort()); Assert.assertEquals(nextPort - 1, location.getPort());
} }
@ -868,8 +868,8 @@ public class TestHCM {
// TODO: This test would seem to presume hardcoded RETRY_BACKOFF which it should not. // TODO: This test would seem to presume hardcoded RETRY_BACKOFF which it should not.
final long ANY_PAUSE = 100; final long ANY_PAUSE = 100;
HRegionInfo ri = new HRegionInfo(TABLE_NAME); HRegionInfo ri = new HRegionInfo(TABLE_NAME);
HRegionLocation location = new HRegionLocation(ri, new ServerName("127.0.0.1", 1, 0)); HRegionLocation location = new HRegionLocation(ri, ServerName.valueOf("127.0.0.1", 1, 0));
HRegionLocation diffLocation = new HRegionLocation(ri, new ServerName("127.0.0.1", 2, 0)); HRegionLocation diffLocation = new HRegionLocation(ri, ServerName.valueOf("127.0.0.1", 2, 0));
ManualEnvironmentEdge timeMachine = new ManualEnvironmentEdge(); ManualEnvironmentEdge timeMachine = new ManualEnvironmentEdge();
EnvironmentEdgeManager.injectEdge(timeMachine); EnvironmentEdgeManager.injectEdge(timeMachine);

View File

@ -169,7 +169,7 @@ public class TestMetaScanner {
Bytes.toBytes(midKey), Bytes.toBytes(midKey),
end); end);
MetaEditor.splitRegion(catalogTracker, parent, splita, splitb, new ServerName("fooserver", 1, 0)); MetaEditor.splitRegion(catalogTracker, parent, splita, splitb, ServerName.valueOf("fooserver", 1, 0));
Threads.sleep(random.nextInt(200)); Threads.sleep(random.nextInt(200));
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -91,7 +91,7 @@ public class TestDelayedRpc {
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString()); RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
try { try {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel( BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
new ServerName(rpcServer.getListenerAddress().getHostName(), ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()), rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
User.getCurrent(), RPC_CLIENT_TIMEOUT); User.getCurrent(), RPC_CLIENT_TIMEOUT);
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub = TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
@ -172,7 +172,7 @@ public class TestDelayedRpc {
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString()); RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
try { try {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel( BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
new ServerName(rpcServer.getListenerAddress().getHostName(), ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()), rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
User.getCurrent(), RPC_CLIENT_TIMEOUT); User.getCurrent(), RPC_CLIENT_TIMEOUT);
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub = TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
@ -295,8 +295,8 @@ public class TestDelayedRpc {
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString()); RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
try { try {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel( BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
new ServerName(rpcServer.getListenerAddress().getHostName(), ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()), rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
User.getCurrent(), 1000); User.getCurrent(), 1000);
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub = TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
TestDelayedRpcProtos.TestDelayedService.newBlockingStub(channel); TestDelayedRpcProtos.TestDelayedService.newBlockingStub(channel);

View File

@ -114,7 +114,7 @@ public class TestProtoBufRpc {
RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT); RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT);
try { try {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel( BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
new ServerName(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()), ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()),
User.getCurrent(), 0); User.getCurrent(), 0);
TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub = TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel); TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);

View File

@ -274,7 +274,7 @@ public class TestLoadIncrementalHFilesSplitRecovery {
Mockito.doNothing().when(c).close(); Mockito.doNothing().when(c).close();
// Make it so we return a particular location when asked. // Make it so we return a particular location when asked.
final HRegionLocation loc = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, final HRegionLocation loc = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO,
new ServerName("example.org", 1234, 0)); ServerName.valueOf("example.org", 1234, 0));
Mockito.when(c.getRegionLocation((TableName) Mockito.any(), Mockito.when(c.getRegionLocation((TableName) Mockito.any(),
(byte[]) Mockito.any(), Mockito.anyBoolean())). (byte[]) Mockito.any(), Mockito.anyBoolean())).
thenReturn(loc); thenReturn(loc);

View File

@ -73,7 +73,7 @@ public class TestActiveMasterManager {
} catch(KeeperException.NoNodeException nne) {} } catch(KeeperException.NoNodeException nne) {}
// Create the master node with a dummy address // Create the master node with a dummy address
ServerName master = new ServerName("localhost", 1, System.currentTimeMillis()); ServerName master = ServerName.valueOf("localhost", 1, System.currentTimeMillis());
// Should not have a master yet // Should not have a master yet
DummyMaster dummyMaster = new DummyMaster(zk,master); DummyMaster dummyMaster = new DummyMaster(zk,master);
ClusterStatusTracker clusterStatusTracker = ClusterStatusTracker clusterStatusTracker =
@ -116,9 +116,9 @@ public class TestActiveMasterManager {
// Create the master node with a dummy address // Create the master node with a dummy address
ServerName firstMasterAddress = ServerName firstMasterAddress =
new ServerName("localhost", 1, System.currentTimeMillis()); ServerName.valueOf("localhost", 1, System.currentTimeMillis());
ServerName secondMasterAddress = ServerName secondMasterAddress =
new ServerName("localhost", 2, System.currentTimeMillis()); ServerName.valueOf("localhost", 2, System.currentTimeMillis());
// Should not have a master yet // Should not have a master yet
DummyMaster ms1 = new DummyMaster(zk,firstMasterAddress); DummyMaster ms1 = new DummyMaster(zk,firstMasterAddress);

View File

@ -100,9 +100,9 @@ import com.google.protobuf.ServiceException;
public class TestAssignmentManager { public class TestAssignmentManager {
private static final HBaseTestingUtility HTU = new HBaseTestingUtility(); private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
private static final ServerName SERVERNAME_A = private static final ServerName SERVERNAME_A =
new ServerName("example.org", 1234, 5678); ServerName.valueOf("example.org", 1234, 5678);
private static final ServerName SERVERNAME_B = private static final ServerName SERVERNAME_B =
new ServerName("example.org", 0, 5678); ServerName.valueOf("example.org", 0, 5678);
private static final HRegionInfo REGIONINFO = private static final HRegionInfo REGIONINFO =
new HRegionInfo(TableName.valueOf("t"), new HRegionInfo(TableName.valueOf("t"),
HConstants.EMPTY_START_ROW, HConstants.EMPTY_START_ROW); HConstants.EMPTY_START_ROW, HConstants.EMPTY_START_ROW);
@ -135,7 +135,7 @@ public class TestAssignmentManager {
// If abort is called, be sure to fail the test (don't just swallow it // If abort is called, be sure to fail the test (don't just swallow it
// silently as is mockito default). // silently as is mockito default).
this.server = Mockito.mock(Server.class); this.server = Mockito.mock(Server.class);
Mockito.when(server.getServerName()).thenReturn(new ServerName("master,1,1")); Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("master,1,1"));
Mockito.when(server.getConfiguration()).thenReturn(HTU.getConfiguration()); Mockito.when(server.getConfiguration()).thenReturn(HTU.getConfiguration());
this.watcher = this.watcher =
new ZooKeeperWatcher(HTU.getConfiguration(), "mockedServer", this.server, true); new ZooKeeperWatcher(HTU.getConfiguration(), "mockedServer", this.server, true);

View File

@ -158,8 +158,8 @@ public class TestAssignmentManagerOnCluster {
ServerName destServer = onlineServers.iterator().next(); ServerName destServer = onlineServers.iterator().next();
// Created faked dead server // Created faked dead server
deadServer = new ServerName(destServer.getHostname(), deadServer = ServerName.valueOf(destServer.getHostname(),
destServer.getPort(), destServer.getStartcode() - 100L); destServer.getPort(), destServer.getStartcode() - 100L);
master.serverManager.recordNewServer(deadServer, ServerLoad.EMPTY_SERVERLOAD); master.serverManager.recordNewServer(deadServer, ServerLoad.EMPTY_SERVERLOAD);
AssignmentManager am = master.getAssignmentManager(); AssignmentManager am = master.getAssignmentManager();

View File

@ -111,7 +111,7 @@ public class TestCatalogJanitor {
this.connection = this.connection =
HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c, HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
Mockito.mock(AdminProtos.AdminService.BlockingInterface.class), ri, Mockito.mock(AdminProtos.AdminService.BlockingInterface.class), ri,
new ServerName("example.org,12345,6789"), ServerName.valueOf("example.org,12345,6789"),
HRegionInfo.FIRST_META_REGIONINFO); HRegionInfo.FIRST_META_REGIONINFO);
// Set hbase.rootdir into test dir. // Set hbase.rootdir into test dir.
FileSystem fs = FileSystem.get(this.c); FileSystem fs = FileSystem.get(this.c);
@ -136,7 +136,7 @@ public class TestCatalogJanitor {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName("mockserver.example.org", 1234, -1L); return ServerName.valueOf("mockserver.example.org", 1234, -1L);
} }
@Override @Override

View File

@ -63,7 +63,7 @@ public class TestClusterStatusPublisher {
List<Pair<ServerName, Long>> res = new ArrayList<Pair<ServerName, Long>>(); List<Pair<ServerName, Long>> res = new ArrayList<Pair<ServerName, Long>>();
switch ((int) EnvironmentEdgeManager.currentTimeMillis()) { switch ((int) EnvironmentEdgeManager.currentTimeMillis()) {
case 2: case 2:
res.add(new Pair<ServerName, Long>(new ServerName("hn", 10, 10), 1L)); res.add(new Pair<ServerName, Long>(ServerName.valueOf("hn", 10, 10), 1L));
break; break;
case 1000: case 1000:
break; break;
@ -88,7 +88,7 @@ public class TestClusterStatusPublisher {
protected List<Pair<ServerName, Long>> getDeadServers(long since) { protected List<Pair<ServerName, Long>> getDeadServers(long since) {
List<Pair<ServerName, Long>> res = new ArrayList<Pair<ServerName, Long>>(); List<Pair<ServerName, Long>> res = new ArrayList<Pair<ServerName, Long>>();
for (int i = 0; i < 25; i++) { for (int i = 0; i < 25; i++) {
res.add(new Pair<ServerName, Long>(new ServerName("hn" + i, 10, 10), 20L)); res.add(new Pair<ServerName, Long>(ServerName.valueOf("hn" + i, 10, 10), 20L));
} }
return res; return res;

View File

@ -34,10 +34,10 @@ import static org.junit.Assert.assertTrue;
@Category(MediumTests.class) @Category(MediumTests.class)
public class TestDeadServer { public class TestDeadServer {
final ServerName hostname123 = new ServerName("127.0.0.1", 123, 3L); final ServerName hostname123 = ServerName.valueOf("127.0.0.1", 123, 3L);
final ServerName hostname123_2 = new ServerName("127.0.0.1", 123, 4L); final ServerName hostname123_2 = ServerName.valueOf("127.0.0.1", 123, 4L);
final ServerName hostname1234 = new ServerName("127.0.0.2", 1234, 4L); final ServerName hostname1234 = ServerName.valueOf("127.0.0.2", 1234, 4L);
final ServerName hostname12345 = new ServerName("127.0.0.2", 12345, 4L); final ServerName hostname12345 = ServerName.valueOf("127.0.0.2", 12345, 4L);
@Test public void testIsDead() { @Test public void testIsDead() {
DeadServer ds = new DeadServer(); DeadServer ds = new DeadServer();
@ -59,7 +59,7 @@ public class TestDeadServer {
// Already dead = 127.0.0.1,9090,112321 // Already dead = 127.0.0.1,9090,112321
// Coming back alive = 127.0.0.1,9090,223341 // Coming back alive = 127.0.0.1,9090,223341
final ServerName deadServer = new ServerName("127.0.0.1", 9090, 112321L); final ServerName deadServer = ServerName.valueOf("127.0.0.1", 9090, 112321L);
assertFalse(ds.cleanPreviousInstance(deadServer)); assertFalse(ds.cleanPreviousInstance(deadServer));
ds.add(deadServer); ds.add(deadServer);
assertTrue(ds.isDeadServer(deadServer)); assertTrue(ds.isDeadServer(deadServer));
@ -68,7 +68,7 @@ public class TestDeadServer {
Assert.assertNotNull(ds.getTimeOfDeath(eachDeadServer)); Assert.assertNotNull(ds.getTimeOfDeath(eachDeadServer));
} }
final ServerName deadServerHostComingAlive = final ServerName deadServerHostComingAlive =
new ServerName("127.0.0.1", 9090, 223341L); ServerName.valueOf("127.0.0.1", 9090, 223341L);
assertTrue(ds.cleanPreviousInstance(deadServerHostComingAlive)); assertTrue(ds.cleanPreviousInstance(deadServerHostComingAlive));
assertFalse(ds.isDeadServer(deadServer)); assertFalse(ds.isDeadServer(deadServer));
assertFalse(ds.cleanPreviousInstance(deadServerHostComingAlive)); assertFalse(ds.cleanPreviousInstance(deadServerHostComingAlive));

View File

@ -26,13 +26,11 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MediumTests; import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.SplitLogTask; import org.apache.hadoop.hbase.SplitLogTask;
import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.FSUtils;
@ -89,8 +87,8 @@ public class TestMasterFileSystem {
String failedRegion = "failedRegoin1"; String failedRegion = "failedRegoin1";
String staleRegion = "staleRegion"; String staleRegion = "staleRegion";
ServerName inRecoveryServerName = new ServerName("mgr,1,1"); ServerName inRecoveryServerName = ServerName.valueOf("mgr,1,1");
ServerName previouselyFaildServerName = new ServerName("previous,1,1"); ServerName previouselyFaildServerName = ServerName.valueOf("previous,1,1");
String walPath = "/hbase/data/.logs/" + inRecoveryServerName.getServerName() String walPath = "/hbase/data/.logs/" + inRecoveryServerName.getServerName()
+ "-splitting/test"; + "-splitting/test";
// Create a ZKW to use in the test // Create a ZKW to use in the test

View File

@ -144,9 +144,9 @@ public class TestMasterNoCluster {
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
// Names for our three servers. Make the port numbers match hostname. // Names for our three servers. Make the port numbers match hostname.
// Will come in use down in the server when we need to figure how to respond. // Will come in use down in the server when we need to figure how to respond.
final ServerName sn0 = new ServerName("0.example.org", 0, now); final ServerName sn0 = ServerName.valueOf("0.example.org", 0, now);
final ServerName sn1 = new ServerName("1.example.org", 1, now); final ServerName sn1 = ServerName.valueOf("1.example.org", 1, now);
final ServerName sn2 = new ServerName("2.example.org", 2, now); final ServerName sn2 = ServerName.valueOf("2.example.org", 2, now);
final ServerName [] sns = new ServerName [] {sn0, sn1, sn2}; final ServerName [] sns = new ServerName [] {sn0, sn1, sn2};
// Put up the mock servers // Put up the mock servers
final Configuration conf = TESTUTIL.getConfiguration(); final Configuration conf = TESTUTIL.getConfiguration();
@ -256,7 +256,7 @@ public class TestMasterNoCluster {
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
// Name for our single mocked up regionserver. // Name for our single mocked up regionserver.
final ServerName sn = new ServerName("0.example.org", 0, now); final ServerName sn = ServerName.valueOf("0.example.org", 0, now);
// Here is our mocked up regionserver. Create it now. Need it setting up // Here is our mocked up regionserver. Create it now. Need it setting up
// master next. // master next.
final MockRegionServer rs0 = new MockRegionServer(conf, sn); final MockRegionServer rs0 = new MockRegionServer(conf, sn);
@ -357,8 +357,8 @@ public class TestMasterNoCluster {
public void testNotPullingDeadRegionServerFromZK() public void testNotPullingDeadRegionServerFromZK()
throws IOException, KeeperException, InterruptedException { throws IOException, KeeperException, InterruptedException {
final Configuration conf = TESTUTIL.getConfiguration(); final Configuration conf = TESTUTIL.getConfiguration();
final ServerName newServer = new ServerName("test.sample", 1, 101); final ServerName newServer = ServerName.valueOf("test.sample", 1, 101);
final ServerName deadServer = new ServerName("test.sample", 1, 100); final ServerName deadServer = ServerName.valueOf("test.sample", 1, 100);
final MockRegionServer rs0 = new MockRegionServer(conf, newServer); final MockRegionServer rs0 = new MockRegionServer(conf, newServer);
HMaster master = new HMaster(conf) { HMaster master = new HMaster(conf) {

View File

@ -56,7 +56,7 @@ public class TestMasterStatusServlet {
private HBaseAdmin admin; private HBaseAdmin admin;
static final ServerName FAKE_HOST = static final ServerName FAKE_HOST =
new ServerName("fakehost", 12345, 1234567890); ServerName.valueOf("fakehost", 12345, 1234567890);
static final HTableDescriptor FAKE_TABLE = static final HTableDescriptor FAKE_TABLE =
new HTableDescriptor(TableName.valueOf("mytable")); new HTableDescriptor(TableName.valueOf("mytable"));
static final HRegionInfo FAKE_HRI = static final HRegionInfo FAKE_HRI =
@ -124,7 +124,7 @@ public class TestMasterStatusServlet {
setupMockTables(); setupMockTables();
new MasterStatusTmpl() new MasterStatusTmpl()
.setMetaLocation(new ServerName("metaserver:123,12345")) .setMetaLocation(ServerName.valueOf("metaserver:123,12345"))
.render(new StringWriter(), .render(new StringWriter(),
master, admin); master, admin);
} }
@ -134,16 +134,16 @@ public class TestMasterStatusServlet {
setupMockTables(); setupMockTables();
List<ServerName> servers = Lists.newArrayList( List<ServerName> servers = Lists.newArrayList(
new ServerName("rootserver:123,12345"), ServerName.valueOf("rootserver:123,12345"),
new ServerName("metaserver:123,12345")); ServerName.valueOf("metaserver:123,12345"));
Set<ServerName> deadServers = new HashSet<ServerName>( Set<ServerName> deadServers = new HashSet<ServerName>(
Lists.newArrayList( Lists.newArrayList(
new ServerName("badserver:123,12345"), ServerName.valueOf("badserver:123,12345"),
new ServerName("uglyserver:123,12345")) ServerName.valueOf("uglyserver:123,12345"))
); );
new MasterStatusTmpl() new MasterStatusTmpl()
.setMetaLocation(new ServerName("metaserver:123,12345")) .setMetaLocation(ServerName.valueOf("metaserver:123,12345"))
.setServers(servers) .setServers(servers)
.setDeadServers(deadServers) .setDeadServers(deadServers)
.render(new StringWriter(), .render(new StringWriter(),

View File

@ -622,7 +622,7 @@ public class TestRegionPlacement {
totalRegionNum.incrementAndGet(); totalRegionNum.incrementAndGet();
if (server != null) { if (server != null) {
ServerName serverName = ServerName serverName =
new ServerName(Bytes.toString(server), -1); ServerName.valueOf(Bytes.toString(server), -1);
if (favoredNodes != null) { if (favoredNodes != null) {
String placement = "[NOT FAVORED NODE]"; String placement = "[NOT FAVORED NODE]";
for (int i = 0; i < favoredServerList.length; i++) { for (int i = 0; i < favoredServerList.length; i++) {

View File

@ -66,7 +66,7 @@ public class TestRestartCluster {
String unassignedZNode = zooKeeper.assignmentZNode; String unassignedZNode = zooKeeper.assignmentZNode;
ZKUtil.createAndFailSilent(zooKeeper, unassignedZNode); ZKUtil.createAndFailSilent(zooKeeper, unassignedZNode);
ServerName sn = new ServerName(HMaster.MASTER, -1, System.currentTimeMillis()); ServerName sn = ServerName.valueOf(HMaster.MASTER, -1, System.currentTimeMillis());
ZKAssign.createNodeOffline(zooKeeper, HRegionInfo.FIRST_META_REGIONINFO, sn); ZKAssign.createNodeOffline(zooKeeper, HRegionInfo.FIRST_META_REGIONINFO, sn);

View File

@ -77,7 +77,7 @@ import org.mockito.Mockito;
@Category(MediumTests.class) @Category(MediumTests.class)
public class TestSplitLogManager { public class TestSplitLogManager {
private static final Log LOG = LogFactory.getLog(TestSplitLogManager.class); private static final Log LOG = LogFactory.getLog(TestSplitLogManager.class);
private final ServerName DUMMY_MASTER = new ServerName("dummy-master,1,1"); private final ServerName DUMMY_MASTER = ServerName.valueOf("dummy-master,1,1");
private final ServerManager sm = Mockito.mock(ServerManager.class); private final ServerManager sm = Mockito.mock(ServerManager.class);
private final MasterServices master = Mockito.mock(MasterServices.class); private final MasterServices master = Mockito.mock(MasterServices.class);
@ -271,9 +271,9 @@ public class TestSplitLogManager {
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
int version = ZKUtil.checkExists(zkw, tasknode); int version = ZKUtil.checkExists(zkw, tasknode);
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
final ServerName worker2 = new ServerName("worker2,1,1"); final ServerName worker2 = ServerName.valueOf("worker2,1,1");
final ServerName worker3 = new ServerName("worker3,1,1"); final ServerName worker3 = ServerName.valueOf("worker3,1,1");
SplitLogTask slt = new SplitLogTask.Owned(worker1); SplitLogTask slt = new SplitLogTask.Owned(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray()); ZKUtil.setData(zkw, tasknode, slt.toByteArray());
waitForCounter(tot_mgr_heartbeat, 0, 1, to/2); waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
@ -303,7 +303,7 @@ public class TestSplitLogManager {
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
int version = ZKUtil.checkExists(zkw, tasknode); int version = ZKUtil.checkExists(zkw, tasknode);
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Owned(worker1); SplitLogTask slt = new SplitLogTask.Owned(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray()); ZKUtil.setData(zkw, tasknode, slt.toByteArray());
waitForCounter(tot_mgr_heartbeat, 0, 1, to/2); waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
@ -330,7 +330,7 @@ public class TestSplitLogManager {
slm = new SplitLogManager(zkw, conf, stopper, master, DUMMY_MASTER); slm = new SplitLogManager(zkw, conf, stopper, master, DUMMY_MASTER);
TaskBatch batch = new TaskBatch(); TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Done(worker1); SplitLogTask slt = new SplitLogTask.Done(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray()); ZKUtil.setData(zkw, tasknode, slt.toByteArray());
synchronized (batch) { synchronized (batch) {
@ -351,7 +351,7 @@ public class TestSplitLogManager {
TaskBatch batch = new TaskBatch(); TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Err(worker1); SplitLogTask slt = new SplitLogTask.Err(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray()); ZKUtil.setData(zkw, tasknode, slt.toByteArray());
@ -374,7 +374,7 @@ public class TestSplitLogManager {
TaskBatch batch = new TaskBatch(); TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
assertEquals(tot_mgr_resubmit.get(), 0); assertEquals(tot_mgr_resubmit.get(), 0);
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
assertEquals(tot_mgr_resubmit.get(), 0); assertEquals(tot_mgr_resubmit.get(), 0);
SplitLogTask slt = new SplitLogTask.Resigned(worker1); SplitLogTask slt = new SplitLogTask.Resigned(worker1);
assertEquals(tot_mgr_resubmit.get(), 0); assertEquals(tot_mgr_resubmit.get(), 0);
@ -398,7 +398,7 @@ public class TestSplitLogManager {
// create an orphan task in OWNED state // create an orphan task in OWNED state
String tasknode1 = ZKSplitLog.getEncodedNodeName(zkw, "orphan/1"); String tasknode1 = ZKSplitLog.getEncodedNodeName(zkw, "orphan/1");
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Owned(worker1); SplitLogTask slt = new SplitLogTask.Owned(worker1);
zkw.getRecoverableZooKeeper().create(tasknode1, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE, zkw.getRecoverableZooKeeper().create(tasknode1, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT); CreateMode.PERSISTENT);
@ -413,7 +413,7 @@ public class TestSplitLogManager {
// keep updating the orphan owned node every to/2 seconds // keep updating the orphan owned node every to/2 seconds
for (int i = 0; i < (3 * to)/100; i++) { for (int i = 0; i < (3 * to)/100; i++) {
Thread.sleep(100); Thread.sleep(100);
final ServerName worker2 = new ServerName("worker1,1,1"); final ServerName worker2 = ServerName.valueOf("worker1,1,1");
slt = new SplitLogTask.Owned(worker2); slt = new SplitLogTask.Owned(worker2);
ZKUtil.setData(zkw, tasknode1, slt.toByteArray()); ZKUtil.setData(zkw, tasknode1, slt.toByteArray());
} }
@ -437,7 +437,7 @@ public class TestSplitLogManager {
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
int version = ZKUtil.checkExists(zkw, tasknode); int version = ZKUtil.checkExists(zkw, tasknode);
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Owned(worker1); SplitLogTask slt = new SplitLogTask.Owned(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray()); ZKUtil.setData(zkw, tasknode, slt.toByteArray());
if (tot_mgr_heartbeat.get() == 0) waitForCounter(tot_mgr_heartbeat, 0, 1, to/2); if (tot_mgr_heartbeat.get() == 0) waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
@ -461,7 +461,7 @@ public class TestSplitLogManager {
TaskBatch batch = new TaskBatch(); TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1"); String tasknode = submitTaskAndWait(batch, "foo/1");
final ServerName worker1 = new ServerName("worker1,1,1"); final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Owned(worker1); SplitLogTask slt = new SplitLogTask.Owned(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray()); ZKUtil.setData(zkw, tasknode, slt.toByteArray());

View File

@ -268,7 +268,7 @@ public class TestTableLockManager {
@Test(timeout = 600000) @Test(timeout = 600000)
public void testReapAllTableLocks() throws Exception { public void testReapAllTableLocks() throws Exception {
prepareMiniZkCluster(); prepareMiniZkCluster();
ServerName serverName = new ServerName("localhost:10000", 0); ServerName serverName = ServerName.valueOf("localhost:10000", 0);
final TableLockManager lockManager = TableLockManager.createTableLockManager( final TableLockManager lockManager = TableLockManager.createTableLockManager(
TEST_UTIL.getConfiguration(), TEST_UTIL.getZooKeeperWatcher(), serverName); TEST_UTIL.getConfiguration(), TEST_UTIL.getZooKeeperWatcher(), serverName);

View File

@ -220,7 +220,7 @@ public class BalancerTestBase {
String host = "srv" + rand.nextInt(100000); String host = "srv" + rand.nextInt(100000);
int port = rand.nextInt(60000); int port = rand.nextInt(60000);
long startCode = rand.nextLong(); long startCode = rand.nextLong();
ServerName sn = new ServerName(host, port, startCode); ServerName sn = ServerName.valueOf(host, port, startCode);
return new ServerAndLoad(sn, numRegionsPerServer); return new ServerAndLoad(sn, numRegionsPerServer);
} }

View File

@ -149,7 +149,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase {
// The old server would have had same host and port, but different // The old server would have had same host and port, but different
// start code! // start code!
ServerName snWithOldStartCode = ServerName snWithOldStartCode =
new ServerName(sn.getHostname(), sn.getPort(), sn.getStartcode() - 10); ServerName.valueOf(sn.getHostname(), sn.getPort(), sn.getStartcode() - 10);
existing.put(regions.get(i), snWithOldStartCode); existing.put(regions.get(i), snWithOldStartCode);
} }
List<ServerName> listOfServerNames = getListOfServerNames(servers); List<ServerName> listOfServerNames = getListOfServerNames(servers);

View File

@ -52,7 +52,7 @@ public class TestFavoredNodeAssignmentHelper {
// Set up some server -> rack mappings // Set up some server -> rack mappings
// Have three racks in the cluster with 10 hosts each. // Have three racks in the cluster with 10 hosts each.
for (int i = 0; i < 40; i++) { for (int i = 0; i < 40; i++) {
ServerName server = new ServerName("foo"+i+":1234",-1); ServerName server = ServerName.valueOf("foo" + i + ":1234", -1);
if (i < 10) { if (i < 10) {
Mockito.when(rackManager.getRack(server)).thenReturn("rack1"); Mockito.when(rackManager.getRack(server)).thenReturn("rack1");
if (rackToServers.get("rack1") == null) { if (rackToServers.get("rack1") == null) {

View File

@ -121,7 +121,7 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
@Test @Test
public void testKeepRegionLoad() throws Exception { public void testKeepRegionLoad() throws Exception {
ServerName sn = new ServerName("test:8080", 100); ServerName sn = ServerName.valueOf("test:8080", 100);
int numClusterStatusToAdd = 20000; int numClusterStatusToAdd = 20000;
for (int i = 0; i < numClusterStatusToAdd; i++) { for (int i = 0; i < numClusterStatusToAdd; i++) {
ServerLoad sl = mock(ServerLoad.class); ServerLoad sl = mock(ServerLoad.class);
@ -267,7 +267,7 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
ServerName sn = serverMap.keySet().toArray(new ServerName[serverMap.size()])[0]; ServerName sn = serverMap.keySet().toArray(new ServerName[serverMap.size()])[0];
ServerName deadSn = new ServerName(sn.getHostname(), sn.getPort(), sn.getStartcode() -100); ServerName deadSn = ServerName.valueOf(sn.getHostname(), sn.getPort(), sn.getStartcode() - 100);
serverMap.put(deadSn, new ArrayList<HRegionInfo>(0)); serverMap.put(deadSn, new ArrayList<HRegionInfo>(0));

View File

@ -215,7 +215,7 @@ public class TestHFileCleaner {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName("regionserver,60020,000000"); return ServerName.valueOf("regionserver,60020,000000");
} }
@Override @Override

View File

@ -151,7 +151,7 @@ public class TestHFileLinkCleaner {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName("regionserver,60020,000000"); return ServerName.valueOf("regionserver,60020,000000");
} }
@Override @Override

View File

@ -28,7 +28,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.catalog.CatalogTracker; import org.apache.hadoop.hbase.catalog.CatalogTracker;
import org.apache.hadoop.hbase.master.cleaner.LogCleaner;
import org.apache.hadoop.hbase.replication.ReplicationFactory; import org.apache.hadoop.hbase.replication.ReplicationFactory;
import org.apache.hadoop.hbase.replication.ReplicationQueues; import org.apache.hadoop.hbase.replication.ReplicationQueues;
import org.apache.hadoop.hbase.replication.regionserver.Replication; import org.apache.hadoop.hbase.replication.regionserver.Replication;
@ -153,7 +152,7 @@ public class TestLogsCleaner {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName("regionserver,60020,000000"); return ServerName.valueOf("regionserver,60020,000000");
} }
@Override @Override

View File

@ -75,7 +75,7 @@ public class TestMasterAddressManager {
// Create the master node with a dummy address // Create the master node with a dummy address
String host = "localhost"; String host = "localhost";
int port = 1234; int port = 1234;
ServerName sn = new ServerName(host, port, System.currentTimeMillis()); ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
LOG.info("Creating master node"); LOG.info("Creating master node");
MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn); MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn);

View File

@ -56,12 +56,12 @@ public class TestRSStatusServlet {
static final int FAKE_WEB_PORT = 1586; static final int FAKE_WEB_PORT = 1586;
private final ServerName fakeServerName = private final ServerName fakeServerName =
new ServerName("localhost", FAKE_IPC_PORT, 11111); ServerName.valueOf("localhost", FAKE_IPC_PORT, 11111);
private final GetServerInfoResponse fakeResponse = private final GetServerInfoResponse fakeResponse =
ResponseConverter.buildGetServerInfoResponse(fakeServerName, FAKE_WEB_PORT); ResponseConverter.buildGetServerInfoResponse(fakeServerName, FAKE_WEB_PORT);
private final ServerName fakeMasterAddress = private final ServerName fakeMasterAddress =
new ServerName("localhost", 60010, 1212121212); ServerName.valueOf("localhost", 60010, 1212121212);
@Before @Before
public void setupBasicMocks() throws IOException, ServiceException { public void setupBasicMocks() throws IOException, ServiceException {

View File

@ -48,7 +48,7 @@ import org.junit.experimental.categories.Category;
@Category(MediumTests.class) @Category(MediumTests.class)
public class TestSplitLogWorker { public class TestSplitLogWorker {
private static final Log LOG = LogFactory.getLog(TestSplitLogWorker.class); private static final Log LOG = LogFactory.getLog(TestSplitLogWorker.class);
private final ServerName MANAGER = new ServerName("manager,1,1"); private final ServerName MANAGER = ServerName.valueOf("manager,1,1");
static { static {
Logger.getLogger("org.apache.hadoop.hbase").setLevel(Level.DEBUG); Logger.getLogger("org.apache.hadoop.hbase").setLevel(Level.DEBUG);
} }
@ -131,9 +131,9 @@ public class TestSplitLogWorker {
LOG.info("testAcquireTaskAtStartup"); LOG.info("testAcquireTaskAtStartup");
SplitLogCounters.resetCounters(); SplitLogCounters.resetCounters();
final String TATAS = "tatas"; final String TATAS = "tatas";
final ServerName RS = new ServerName("rs,1,1"); final ServerName RS = ServerName.valueOf("rs,1,1");
zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, TATAS), zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, TATAS),
new SplitLogTask.Unassigned(new ServerName("mgr,1,1")).toByteArray(), Ids.OPEN_ACL_UNSAFE, new SplitLogTask.Unassigned(ServerName.valueOf("mgr,1,1")).toByteArray(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT); CreateMode.PERSISTENT);
SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), RS, neverEndingTask); SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), RS, neverEndingTask);
@ -164,8 +164,8 @@ public class TestSplitLogWorker {
LOG.info("testRaceForTask"); LOG.info("testRaceForTask");
SplitLogCounters.resetCounters(); SplitLogCounters.resetCounters();
final String TRFT = "trft"; final String TRFT = "trft";
final ServerName SVR1 = new ServerName("svr1,1,1"); final ServerName SVR1 = ServerName.valueOf("svr1,1,1");
final ServerName SVR2 = new ServerName("svr2,1,1"); final ServerName SVR2 = ServerName.valueOf("svr2,1,1");
zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, TRFT), zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, TRFT),
new SplitLogTask.Unassigned(MANAGER).toByteArray(), Ids.OPEN_ACL_UNSAFE, new SplitLogTask.Unassigned(MANAGER).toByteArray(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT); CreateMode.PERSISTENT);
@ -193,7 +193,7 @@ public class TestSplitLogWorker {
public void testPreemptTask() throws Exception { public void testPreemptTask() throws Exception {
LOG.info("testPreemptTask"); LOG.info("testPreemptTask");
SplitLogCounters.resetCounters(); SplitLogCounters.resetCounters();
final ServerName SRV = new ServerName("tpt_svr,1,1"); final ServerName SRV = ServerName.valueOf("tpt_svr,1,1");
final String PATH = ZKSplitLog.getEncodedNodeName(zkw, "tpt_task"); final String PATH = ZKSplitLog.getEncodedNodeName(zkw, "tpt_task");
SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask); SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask);
slw.start(); slw.start();
@ -224,7 +224,7 @@ public class TestSplitLogWorker {
public void testMultipleTasks() throws Exception { public void testMultipleTasks() throws Exception {
LOG.info("testMultipleTasks"); LOG.info("testMultipleTasks");
SplitLogCounters.resetCounters(); SplitLogCounters.resetCounters();
final ServerName SRV = new ServerName("tmt_svr,1,1"); final ServerName SRV = ServerName.valueOf("tmt_svr,1,1");
final String PATH1 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_task"); final String PATH1 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_task");
SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask); SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask);
slw.start(); slw.start();
@ -246,7 +246,7 @@ public class TestSplitLogWorker {
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
// preempt the first task, have it owned by another worker // preempt the first task, have it owned by another worker
final ServerName anotherWorker = new ServerName("another-worker,1,1"); final ServerName anotherWorker = ServerName.valueOf("another-worker,1,1");
SplitLogTask slt = new SplitLogTask.Owned(anotherWorker); SplitLogTask slt = new SplitLogTask.Owned(anotherWorker);
ZKUtil.setData(zkw, PATH1, slt.toByteArray()); ZKUtil.setData(zkw, PATH1, slt.toByteArray());
waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, 1500); waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, 1500);
@ -265,7 +265,7 @@ public class TestSplitLogWorker {
public void testRescan() throws Exception { public void testRescan() throws Exception {
LOG.info("testRescan"); LOG.info("testRescan");
SplitLogCounters.resetCounters(); SplitLogCounters.resetCounters();
final ServerName SRV = new ServerName("svr,1,1"); final ServerName SRV = ServerName.valueOf("svr,1,1");
slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask); slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask);
slw.start(); slw.start();
Thread.yield(); // let the worker start Thread.yield(); // let the worker start

View File

@ -419,7 +419,7 @@ public class TestSplitTransactionOnCluster {
int regionCount = ProtobufUtil.getOnlineRegions(server).size(); int regionCount = ProtobufUtil.getOnlineRegions(server).size();
// Insert into zk a blocking znode, a znode of same name as region // Insert into zk a blocking znode, a znode of same name as region
// so it gets in way of our splitting. // so it gets in way of our splitting.
ServerName fakedServer = new ServerName("any.old.server", 1234, -1); ServerName fakedServer = ServerName.valueOf("any.old.server", 1234, -1);
ZKAssign.createNodeClosing(TESTING_UTIL.getZooKeeperWatcher(), ZKAssign.createNodeClosing(TESTING_UTIL.getZooKeeperWatcher(),
hri, fakedServer); hri, fakedServer);
// Now try splitting.... should fail. And each should successfully // Now try splitting.... should fail. And each should successfully

View File

@ -23,11 +23,8 @@ import static org.junit.Assert.*;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.BindException; import java.net.BindException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.TreeMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -63,9 +60,6 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/** JUnit test case for HLog */ /** JUnit test case for HLog */
@Category(LargeTests.class) @Category(LargeTests.class)
@ -716,7 +710,7 @@ public class TestHLog {
@Test @Test
public void testGetServerNameFromHLogDirectoryName() throws IOException { public void testGetServerNameFromHLogDirectoryName() throws IOException {
ServerName sn = new ServerName("hn", 450, 1398); ServerName sn = ServerName.valueOf("hn", 450, 1398);
String hl = FSUtils.getRootDir(conf) + "/" + HLogUtil.getHLogDirectoryName(sn.toString()); String hl = FSUtils.getRootDir(conf) + "/" + HLogUtil.getHLogDirectoryName(sn.toString());
// Must not throw exception // Must not throw exception

View File

@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.replication;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.SortedSet; import java.util.SortedSet;
@ -29,7 +28,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.zookeeper.ZKUtil; import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.zookeeper.KeeperException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -43,9 +41,9 @@ public abstract class TestReplicationStateBasic {
protected ReplicationQueues rq2; protected ReplicationQueues rq2;
protected ReplicationQueues rq3; protected ReplicationQueues rq3;
protected ReplicationQueuesClient rqc; protected ReplicationQueuesClient rqc;
protected String server1 = new ServerName("hostname1.example.org", 1234, -1L).toString(); protected String server1 = ServerName.valueOf("hostname1.example.org", 1234, -1L).toString();
protected String server2 = new ServerName("hostname2.example.org", 1234, -1L).toString(); protected String server2 = ServerName.valueOf("hostname2.example.org", 1234, -1L).toString();
protected String server3 = new ServerName("hostname3.example.org", 1234, -1L).toString(); protected String server3 = ServerName.valueOf("hostname3.example.org", 1234, -1L).toString();
protected ReplicationPeers rp; protected ReplicationPeers rp;
protected static final String ID_ONE = "1"; protected static final String ID_ONE = "1";
protected static final String ID_TWO = "2"; protected static final String ID_TWO = "2";
@ -124,7 +122,7 @@ public abstract class TestReplicationStateBasic {
assertNull(rq1.getAllQueues()); assertNull(rq1.getAllQueues());
assertEquals(0, rq1.getLogPosition("bogus", "bogus")); assertEquals(0, rq1.getLogPosition("bogus", "bogus"));
assertNull(rq1.getLogsInQueue("bogus")); assertNull(rq1.getLogsInQueue("bogus"));
assertEquals(0, rq1.claimQueues(new ServerName("bogus", 1234, -1L).toString()).size()); assertEquals(0, rq1.claimQueues(ServerName.valueOf("bogus", 1234, -1L).toString()).size());
rq1.setLogPosition("bogus", "bogus", 5L); rq1.setLogPosition("bogus", "bogus", 5L);

View File

@ -148,7 +148,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName(this.serverName); return ServerName.valueOf(this.serverName);
} }
@Override @Override

View File

@ -224,7 +224,7 @@ public class TestReplicationTrackerZKImpl {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName(this.serverName); return ServerName.valueOf(this.serverName);
} }
@Override @Override

View File

@ -397,7 +397,7 @@ public class TestReplicationSourceManager {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName(hostname, 1234, 1L); return ServerName.valueOf(hostname, 1234, 1L);
} }
@Override @Override

View File

@ -101,7 +101,7 @@ public class TestSecureRPC {
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString()); RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
try { try {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel( BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
new ServerName(rpcServer.getListenerAddress().getHostName(), ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()), rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
User.getCurrent(), 1000); User.getCurrent(), 1000);
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub = TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =

View File

@ -52,7 +52,6 @@ import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface; import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface;
import org.apache.hadoop.hbase.ipc.RpcServerInterface; import org.apache.hadoop.hbase.ipc.RpcServerInterface;
import org.apache.hadoop.hbase.ipc.ServerRpcController; import org.apache.hadoop.hbase.ipc.ServerRpcController;
import org.apache.hadoop.hbase.ipc.SimpleRpcScheduler;
import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos; import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos;
import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.RegionServerServices; import org.apache.hadoop.hbase.regionserver.RegionServerServices;
@ -160,7 +159,7 @@ public class TestTokenAuthentication {
@Override @Override
public ServerName getServerName() { public ServerName getServerName() {
return new ServerName(isa.getHostName(), isa.getPort(), startcode); return ServerName.valueOf(isa.getHostName(), isa.getPort(), startcode);
} }
@Override @Override
@ -383,8 +382,8 @@ public class TestTokenAuthentication {
Configuration c = server.getConfiguration(); Configuration c = server.getConfiguration();
RpcClient rpcClient = new RpcClient(c, clusterId.toString()); RpcClient rpcClient = new RpcClient(c, clusterId.toString());
ServerName sn = ServerName sn =
new ServerName(server.getAddress().getHostName(), server.getAddress().getPort(), ServerName.valueOf(server.getAddress().getHostName(), server.getAddress().getPort(),
System.currentTimeMillis()); System.currentTimeMillis());
try { try {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn, BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn,
User.getCurrent(), HConstants.DEFAULT_HBASE_RPC_TIMEOUT); User.getCurrent(), HConstants.DEFAULT_HBASE_RPC_TIMEOUT);

View File

@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
*/ */
public class MockServer implements Server { public class MockServer implements Server {
static final Log LOG = LogFactory.getLog(MockServer.class); static final Log LOG = LogFactory.getLog(MockServer.class);
final static ServerName NAME = new ServerName("MockServer", 123, -1); final static ServerName NAME = ServerName.valueOf("MockServer", 123, -1);
boolean stopped; boolean stopped;
boolean aborted; boolean aborted;

View File

@ -2031,7 +2031,7 @@ public class TestHBaseFsck {
HBaseFsck hbck = doFsck(conf, false); HBaseFsck hbck = doFsck(conf, false);
assertNoErrors(hbck); assertNoErrors(hbck);
ServerName mockName = new ServerName("localhost", 60000, 1); ServerName mockName = ServerName.valueOf("localhost", 60000, 1);
// obtain one lock // obtain one lock
final TableLockManager tableLockManager = TableLockManager.createTableLockManager(conf, TEST_UTIL.getZooKeeperWatcher(), mockName); final TableLockManager tableLockManager = TableLockManager.createTableLockManager(conf, TEST_UTIL.getZooKeeperWatcher(), mockName);
@ -2113,7 +2113,7 @@ public class TestHBaseFsck {
HConnection connection = HConnectionManager.getConnection(conf); HConnection connection = HConnectionManager.getConnection(conf);
HRegionLocation metaLocation = connection.locateRegion(TableName.META_TABLE_NAME, HRegionLocation metaLocation = connection.locateRegion(TableName.META_TABLE_NAME,
HConstants.EMPTY_START_ROW); HConstants.EMPTY_START_ROW);
ServerName hsa = new ServerName(metaLocation.getHostnamePort(), 0L); ServerName hsa = ServerName.valueOf(metaLocation.getHostnamePort(), 0L);
HRegionInfo hri = metaLocation.getRegionInfo(); HRegionInfo hri = metaLocation.getRegionInfo();
if (unassign) { if (unassign) {
LOG.info("Undeploying meta region " + hri + " from server " + hsa); LOG.info("Undeploying meta region " + hri + " from server " + hsa);

View File

@ -25,7 +25,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Random; import java.util.Random;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
@ -33,12 +32,10 @@ import junit.framework.Assert;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.master.TestActiveMasterManager.NodeDeletionListener; import org.apache.hadoop.hbase.master.TestActiveMasterManager.NodeDeletionListener;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.util.Threads;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher; import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooDefs.Ids; import org.apache.zookeeper.ZooDefs.Ids;
@ -321,7 +318,7 @@ public class TestZooKeeperNodeTracker {
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(), ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
"testNodeTracker", new TestZooKeeperNodeTracker.StubAbortable()); "testNodeTracker", new TestZooKeeperNodeTracker.StubAbortable());
final ServerName sn = new ServerName("127.0.0.1:52",45L); final ServerName sn = ServerName.valueOf("127.0.0.1:52", 45L);
ZKUtil.createAndFailSilent(zkw, ZKUtil.createAndFailSilent(zkw,
TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT, TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT,
@ -336,7 +333,7 @@ public class TestZooKeeperNodeTracker {
// Check that we don't delete if we're not supposed to // Check that we don't delete if we're not supposed to
ZKUtil.setData(zkw, nodeName, MasterAddressTracker.toByteArray(sn)); ZKUtil.setData(zkw, nodeName, MasterAddressTracker.toByteArray(sn));
MasterAddressTracker.deleteIfEquals(zkw, new ServerName("127.0.0.2:52",45L).toString()); MasterAddressTracker.deleteIfEquals(zkw, ServerName.valueOf("127.0.0.2:52", 45L).toString());
Assert.assertFalse(ZKUtil.getData(zkw, nodeName) == null); Assert.assertFalse(ZKUtil.getData(zkw, nodeName) == null);
// Check that we delete when we're supposed to // Check that we delete when we're supposed to