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:
parent
d9b983bb5e
commit
bc7c3c7daa
|
@ -1041,7 +1041,7 @@ public class HRegionInfo implements Comparable<HRegionInfo> {
|
|||
cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,
|
||||
HConstants.STARTCODE_QUALIFIER);
|
||||
if (cell == null || cell.getValueLength() == 0) return null;
|
||||
return new ServerName(hostAndPort,
|
||||
return ServerName.valueOf(hostAndPort,
|
||||
Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
private byte [] bytes;
|
||||
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
|
||||
// unwieldy names.
|
||||
this.hostnameOnly = hostname;
|
||||
|
@ -116,12 +116,12 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
return parts[0];
|
||||
}
|
||||
|
||||
public ServerName(final String serverName) {
|
||||
private ServerName(final String serverName) {
|
||||
this(parseHostname(serverName), parsePort(serverName),
|
||||
parseStartcode(serverName));
|
||||
}
|
||||
|
||||
public ServerName(final String hostAndPort, final long startCode) {
|
||||
private ServerName(final String hostAndPort, final long startCode) {
|
||||
this(Addressing.parseHostname(hostAndPort),
|
||||
Addressing.parsePort(hostAndPort), startCode);
|
||||
}
|
||||
|
@ -147,6 +147,18 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
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
|
||||
public String toString() {
|
||||
return getServerName();
|
||||
|
@ -301,11 +313,11 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
short version = Bytes.toShort(versionedBytes);
|
||||
if (version == VERSION) {
|
||||
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
|
||||
// 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.
|
||||
*/
|
||||
public static ServerName parseServerName(final String str) {
|
||||
return SERVERNAME_PATTERN.matcher(str).matches()? new ServerName(str):
|
||||
new ServerName(str, NON_STARTCODE);
|
||||
return SERVERNAME_PATTERN.matcher(str).matches()? valueOf(str) :
|
||||
valueOf(str, NON_STARTCODE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -346,7 +358,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
MetaRegionServer rss =
|
||||
MetaRegionServer.PARSER.parseFrom(data, prefixLen, data.length - prefixLen);
|
||||
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) {
|
||||
// A failed parse of the znode is pretty catastrophic. Rather than loop
|
||||
// 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.
|
||||
String hostname = Addressing.parseHostname(str);
|
||||
int port = Addressing.parsePort(str);
|
||||
return new ServerName(hostname, port, -1L);
|
||||
return valueOf(hostname, port, -1L);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1324,7 +1324,7 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
if (pair == null || pair.getFirst() == null) {
|
||||
throw new UnknownRegionException(Bytes.toStringBinary(regionname));
|
||||
} else {
|
||||
closeRegion(new ServerName(serverName), pair.getFirst());
|
||||
closeRegion(ServerName.valueOf(serverName), pair.getFirst());
|
||||
}
|
||||
} else {
|
||||
Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, regionname);
|
||||
|
@ -1368,7 +1368,7 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
throw new IllegalArgumentException(
|
||||
"The servername cannot be null or empty.");
|
||||
}
|
||||
ServerName sn = new ServerName(serverName);
|
||||
ServerName sn = ServerName.valueOf(serverName);
|
||||
AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
|
||||
// Close the region without updating zk state.
|
||||
CloseRegionRequest request =
|
||||
|
@ -2126,7 +2126,7 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
String hostname = Addressing.parseHostname(hostnamePort);
|
||||
int port = Addressing.parsePort(hostnamePort);
|
||||
AdminService.BlockingInterface admin =
|
||||
this.connection.getAdmin(new ServerName(hostname, port, 0));
|
||||
this.connection.getAdmin(ServerName.valueOf(hostname, port, 0));
|
||||
StopServerRequest request = RequestConverter.buildStopServerRequest(
|
||||
"Called by admin client " + this.connection.toString());
|
||||
try {
|
||||
|
@ -2426,7 +2426,7 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
*/
|
||||
public synchronized byte[][] rollHLogWriter(String serverName)
|
||||
throws IOException, FailedLogCloseException {
|
||||
ServerName sn = new ServerName(serverName);
|
||||
ServerName sn = ServerName.valueOf(serverName);
|
||||
AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
|
||||
RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest();
|
||||
try {
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.hadoop.classification.InterfaceStability;
|
|||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.NotServingRegionException;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.ipc.RemoteException;
|
||||
|
||||
/**
|
||||
* Subclass if the server knows the region is now on another server.
|
||||
|
@ -63,7 +62,7 @@ public class RegionMovedException extends NotServingRegionException {
|
|||
}
|
||||
|
||||
public ServerName getServerName(){
|
||||
return new ServerName(hostname, port, startCode);
|
||||
return ServerName.valueOf(hostname, port, startCode);
|
||||
}
|
||||
|
||||
public long getLocationSeqNum() {
|
||||
|
|
|
@ -321,7 +321,7 @@ public final class ProtobufUtil {
|
|||
if (proto.hasStartCode()) {
|
||||
startCode = proto.getStartCode();
|
||||
}
|
||||
return new ServerName(hostName, port, startCode);
|
||||
return ServerName.valueOf(hostName, port, startCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
|
|||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
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.Append;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
|
@ -996,7 +995,7 @@ public final class RequestConverter {
|
|||
buildRegionSpecifier(RegionSpecifierType.ENCODED_REGION_NAME,encodedRegionName));
|
||||
if (destServerName != null) {
|
||||
builder.setDestServerName(
|
||||
ProtobufUtil.toServerName(new ServerName(Bytes.toString(destServerName))));
|
||||
ProtobufUtil.toServerName(ServerName.valueOf(Bytes.toString(destServerName))));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ public class TestAsyncProcess {
|
|||
private static final byte[] FAILS = "FAILS".getBytes();
|
||||
private static final Configuration conf = new Configuration();
|
||||
|
||||
private static ServerName sn = new ServerName("localhost:10,1254");
|
||||
private static ServerName sn2 = new ServerName("localhost:140,12540");
|
||||
private static ServerName sn = ServerName.valueOf("localhost:10,1254");
|
||||
private static ServerName sn2 = ServerName.valueOf("localhost:140,12540");
|
||||
private static HRegionInfo hri1 =
|
||||
new HRegionInfo(DUMMY_TABLE, DUMMY_BYTES_1, DUMMY_BYTES_2, false, 1);
|
||||
private static HRegionInfo hri2 =
|
||||
|
|
|
@ -95,7 +95,7 @@ public class TestClientNoCluster extends Configured implements Tool {
|
|||
private static final Log LOG = LogFactory.getLog(TestClientNoCluster.class);
|
||||
private Configuration conf;
|
||||
public static final ServerName META_SERVERNAME =
|
||||
new ServerName("meta.example.org", 60010, 12345);
|
||||
ServerName.valueOf("meta.example.org", 60010, 12345);
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -651,7 +651,7 @@ public class TestClientNoCluster extends Configured implements Tool {
|
|||
private static ServerName [] makeServerNames(final int count) {
|
||||
ServerName [] sns = new ServerName[count];
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class RollingBatchRestartRsAction extends BatchRestartRsAction {
|
|||
final int count = 4;
|
||||
List<ServerName> serverNames = new ArrayList<ServerName>(count);
|
||||
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 [] {});
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ import com.google.common.collect.LinkedHashMultimap;
|
|||
public class AssignmentManager extends ZooKeeperListener {
|
||||
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);
|
||||
|
||||
public static final String ASSIGNMENT_TIMEOUT = "hbase.master.assignment.timeoutmonitor.timeout";
|
||||
|
|
|
@ -440,7 +440,7 @@ MasterServices, Server {
|
|||
// Set our address.
|
||||
this.isa = this.rpcServer.getListenerAddress();
|
||||
// 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(
|
||||
conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024));
|
||||
|
||||
|
@ -1699,7 +1699,7 @@ MasterServices, Server {
|
|||
regionState.getServerName());
|
||||
dest = balancer.randomAssignment(hri, destServers);
|
||||
} else {
|
||||
dest = new ServerName(Bytes.toString(destServerName));
|
||||
dest = ServerName.valueOf(Bytes.toString(destServerName));
|
||||
if (dest.equals(regionState.getServerName())) {
|
||||
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
|
||||
+ " because region already assigned to the same server " + dest + ".");
|
||||
|
|
|
@ -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.protobuf.ProtobufUtil;
|
||||
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.UpdateFavoredNodesRequest;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse;
|
||||
|
@ -401,15 +400,15 @@ public class RegionPlacementMaintainer {
|
|||
List<ServerName> favoredServers =
|
||||
new ArrayList<ServerName>(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM);
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
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));
|
||||
// Update the assignment plan
|
||||
plan.updateAssignmentPlan(regions.get(i), favoredServers);
|
||||
|
@ -434,17 +433,17 @@ public class RegionPlacementMaintainer {
|
|||
new ArrayList<ServerName>(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM);
|
||||
HRegionInfo currentRegion = regions.get(i);
|
||||
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[] secondaryAndTertiary =
|
||||
secondaryAndTertiaryMap.get(currentRegion);
|
||||
s = secondaryAndTertiary[0];
|
||||
favoredServers.add(new ServerName(s.getHostname(), s.getPort(),
|
||||
favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
|
||||
ServerName.NON_STARTCODE));
|
||||
|
||||
s = secondaryAndTertiary[1];
|
||||
favoredServers.add(new ServerName(s.getHostname(), s.getPort(),
|
||||
favoredServers.add(ServerName.valueOf(s.getHostname(), s.getPort(),
|
||||
ServerName.NON_STARTCODE));
|
||||
// Update the assignment plan
|
||||
plan.updateAssignmentPlan(regions.get(i), favoredServers);
|
||||
|
@ -943,7 +942,7 @@ public class RegionPlacementMaintainer {
|
|||
|
||||
List<ServerName> serverList = new ArrayList<ServerName>();
|
||||
for (String hostNameAndPort : favoredNodesArray) {
|
||||
serverList.add(new ServerName(hostNameAndPort, ServerName.NON_STARTCODE));
|
||||
serverList.add(ServerName.valueOf(hostNameAndPort, ServerName.NON_STARTCODE));
|
||||
}
|
||||
return serverList;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ public class ServerManager {
|
|||
// is, reject the server and trigger its expiration. The next time it comes
|
||||
// in, it should have been removed from serverAddressToServerInfo and queued
|
||||
// for processing by ProcessServerShutdown.
|
||||
ServerName sn = new ServerName(ia.getHostName(), port, serverStartcode);
|
||||
ServerName sn = ServerName.valueOf(ia.getHostName(), port, serverStartcode);
|
||||
checkClockSkew(sn, serverCurrentTime);
|
||||
checkIsDead(sn, "STARTUP");
|
||||
if (!checkAlreadySameHostPortAndRecordNewServer(
|
||||
|
|
|
@ -88,14 +88,14 @@ public class FavoredNodeLoadBalancer extends BaseLoadBalancer {
|
|||
new HashMap<ServerName, ServerName>();
|
||||
ServerManager serverMgr = super.services.getServerManager();
|
||||
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);
|
||||
serverNameWithoutCodeToServerName.put(s, sn);
|
||||
}
|
||||
for (Map.Entry<ServerName, List<HRegionInfo>> entry : clusterState.entrySet()) {
|
||||
ServerName currentServer = entry.getKey();
|
||||
//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);
|
||||
List<HRegionInfo> list = entry.getValue();
|
||||
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
|
||||
List<ServerName> favoredNodesForRegion = new ArrayList<ServerName>(3);
|
||||
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[] secondaryAndTertiaryNodes = secondaryAndTertiaryRSMap.get(region);
|
||||
if (secondaryAndTertiaryNodes != null) {
|
||||
favoredNodesForRegion.add(new ServerName(secondaryAndTertiaryNodes[0].getHostname(),
|
||||
favoredNodesForRegion.add(ServerName.valueOf(secondaryAndTertiaryNodes[0].getHostname(),
|
||||
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));
|
||||
}
|
||||
globalFavoredNodesAssignmentPlan.updateFavoredNodesMap(region, favoredNodesForRegion);
|
||||
|
|
|
@ -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());
|
||||
HLog metaHLog = HLogFactory.createMetaHLog(fs, rootDir,
|
||||
metaLogName, conf, null,
|
||||
|
|
|
@ -763,7 +763,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
this.abort("Failed to reach zk cluster when creating snapshot handler.");
|
||||
}
|
||||
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
|
||||
if(this.distributedLogReplay) {
|
||||
|
@ -1209,7 +1209,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
// The hostname the master sees us as.
|
||||
if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
|
||||
String hostnameFromMasterPOV = e.getValue();
|
||||
this.serverNameFromMasterPOV = new ServerName(hostnameFromMasterPOV,
|
||||
this.serverNameFromMasterPOV = ServerName.valueOf(hostnameFromMasterPOV,
|
||||
this.isa.getPort(), this.startcode);
|
||||
if (!hostnameFromMasterPOV.equals(this.isa.getHostName())) {
|
||||
LOG.info("Master passed us a different hostname to use; was=" +
|
||||
|
@ -2236,7 +2236,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
public ServerName getServerName() {
|
||||
// Our servername could change after we talk to the master.
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class DrainingServerTracker extends ZooKeeperListener {
|
|||
synchronized(this.drainingServers) {
|
||||
this.drainingServers.clear();
|
||||
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.serverManager.addServerToDrainList(sn);
|
||||
LOG.info("Draining RS node created, adding to list [" +
|
||||
|
@ -97,7 +97,7 @@ public class DrainingServerTracker extends ZooKeeperListener {
|
|||
@Override
|
||||
public void nodeDeleted(final String path) {
|
||||
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 [" +
|
||||
sn + "]");
|
||||
remove(sn);
|
||||
|
|
|
@ -89,8 +89,8 @@ public class TestDrainingServer {
|
|||
final HMaster master = Mockito.mock(HMaster.class);
|
||||
final Server server = Mockito.mock(Server.class);
|
||||
final ServerManager serverManager = Mockito.mock(ServerManager.class);
|
||||
final ServerName SERVERNAME_A = new ServerName("mockserver_a.org", 1000, 8000);
|
||||
final ServerName SERVERNAME_B = new ServerName("mockserver_b.org", 1001, 8000);
|
||||
final ServerName SERVERNAME_A = ServerName.valueOf("mockserver_a.org", 1000, 8000);
|
||||
final ServerName SERVERNAME_B = ServerName.valueOf("mockserver_b.org", 1001, 8000);
|
||||
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(conf);
|
||||
CatalogTracker catalogTracker = Mockito.mock(CatalogTracker.class);
|
||||
final HRegionInfo REGIONINFO = new HRegionInfo(TableName.valueOf("table_test"),
|
||||
|
@ -105,7 +105,7 @@ public class TestDrainingServer {
|
|||
onlineServers.put(SERVERNAME_B, ServerLoad.EMPTY_SERVERLOAD);
|
||||
|
||||
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(serverManager.getOnlineServers()).thenReturn(onlineServers);
|
||||
|
@ -163,11 +163,11 @@ public class TestDrainingServer {
|
|||
final HMaster master = Mockito.mock(HMaster.class);
|
||||
final Server server = Mockito.mock(Server.class);
|
||||
final ServerManager serverManager = Mockito.mock(ServerManager.class);
|
||||
final ServerName SERVERNAME_A = new ServerName("mockserverbulk_a.org", 1000, 8000);
|
||||
final ServerName SERVERNAME_B = new ServerName("mockserverbulk_b.org", 1001, 8000);
|
||||
final ServerName SERVERNAME_C = new ServerName("mockserverbulk_c.org", 1002, 8000);
|
||||
final ServerName SERVERNAME_D = new ServerName("mockserverbulk_d.org", 1003, 8000);
|
||||
final ServerName SERVERNAME_E = new ServerName("mockserverbulk_e.org", 1004, 8000);
|
||||
final ServerName SERVERNAME_A = ServerName.valueOf("mockserverbulk_a.org", 1000, 8000);
|
||||
final ServerName SERVERNAME_B = ServerName.valueOf("mockserverbulk_b.org", 1001, 8000);
|
||||
final ServerName SERVERNAME_C = ServerName.valueOf("mockserverbulk_c.org", 1002, 8000);
|
||||
final ServerName SERVERNAME_D = ServerName.valueOf("mockserverbulk_d.org", 1003, 8000);
|
||||
final ServerName SERVERNAME_E = ServerName.valueOf("mockserverbulk_e.org", 1004, 8000);
|
||||
final Map<HRegionInfo, ServerName> bulk = new HashMap<HRegionInfo, ServerName>();
|
||||
|
||||
Set<ServerName> bunchServersAssigned = new HashSet<ServerName>();
|
||||
|
@ -202,7 +202,7 @@ public class TestDrainingServer {
|
|||
"zkWatcher-BulkAssignTest", abortable, true);
|
||||
|
||||
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(serverManager.getOnlineServers()).thenReturn(onlineServers);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class TestHRegionLocation {
|
|||
*/
|
||||
@Test
|
||||
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 hrl2 = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1);
|
||||
assertEquals(hrl1.hashCode(), hrl2.hashCode());
|
||||
|
@ -45,7 +45,7 @@ public class TestHRegionLocation {
|
|||
// They are equal because they have same location even though they are
|
||||
// carrying different regions or timestamp.
|
||||
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);
|
||||
// These have same HRI but different locations so should be different.
|
||||
assertFalse(hrl3.equals(hrl4));
|
||||
|
@ -56,17 +56,17 @@ public class TestHRegionLocation {
|
|||
|
||||
@Test
|
||||
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);
|
||||
System.out.println(hrl1.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareTo() {
|
||||
ServerName hsa1 = new ServerName("localhost", 1234, -1L);
|
||||
ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L);
|
||||
HRegionLocation hsl1 =
|
||||
new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa1);
|
||||
ServerName hsa2 = new ServerName("localhost", 1235, -1L);
|
||||
ServerName hsa2 = ServerName.valueOf("localhost", 1235, -1L);
|
||||
HRegionLocation hsl2 =
|
||||
new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2);
|
||||
assertTrue(hsl1.compareTo(hsl1) == 0);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class TestSerialization {
|
|||
|
||||
@Test
|
||||
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();
|
||||
SplitLogTask sltDeserialized = SplitLogTask.parseFrom(bytes);
|
||||
assertTrue(slt.equals(sltDeserialized));
|
||||
|
|
|
@ -41,17 +41,17 @@ public class TestServerName {
|
|||
assertEquals("x", ServerName.getHostNameMinusDomain("x"));
|
||||
assertEquals("x", ServerName.getHostNameMinusDomain("x.y.z"));
|
||||
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());
|
||||
}
|
||||
|
||||
@Test
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class TestServerName {
|
|||
|
||||
@Test public void testParseOfBytes() {
|
||||
final String snStr = "www.example.org,1234,5678";
|
||||
ServerName sn = new ServerName(snStr);
|
||||
ServerName sn = ServerName.valueOf(snStr);
|
||||
byte [] versionedBytes = sn.getVersionedBytes();
|
||||
assertEquals(sn.toString(), ServerName.parseVersionedServerName(versionedBytes).toString());
|
||||
final String hostnamePortStr = sn.getHostAndPort();
|
||||
|
@ -81,9 +81,9 @@ public class TestServerName {
|
|||
|
||||
@Test
|
||||
public void testServerName() {
|
||||
ServerName sn = new ServerName("www.example.org", 1234, 5678);
|
||||
ServerName sn2 = new ServerName("www.example.org", 1234, 5678);
|
||||
ServerName sn3 = new ServerName("www.example.org", 1234, 56789);
|
||||
ServerName sn = ServerName.valueOf("www.example.org", 1234, 5678);
|
||||
ServerName sn2 = ServerName.valueOf("www.example.org", 1234, 5678);
|
||||
ServerName sn3 = ServerName.valueOf("www.example.org", 1234, 56789);
|
||||
assertTrue(sn.equals(sn2));
|
||||
assertFalse(sn.equals(sn3));
|
||||
assertEquals(sn.hashCode(), sn2.hashCode());
|
||||
|
@ -99,7 +99,7 @@ public class TestServerName {
|
|||
|
||||
@Test
|
||||
public void getServerStartcodeFromServerName() {
|
||||
ServerName sn = new ServerName("www.example.org", 1234, 5678);
|
||||
ServerName sn = ServerName.valueOf("www.example.org", 1234, 5678);
|
||||
assertEquals(5678,
|
||||
ServerName.getServerStartcodeFromServerName(sn.toString()));
|
||||
assertNotSame(5677,
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TestCatalogTracker {
|
|||
private static final Log LOG = LogFactory.getLog(TestCatalogTracker.class);
|
||||
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
||||
private static final ServerName SN =
|
||||
new ServerName("example.org", 1234, System.currentTimeMillis());
|
||||
ServerName.valueOf("example.org", 1234, System.currentTimeMillis());
|
||||
private ZooKeeperWatcher watcher;
|
||||
private Abortable abortable;
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class TestCatalogTracker {
|
|||
constructAndStartCatalogTracker(connection);
|
||||
|
||||
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);
|
||||
|
||||
MetaRegionTracker.setMetaLocation(this.watcher,
|
||||
new ServerName("example.com", 1234, System.currentTimeMillis()));
|
||||
ServerName.valueOf("example.com", 1234, System.currentTimeMillis()));
|
||||
Assert.assertFalse(ct.verifyMetaRegionLocation(100));
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class TestMetaReaderEditorNoCluster {
|
|||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(),
|
||||
this.getClass().getSimpleName(), ABORTABLE, true);
|
||||
// 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;
|
||||
CatalogTracker ct = null;
|
||||
|
|
|
@ -361,7 +361,7 @@ public class TestHCM {
|
|||
|
||||
final int nextPort = conn.getCachedLocation(TABLE_NAME, ROW).getPort() + 1;
|
||||
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);
|
||||
Assert.assertEquals(conn.getCachedLocation(TABLE_NAME, ROW).getPort(), nextPort);
|
||||
|
||||
|
@ -553,34 +553,34 @@ public class TestHCM {
|
|||
HRegionLocation location = conn.getCachedLocation(TABLE_NAME2, ROW);
|
||||
assertNotNull(location);
|
||||
|
||||
HRegionLocation anySource = new HRegionLocation(location.getRegionInfo(), new ServerName(
|
||||
HRegionLocation anySource = new HRegionLocation(location.getRegionInfo(), ServerName.valueOf(
|
||||
location.getHostname(), location.getPort() - 1, 0L));
|
||||
|
||||
// Same server as already in cache reporting - overwrites any value despite seqNum.
|
||||
int nextPort = location.getPort() + 1;
|
||||
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);
|
||||
Assert.assertEquals(nextPort, location.getPort());
|
||||
|
||||
// No source specified - same.
|
||||
nextPort = location.getPort() + 1;
|
||||
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);
|
||||
Assert.assertEquals(nextPort, location.getPort());
|
||||
|
||||
// Higher seqNum - overwrites lower seqNum.
|
||||
nextPort = location.getPort() + 1;
|
||||
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);
|
||||
Assert.assertEquals(nextPort, location.getPort());
|
||||
|
||||
// Lower seqNum - does not overwrite higher seqNum.
|
||||
nextPort = location.getPort() + 1;
|
||||
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);
|
||||
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.
|
||||
final long ANY_PAUSE = 100;
|
||||
HRegionInfo ri = new HRegionInfo(TABLE_NAME);
|
||||
HRegionLocation location = new HRegionLocation(ri, new ServerName("127.0.0.1", 1, 0));
|
||||
HRegionLocation diffLocation = new HRegionLocation(ri, new ServerName("127.0.0.1", 2, 0));
|
||||
HRegionLocation location = new HRegionLocation(ri, ServerName.valueOf("127.0.0.1", 1, 0));
|
||||
HRegionLocation diffLocation = new HRegionLocation(ri, ServerName.valueOf("127.0.0.1", 2, 0));
|
||||
|
||||
ManualEnvironmentEdge timeMachine = new ManualEnvironmentEdge();
|
||||
EnvironmentEdgeManager.injectEdge(timeMachine);
|
||||
|
|
|
@ -169,7 +169,7 @@ public class TestMetaScanner {
|
|||
Bytes.toBytes(midKey),
|
||||
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));
|
||||
} catch (Throwable e) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class TestDelayedRpc {
|
|||
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
|
||||
try {
|
||||
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
|
||||
new ServerName(rpcServer.getListenerAddress().getHostName(),
|
||||
ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
|
||||
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
|
||||
User.getCurrent(), RPC_CLIENT_TIMEOUT);
|
||||
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
|
||||
|
@ -172,7 +172,7 @@ public class TestDelayedRpc {
|
|||
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
|
||||
try {
|
||||
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
|
||||
new ServerName(rpcServer.getListenerAddress().getHostName(),
|
||||
ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
|
||||
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
|
||||
User.getCurrent(), RPC_CLIENT_TIMEOUT);
|
||||
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
|
||||
|
@ -295,7 +295,7 @@ public class TestDelayedRpc {
|
|||
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
|
||||
try {
|
||||
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
|
||||
new ServerName(rpcServer.getListenerAddress().getHostName(),
|
||||
ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
|
||||
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
|
||||
User.getCurrent(), 1000);
|
||||
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
|
||||
|
|
|
@ -114,7 +114,7 @@ public class TestProtoBufRpc {
|
|||
RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT);
|
||||
try {
|
||||
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);
|
||||
TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
|
||||
TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
|
||||
|
|
|
@ -274,7 +274,7 @@ public class TestLoadIncrementalHFilesSplitRecovery {
|
|||
Mockito.doNothing().when(c).close();
|
||||
// Make it so we return a particular location when asked.
|
||||
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(),
|
||||
(byte[]) Mockito.any(), Mockito.anyBoolean())).
|
||||
thenReturn(loc);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TestActiveMasterManager {
|
|||
} catch(KeeperException.NoNodeException nne) {}
|
||||
|
||||
// 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
|
||||
DummyMaster dummyMaster = new DummyMaster(zk,master);
|
||||
ClusterStatusTracker clusterStatusTracker =
|
||||
|
@ -116,9 +116,9 @@ public class TestActiveMasterManager {
|
|||
|
||||
// Create the master node with a dummy address
|
||||
ServerName firstMasterAddress =
|
||||
new ServerName("localhost", 1, System.currentTimeMillis());
|
||||
ServerName.valueOf("localhost", 1, System.currentTimeMillis());
|
||||
ServerName secondMasterAddress =
|
||||
new ServerName("localhost", 2, System.currentTimeMillis());
|
||||
ServerName.valueOf("localhost", 2, System.currentTimeMillis());
|
||||
|
||||
// Should not have a master yet
|
||||
DummyMaster ms1 = new DummyMaster(zk,firstMasterAddress);
|
||||
|
|
|
@ -100,9 +100,9 @@ import com.google.protobuf.ServiceException;
|
|||
public class TestAssignmentManager {
|
||||
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
|
||||
private static final ServerName SERVERNAME_A =
|
||||
new ServerName("example.org", 1234, 5678);
|
||||
ServerName.valueOf("example.org", 1234, 5678);
|
||||
private static final ServerName SERVERNAME_B =
|
||||
new ServerName("example.org", 0, 5678);
|
||||
ServerName.valueOf("example.org", 0, 5678);
|
||||
private static final HRegionInfo REGIONINFO =
|
||||
new HRegionInfo(TableName.valueOf("t"),
|
||||
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
|
||||
// silently as is mockito default).
|
||||
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());
|
||||
this.watcher =
|
||||
new ZooKeeperWatcher(HTU.getConfiguration(), "mockedServer", this.server, true);
|
||||
|
|
|
@ -158,7 +158,7 @@ public class TestAssignmentManagerOnCluster {
|
|||
ServerName destServer = onlineServers.iterator().next();
|
||||
|
||||
// Created faked dead server
|
||||
deadServer = new ServerName(destServer.getHostname(),
|
||||
deadServer = ServerName.valueOf(destServer.getHostname(),
|
||||
destServer.getPort(), destServer.getStartcode() - 100L);
|
||||
master.serverManager.recordNewServer(deadServer, ServerLoad.EMPTY_SERVERLOAD);
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public class TestCatalogJanitor {
|
|||
this.connection =
|
||||
HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
|
||||
Mockito.mock(AdminProtos.AdminService.BlockingInterface.class), ri,
|
||||
new ServerName("example.org,12345,6789"),
|
||||
ServerName.valueOf("example.org,12345,6789"),
|
||||
HRegionInfo.FIRST_META_REGIONINFO);
|
||||
// Set hbase.rootdir into test dir.
|
||||
FileSystem fs = FileSystem.get(this.c);
|
||||
|
@ -136,7 +136,7 @@ public class TestCatalogJanitor {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName("mockserver.example.org", 1234, -1L);
|
||||
return ServerName.valueOf("mockserver.example.org", 1234, -1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TestClusterStatusPublisher {
|
|||
List<Pair<ServerName, Long>> res = new ArrayList<Pair<ServerName, Long>>();
|
||||
switch ((int) EnvironmentEdgeManager.currentTimeMillis()) {
|
||||
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;
|
||||
case 1000:
|
||||
break;
|
||||
|
@ -88,7 +88,7 @@ public class TestClusterStatusPublisher {
|
|||
protected List<Pair<ServerName, Long>> getDeadServers(long since) {
|
||||
List<Pair<ServerName, Long>> res = new ArrayList<Pair<ServerName, Long>>();
|
||||
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;
|
||||
|
|
|
@ -34,10 +34,10 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
@Category(MediumTests.class)
|
||||
public class TestDeadServer {
|
||||
final ServerName hostname123 = new ServerName("127.0.0.1", 123, 3L);
|
||||
final ServerName hostname123_2 = new ServerName("127.0.0.1", 123, 4L);
|
||||
final ServerName hostname1234 = new ServerName("127.0.0.2", 1234, 4L);
|
||||
final ServerName hostname12345 = new ServerName("127.0.0.2", 12345, 4L);
|
||||
final ServerName hostname123 = ServerName.valueOf("127.0.0.1", 123, 3L);
|
||||
final ServerName hostname123_2 = ServerName.valueOf("127.0.0.1", 123, 4L);
|
||||
final ServerName hostname1234 = ServerName.valueOf("127.0.0.2", 1234, 4L);
|
||||
final ServerName hostname12345 = ServerName.valueOf("127.0.0.2", 12345, 4L);
|
||||
|
||||
@Test public void testIsDead() {
|
||||
DeadServer ds = new DeadServer();
|
||||
|
@ -59,7 +59,7 @@ public class TestDeadServer {
|
|||
// Already dead = 127.0.0.1,9090,112321
|
||||
// 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));
|
||||
ds.add(deadServer);
|
||||
assertTrue(ds.isDeadServer(deadServer));
|
||||
|
@ -68,7 +68,7 @@ public class TestDeadServer {
|
|||
Assert.assertNotNull(ds.getTimeOfDeath(eachDeadServer));
|
||||
}
|
||||
final ServerName deadServerHostComingAlive =
|
||||
new ServerName("127.0.0.1", 9090, 223341L);
|
||||
ServerName.valueOf("127.0.0.1", 9090, 223341L);
|
||||
assertTrue(ds.cleanPreviousInstance(deadServerHostComingAlive));
|
||||
assertFalse(ds.isDeadServer(deadServer));
|
||||
assertFalse(ds.cleanPreviousInstance(deadServerHostComingAlive));
|
||||
|
|
|
@ -26,13 +26,11 @@ import java.util.Set;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.MediumTests;
|
||||
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.SplitLogTask;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
|
@ -89,8 +87,8 @@ public class TestMasterFileSystem {
|
|||
|
||||
String failedRegion = "failedRegoin1";
|
||||
String staleRegion = "staleRegion";
|
||||
ServerName inRecoveryServerName = new ServerName("mgr,1,1");
|
||||
ServerName previouselyFaildServerName = new ServerName("previous,1,1");
|
||||
ServerName inRecoveryServerName = ServerName.valueOf("mgr,1,1");
|
||||
ServerName previouselyFaildServerName = ServerName.valueOf("previous,1,1");
|
||||
String walPath = "/hbase/data/.logs/" + inRecoveryServerName.getServerName()
|
||||
+ "-splitting/test";
|
||||
// Create a ZKW to use in the test
|
||||
|
|
|
@ -144,9 +144,9 @@ public class TestMasterNoCluster {
|
|||
final long now = System.currentTimeMillis();
|
||||
// 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.
|
||||
final ServerName sn0 = new ServerName("0.example.org", 0, now);
|
||||
final ServerName sn1 = new ServerName("1.example.org", 1, now);
|
||||
final ServerName sn2 = new ServerName("2.example.org", 2, now);
|
||||
final ServerName sn0 = ServerName.valueOf("0.example.org", 0, now);
|
||||
final ServerName sn1 = ServerName.valueOf("1.example.org", 1, now);
|
||||
final ServerName sn2 = ServerName.valueOf("2.example.org", 2, now);
|
||||
final ServerName [] sns = new ServerName [] {sn0, sn1, sn2};
|
||||
// Put up the mock servers
|
||||
final Configuration conf = TESTUTIL.getConfiguration();
|
||||
|
@ -256,7 +256,7 @@ public class TestMasterNoCluster {
|
|||
|
||||
final long now = System.currentTimeMillis();
|
||||
// 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
|
||||
// master next.
|
||||
final MockRegionServer rs0 = new MockRegionServer(conf, sn);
|
||||
|
@ -357,8 +357,8 @@ public class TestMasterNoCluster {
|
|||
public void testNotPullingDeadRegionServerFromZK()
|
||||
throws IOException, KeeperException, InterruptedException {
|
||||
final Configuration conf = TESTUTIL.getConfiguration();
|
||||
final ServerName newServer = new ServerName("test.sample", 1, 101);
|
||||
final ServerName deadServer = new ServerName("test.sample", 1, 100);
|
||||
final ServerName newServer = ServerName.valueOf("test.sample", 1, 101);
|
||||
final ServerName deadServer = ServerName.valueOf("test.sample", 1, 100);
|
||||
final MockRegionServer rs0 = new MockRegionServer(conf, newServer);
|
||||
|
||||
HMaster master = new HMaster(conf) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class TestMasterStatusServlet {
|
|||
private HBaseAdmin admin;
|
||||
|
||||
static final ServerName FAKE_HOST =
|
||||
new ServerName("fakehost", 12345, 1234567890);
|
||||
ServerName.valueOf("fakehost", 12345, 1234567890);
|
||||
static final HTableDescriptor FAKE_TABLE =
|
||||
new HTableDescriptor(TableName.valueOf("mytable"));
|
||||
static final HRegionInfo FAKE_HRI =
|
||||
|
@ -124,7 +124,7 @@ public class TestMasterStatusServlet {
|
|||
setupMockTables();
|
||||
|
||||
new MasterStatusTmpl()
|
||||
.setMetaLocation(new ServerName("metaserver:123,12345"))
|
||||
.setMetaLocation(ServerName.valueOf("metaserver:123,12345"))
|
||||
.render(new StringWriter(),
|
||||
master, admin);
|
||||
}
|
||||
|
@ -134,16 +134,16 @@ public class TestMasterStatusServlet {
|
|||
setupMockTables();
|
||||
|
||||
List<ServerName> servers = Lists.newArrayList(
|
||||
new ServerName("rootserver:123,12345"),
|
||||
new ServerName("metaserver:123,12345"));
|
||||
ServerName.valueOf("rootserver:123,12345"),
|
||||
ServerName.valueOf("metaserver:123,12345"));
|
||||
Set<ServerName> deadServers = new HashSet<ServerName>(
|
||||
Lists.newArrayList(
|
||||
new ServerName("badserver:123,12345"),
|
||||
new ServerName("uglyserver:123,12345"))
|
||||
ServerName.valueOf("badserver:123,12345"),
|
||||
ServerName.valueOf("uglyserver:123,12345"))
|
||||
);
|
||||
|
||||
new MasterStatusTmpl()
|
||||
.setMetaLocation(new ServerName("metaserver:123,12345"))
|
||||
.setMetaLocation(ServerName.valueOf("metaserver:123,12345"))
|
||||
.setServers(servers)
|
||||
.setDeadServers(deadServers)
|
||||
.render(new StringWriter(),
|
||||
|
|
|
@ -622,7 +622,7 @@ public class TestRegionPlacement {
|
|||
totalRegionNum.incrementAndGet();
|
||||
if (server != null) {
|
||||
ServerName serverName =
|
||||
new ServerName(Bytes.toString(server), -1);
|
||||
ServerName.valueOf(Bytes.toString(server), -1);
|
||||
if (favoredNodes != null) {
|
||||
String placement = "[NOT FAVORED NODE]";
|
||||
for (int i = 0; i < favoredServerList.length; i++) {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class TestRestartCluster {
|
|||
String unassignedZNode = zooKeeper.assignmentZNode;
|
||||
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);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ import org.mockito.Mockito;
|
|||
@Category(MediumTests.class)
|
||||
public class TestSplitLogManager {
|
||||
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 MasterServices master = Mockito.mock(MasterServices.class);
|
||||
|
||||
|
@ -271,9 +271,9 @@ public class TestSplitLogManager {
|
|||
|
||||
String tasknode = submitTaskAndWait(batch, "foo/1");
|
||||
int version = ZKUtil.checkExists(zkw, tasknode);
|
||||
final ServerName worker1 = new ServerName("worker1,1,1");
|
||||
final ServerName worker2 = new ServerName("worker2,1,1");
|
||||
final ServerName worker3 = new ServerName("worker3,1,1");
|
||||
final ServerName worker1 = ServerName.valueOf("worker1,1,1");
|
||||
final ServerName worker2 = ServerName.valueOf("worker2,1,1");
|
||||
final ServerName worker3 = ServerName.valueOf("worker3,1,1");
|
||||
SplitLogTask slt = new SplitLogTask.Owned(worker1);
|
||||
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
|
||||
waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
|
||||
|
@ -303,7 +303,7 @@ public class TestSplitLogManager {
|
|||
|
||||
String tasknode = submitTaskAndWait(batch, "foo/1");
|
||||
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);
|
||||
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
|
||||
waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
|
||||
|
@ -330,7 +330,7 @@ public class TestSplitLogManager {
|
|||
slm = new SplitLogManager(zkw, conf, stopper, master, DUMMY_MASTER);
|
||||
TaskBatch batch = new TaskBatch();
|
||||
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);
|
||||
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
|
||||
synchronized (batch) {
|
||||
|
@ -351,7 +351,7 @@ public class TestSplitLogManager {
|
|||
TaskBatch batch = new TaskBatch();
|
||||
|
||||
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);
|
||||
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
|
||||
|
||||
|
@ -374,7 +374,7 @@ public class TestSplitLogManager {
|
|||
TaskBatch batch = new TaskBatch();
|
||||
String tasknode = submitTaskAndWait(batch, "foo/1");
|
||||
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);
|
||||
SplitLogTask slt = new SplitLogTask.Resigned(worker1);
|
||||
assertEquals(tot_mgr_resubmit.get(), 0);
|
||||
|
@ -398,7 +398,7 @@ public class TestSplitLogManager {
|
|||
|
||||
// create an orphan task in OWNED state
|
||||
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);
|
||||
zkw.getRecoverableZooKeeper().create(tasknode1, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
|
||||
CreateMode.PERSISTENT);
|
||||
|
@ -413,7 +413,7 @@ public class TestSplitLogManager {
|
|||
// keep updating the orphan owned node every to/2 seconds
|
||||
for (int i = 0; i < (3 * to)/100; i++) {
|
||||
Thread.sleep(100);
|
||||
final ServerName worker2 = new ServerName("worker1,1,1");
|
||||
final ServerName worker2 = ServerName.valueOf("worker1,1,1");
|
||||
slt = new SplitLogTask.Owned(worker2);
|
||||
ZKUtil.setData(zkw, tasknode1, slt.toByteArray());
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class TestSplitLogManager {
|
|||
|
||||
String tasknode = submitTaskAndWait(batch, "foo/1");
|
||||
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);
|
||||
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
|
||||
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();
|
||||
|
||||
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);
|
||||
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
|
||||
|
|
|
@ -268,7 +268,7 @@ public class TestTableLockManager {
|
|||
@Test(timeout = 600000)
|
||||
public void testReapAllTableLocks() throws Exception {
|
||||
prepareMiniZkCluster();
|
||||
ServerName serverName = new ServerName("localhost:10000", 0);
|
||||
ServerName serverName = ServerName.valueOf("localhost:10000", 0);
|
||||
final TableLockManager lockManager = TableLockManager.createTableLockManager(
|
||||
TEST_UTIL.getConfiguration(), TEST_UTIL.getZooKeeperWatcher(), serverName);
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ public class BalancerTestBase {
|
|||
String host = "srv" + rand.nextInt(100000);
|
||||
int port = rand.nextInt(60000);
|
||||
long startCode = rand.nextLong();
|
||||
ServerName sn = new ServerName(host, port, startCode);
|
||||
ServerName sn = ServerName.valueOf(host, port, startCode);
|
||||
return new ServerAndLoad(sn, numRegionsPerServer);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase {
|
|||
// The old server would have had same host and port, but different
|
||||
// start code!
|
||||
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);
|
||||
}
|
||||
List<ServerName> listOfServerNames = getListOfServerNames(servers);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TestFavoredNodeAssignmentHelper {
|
|||
// Set up some server -> rack mappings
|
||||
// Have three racks in the cluster with 10 hosts each.
|
||||
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) {
|
||||
Mockito.when(rackManager.getRack(server)).thenReturn("rack1");
|
||||
if (rackToServers.get("rack1") == null) {
|
||||
|
|
|
@ -121,7 +121,7 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
|
|||
@Test
|
||||
public void testKeepRegionLoad() throws Exception {
|
||||
|
||||
ServerName sn = new ServerName("test:8080", 100);
|
||||
ServerName sn = ServerName.valueOf("test:8080", 100);
|
||||
int numClusterStatusToAdd = 20000;
|
||||
for (int i = 0; i < numClusterStatusToAdd; i++) {
|
||||
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 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));
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ public class TestHFileCleaner {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName("regionserver,60020,000000");
|
||||
return ServerName.valueOf("regionserver,60020,000000");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -151,7 +151,7 @@ public class TestHFileLinkCleaner {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName("regionserver,60020,000000");
|
||||
return ServerName.valueOf("regionserver,60020,000000");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.hadoop.fs.FileSystem;
|
|||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.*;
|
||||
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.ReplicationQueues;
|
||||
import org.apache.hadoop.hbase.replication.regionserver.Replication;
|
||||
|
@ -153,7 +152,7 @@ public class TestLogsCleaner {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName("regionserver,60020,000000");
|
||||
return ServerName.valueOf("regionserver,60020,000000");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -75,7 +75,7 @@ public class TestMasterAddressManager {
|
|||
// Create the master node with a dummy address
|
||||
String host = "localhost";
|
||||
int port = 1234;
|
||||
ServerName sn = new ServerName(host, port, System.currentTimeMillis());
|
||||
ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
|
||||
LOG.info("Creating master node");
|
||||
MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn);
|
||||
|
||||
|
|
|
@ -56,12 +56,12 @@ public class TestRSStatusServlet {
|
|||
static final int FAKE_WEB_PORT = 1586;
|
||||
|
||||
private final ServerName fakeServerName =
|
||||
new ServerName("localhost", FAKE_IPC_PORT, 11111);
|
||||
ServerName.valueOf("localhost", FAKE_IPC_PORT, 11111);
|
||||
private final GetServerInfoResponse fakeResponse =
|
||||
ResponseConverter.buildGetServerInfoResponse(fakeServerName, FAKE_WEB_PORT);
|
||||
|
||||
private final ServerName fakeMasterAddress =
|
||||
new ServerName("localhost", 60010, 1212121212);
|
||||
ServerName.valueOf("localhost", 60010, 1212121212);
|
||||
|
||||
@Before
|
||||
public void setupBasicMocks() throws IOException, ServiceException {
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.junit.experimental.categories.Category;
|
|||
@Category(MediumTests.class)
|
||||
public class TestSplitLogWorker {
|
||||
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 {
|
||||
Logger.getLogger("org.apache.hadoop.hbase").setLevel(Level.DEBUG);
|
||||
}
|
||||
|
@ -131,9 +131,9 @@ public class TestSplitLogWorker {
|
|||
LOG.info("testAcquireTaskAtStartup");
|
||||
SplitLogCounters.resetCounters();
|
||||
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),
|
||||
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);
|
||||
|
||||
SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), RS, neverEndingTask);
|
||||
|
@ -164,8 +164,8 @@ public class TestSplitLogWorker {
|
|||
LOG.info("testRaceForTask");
|
||||
SplitLogCounters.resetCounters();
|
||||
final String TRFT = "trft";
|
||||
final ServerName SVR1 = new ServerName("svr1,1,1");
|
||||
final ServerName SVR2 = new ServerName("svr2,1,1");
|
||||
final ServerName SVR1 = ServerName.valueOf("svr1,1,1");
|
||||
final ServerName SVR2 = ServerName.valueOf("svr2,1,1");
|
||||
zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, TRFT),
|
||||
new SplitLogTask.Unassigned(MANAGER).toByteArray(), Ids.OPEN_ACL_UNSAFE,
|
||||
CreateMode.PERSISTENT);
|
||||
|
@ -193,7 +193,7 @@ public class TestSplitLogWorker {
|
|||
public void testPreemptTask() throws Exception {
|
||||
LOG.info("testPreemptTask");
|
||||
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");
|
||||
SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask);
|
||||
slw.start();
|
||||
|
@ -224,7 +224,7 @@ public class TestSplitLogWorker {
|
|||
public void testMultipleTasks() throws Exception {
|
||||
LOG.info("testMultipleTasks");
|
||||
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");
|
||||
SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask);
|
||||
slw.start();
|
||||
|
@ -246,7 +246,7 @@ public class TestSplitLogWorker {
|
|||
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
|
||||
|
||||
// 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);
|
||||
ZKUtil.setData(zkw, PATH1, slt.toByteArray());
|
||||
waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, 1500);
|
||||
|
@ -265,7 +265,7 @@ public class TestSplitLogWorker {
|
|||
public void testRescan() throws Exception {
|
||||
LOG.info("testRescan");
|
||||
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.start();
|
||||
Thread.yield(); // let the worker start
|
||||
|
|
|
@ -419,7 +419,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int regionCount = ProtobufUtil.getOnlineRegions(server).size();
|
||||
// Insert into zk a blocking znode, a znode of same name as region
|
||||
// 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(),
|
||||
hri, fakedServer);
|
||||
// Now try splitting.... should fail. And each should successfully
|
||||
|
|
|
@ -23,11 +23,8 @@ import static org.junit.Assert.*;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.BindException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
@ -63,9 +60,6 @@ import org.junit.Before;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
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 */
|
||||
@Category(LargeTests.class)
|
||||
|
@ -716,7 +710,7 @@ public class TestHLog {
|
|||
|
||||
@Test
|
||||
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());
|
||||
|
||||
// Must not throw exception
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.replication;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
|
@ -29,7 +28,6 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -43,9 +41,9 @@ public abstract class TestReplicationStateBasic {
|
|||
protected ReplicationQueues rq2;
|
||||
protected ReplicationQueues rq3;
|
||||
protected ReplicationQueuesClient rqc;
|
||||
protected String server1 = new ServerName("hostname1.example.org", 1234, -1L).toString();
|
||||
protected String server2 = new ServerName("hostname2.example.org", 1234, -1L).toString();
|
||||
protected String server3 = new ServerName("hostname3.example.org", 1234, -1L).toString();
|
||||
protected String server1 = ServerName.valueOf("hostname1.example.org", 1234, -1L).toString();
|
||||
protected String server2 = ServerName.valueOf("hostname2.example.org", 1234, -1L).toString();
|
||||
protected String server3 = ServerName.valueOf("hostname3.example.org", 1234, -1L).toString();
|
||||
protected ReplicationPeers rp;
|
||||
protected static final String ID_ONE = "1";
|
||||
protected static final String ID_TWO = "2";
|
||||
|
@ -124,7 +122,7 @@ public abstract class TestReplicationStateBasic {
|
|||
assertNull(rq1.getAllQueues());
|
||||
assertEquals(0, rq1.getLogPosition("bogus", "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);
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName(this.serverName);
|
||||
return ServerName.valueOf(this.serverName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -224,7 +224,7 @@ public class TestReplicationTrackerZKImpl {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName(this.serverName);
|
||||
return ServerName.valueOf(this.serverName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -397,7 +397,7 @@ public class TestReplicationSourceManager {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName(hostname, 1234, 1L);
|
||||
return ServerName.valueOf(hostname, 1234, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TestSecureRPC {
|
|||
RpcClient rpcClient = new RpcClient(conf, HConstants.DEFAULT_CLUSTER_ID.toString());
|
||||
try {
|
||||
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
|
||||
new ServerName(rpcServer.getListenerAddress().getHostName(),
|
||||
ServerName.valueOf(rpcServer.getListenerAddress().getHostName(),
|
||||
rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
|
||||
User.getCurrent(), 1000);
|
||||
TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
|
||||
|
|
|
@ -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.RpcServerInterface;
|
||||
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.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
|
||||
|
@ -160,7 +159,7 @@ public class TestTokenAuthentication {
|
|||
|
||||
@Override
|
||||
public ServerName getServerName() {
|
||||
return new ServerName(isa.getHostName(), isa.getPort(), startcode);
|
||||
return ServerName.valueOf(isa.getHostName(), isa.getPort(), startcode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -383,7 +382,7 @@ public class TestTokenAuthentication {
|
|||
Configuration c = server.getConfiguration();
|
||||
RpcClient rpcClient = new RpcClient(c, clusterId.toString());
|
||||
ServerName sn =
|
||||
new ServerName(server.getAddress().getHostName(), server.getAddress().getPort(),
|
||||
ServerName.valueOf(server.getAddress().getHostName(), server.getAddress().getPort(),
|
||||
System.currentTimeMillis());
|
||||
try {
|
||||
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn,
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
|||
*/
|
||||
public class MockServer implements Server {
|
||||
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 aborted;
|
||||
|
|
|
@ -2031,7 +2031,7 @@ public class TestHBaseFsck {
|
|||
HBaseFsck hbck = doFsck(conf, false);
|
||||
assertNoErrors(hbck);
|
||||
|
||||
ServerName mockName = new ServerName("localhost", 60000, 1);
|
||||
ServerName mockName = ServerName.valueOf("localhost", 60000, 1);
|
||||
|
||||
// obtain one lock
|
||||
final TableLockManager tableLockManager = TableLockManager.createTableLockManager(conf, TEST_UTIL.getZooKeeperWatcher(), mockName);
|
||||
|
@ -2113,7 +2113,7 @@ public class TestHBaseFsck {
|
|||
HConnection connection = HConnectionManager.getConnection(conf);
|
||||
HRegionLocation metaLocation = connection.locateRegion(TableName.META_TABLE_NAME,
|
||||
HConstants.EMPTY_START_ROW);
|
||||
ServerName hsa = new ServerName(metaLocation.getHostnamePort(), 0L);
|
||||
ServerName hsa = ServerName.valueOf(metaLocation.getHostnamePort(), 0L);
|
||||
HRegionInfo hri = metaLocation.getRegionInfo();
|
||||
if (unassign) {
|
||||
LOG.info("Undeploying meta region " + hri + " from server " + hsa);
|
||||
|
|
|
@ -25,7 +25,6 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
|
@ -33,12 +32,10 @@ import junit.framework.Assert;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.WatchedEvent;
|
||||
import org.apache.zookeeper.Watcher;
|
||||
import org.apache.zookeeper.ZooDefs.Ids;
|
||||
|
@ -321,7 +318,7 @@ public class TestZooKeeperNodeTracker {
|
|||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||
"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,
|
||||
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
|
||||
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);
|
||||
|
||||
// Check that we delete when we're supposed to
|
||||
|
|
Loading…
Reference in New Issue