HBASE-5596 Few minor bugs from HBASE-5209 (David S. Wang)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1305661 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
080206de01
commit
3fd6997380
|
@ -71,7 +71,6 @@ public class ClusterStatus extends VersionedWritable {
|
||||||
*/
|
*/
|
||||||
private static final byte VERSION_MASTER_BACKUPMASTERS = 2;
|
private static final byte VERSION_MASTER_BACKUPMASTERS = 2;
|
||||||
private static final byte VERSION = 2;
|
private static final byte VERSION = 2;
|
||||||
private static final String UNKNOWN_SERVERNAME = "unknown";
|
|
||||||
|
|
||||||
private String hbaseVersion;
|
private String hbaseVersion;
|
||||||
private Map<ServerName, HServerLoad> liveServers;
|
private Map<ServerName, HServerLoad> liveServers;
|
||||||
|
@ -177,11 +176,11 @@ public class ClusterStatus extends VersionedWritable {
|
||||||
return (getVersion() == ((ClusterStatus)o).getVersion()) &&
|
return (getVersion() == ((ClusterStatus)o).getVersion()) &&
|
||||||
getHBaseVersion().equals(((ClusterStatus)o).getHBaseVersion()) &&
|
getHBaseVersion().equals(((ClusterStatus)o).getHBaseVersion()) &&
|
||||||
this.liveServers.equals(((ClusterStatus)o).liveServers) &&
|
this.liveServers.equals(((ClusterStatus)o).liveServers) &&
|
||||||
this.deadServers.equals(((ClusterStatus)o).deadServers) &&
|
this.deadServers.containsAll(((ClusterStatus)o).deadServers) &&
|
||||||
Arrays.equals(this.masterCoprocessors,
|
Arrays.equals(this.masterCoprocessors,
|
||||||
((ClusterStatus)o).masterCoprocessors) &&
|
((ClusterStatus)o).masterCoprocessors) &&
|
||||||
this.master.equals(((ClusterStatus)o).master) &&
|
this.master.equals(((ClusterStatus)o).master) &&
|
||||||
this.backupMasters.equals(((ClusterStatus)o).backupMasters);
|
this.backupMasters.containsAll(((ClusterStatus)o).backupMasters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,7 +343,7 @@ public class ClusterStatus extends VersionedWritable {
|
||||||
Bytes.readByteArray(in)));
|
Bytes.readByteArray(in)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.master = new ServerName(UNKNOWN_SERVERNAME, -1,
|
this.master = new ServerName(ServerName.UNKNOWN_SERVERNAME, -1,
|
||||||
ServerName.NON_STARTCODE);
|
ServerName.NON_STARTCODE);
|
||||||
this.backupMasters = new ArrayList<ServerName>(0);
|
this.backupMasters = new ArrayList<ServerName>(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,11 @@ public class ServerName implements Comparable<ServerName> {
|
||||||
SERVERNAME_SEPARATOR + Addressing.VALID_PORT_REGEX +
|
SERVERNAME_SEPARATOR + Addressing.VALID_PORT_REGEX +
|
||||||
SERVERNAME_SEPARATOR + Addressing.VALID_PORT_REGEX + "$");
|
SERVERNAME_SEPARATOR + Addressing.VALID_PORT_REGEX + "$");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What to use if server name is unknown.
|
||||||
|
*/
|
||||||
|
public static final String UNKNOWN_SERVERNAME = "#unknown#";
|
||||||
|
|
||||||
private final String servername;
|
private final String servername;
|
||||||
private final String hostname;
|
private final String hostname;
|
||||||
private final int port;
|
private final int port;
|
||||||
|
|
|
@ -168,7 +168,7 @@ class ActiveMasterManager extends ZooKeeperListener {
|
||||||
LOG.info("Adding ZNode for " + backupZNode +
|
LOG.info("Adding ZNode for " + backupZNode +
|
||||||
" in backup master directory");
|
" in backup master directory");
|
||||||
ZKUtil.createEphemeralNodeAndWatch(this.watcher, backupZNode,
|
ZKUtil.createEphemeralNodeAndWatch(this.watcher, backupZNode,
|
||||||
HConstants.EMPTY_BYTE_ARRAY);
|
this.sn.getVersionedBytes());
|
||||||
|
|
||||||
String msg;
|
String msg;
|
||||||
byte[] bytes =
|
byte[] bytes =
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1522,8 +1524,20 @@ Server {
|
||||||
List<ServerName> backupMasters = new ArrayList<ServerName>(
|
List<ServerName> backupMasters = new ArrayList<ServerName>(
|
||||||
backupMasterStrings.size());
|
backupMasterStrings.size());
|
||||||
for (String s: backupMasterStrings) {
|
for (String s: backupMasterStrings) {
|
||||||
backupMasters.add(new ServerName(s));
|
try {
|
||||||
|
byte[] bytes = ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode(this.zooKeeper.backupMasterAddressesZNode, s));
|
||||||
|
if (bytes != null) {
|
||||||
|
backupMasters.add(ServerName.parseVersionedServerName(bytes));
|
||||||
|
}
|
||||||
|
} catch (KeeperException e) {
|
||||||
|
LOG.warn(this.zooKeeper.prefix("Unable to get information about " +
|
||||||
|
"backup servers"), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort(backupMasters, new Comparator<ServerName>() {
|
||||||
|
public int compare(ServerName s1, ServerName s2) {
|
||||||
|
return s1.getServerName().compareTo(s2.getServerName());
|
||||||
|
}});
|
||||||
|
|
||||||
return new ClusterStatus(VersionInfo.getVersion(),
|
return new ClusterStatus(VersionInfo.getVersion(),
|
||||||
this.fileSystemManager.getClusterId(),
|
this.fileSystemManager.getClusterId(),
|
||||||
|
|
Loading…
Reference in New Issue