Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A3282200D03 for ; Sat, 9 Sep 2017 17:14:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A1DF11609E3; Sat, 9 Sep 2017 15:14:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2C5601609E5 for ; Sat, 9 Sep 2017 17:14:04 +0200 (CEST) Received: (qmail 36488 invoked by uid 500); 9 Sep 2017 15:13:57 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 33404 invoked by uid 99); 9 Sep 2017 15:13:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Sep 2017 15:13:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CA911F5718; Sat, 9 Sep 2017 15:13:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Sat, 09 Sep 2017 15:14:27 -0000 Message-Id: In-Reply-To: <66995acc0cf745738afee05fa04155ea@git.apache.org> References: <66995acc0cf745738afee05fa04155ea@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [35/51] [partial] hbase-site git commit: Published site at . archived-at: Sat, 09 Sep 2017 15:14:06 -0000 http://git-wip-us.apache.org/repos/asf/hbase-site/blob/1490b3ab/apidocs/src-html/org/apache/hadoop/hbase/ClusterStatus.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/ClusterStatus.html b/apidocs/src-html/org/apache/hadoop/hbase/ClusterStatus.html index 09abf56..ecd0db0 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/ClusterStatus.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/ClusterStatus.html @@ -35,8 +35,8 @@ 027 028import org.apache.hadoop.hbase.classification.InterfaceAudience; 029import org.apache.hadoop.hbase.master.RegionState; -030import org.apache.hadoop.io.VersionedWritable; -031 +030 +031import com.google.common.base.Objects; 032 033/** 034 * Status information on the HBase cluster. @@ -55,586 +55,403 @@ 047 * <li>Regions in transition at master</li> 048 * <li>The unique cluster ID</li> 049 * </ul> -050 * <tt>{@link Options}</tt> provides a way to filter out infos which unwanted. -051 * The following codes will retrieve all the cluster information. +050 * <tt>{@link Option}</tt> provides a way to get desired ClusterStatus information. +051 * The following codes will get all the cluster information. 052 * <pre> 053 * {@code 054 * // Original version still works 055 * Admin admin = connection.getAdmin(); 056 * ClusterStatus status = admin.getClusterStatus(); 057 * // or below, a new version which has the same effects -058 * ClusterStatus status = admin.getClusterStatus(Options.defaultOptions()); +058 * ClusterStatus status = admin.getClusterStatus(EnumSet.allOf(Option.class)); 059 * } 060 * </pre> -061 * If information about dead servers and master coprocessors are unwanted, +061 * If information about live servers is the only wanted. 062 * then codes in the following way: 063 * <pre> 064 * {@code 065 * Admin admin = connection.getAdmin(); -066 * ClusterStatus status = admin.getClusterStatus( -067 * Options.defaultOptions() -068 * .excludeDeadServers() -069 * .excludeMasterCoprocessors()); -070 * } -071 * </pre> -072 */ -073@InterfaceAudience.Public -074public class ClusterStatus extends VersionedWritable { -075 /** -076 * Version for object serialization. Incremented for changes in serialized -077 * representation. -078 * <dl> -079 * <dt>0</dt> <dd>Initial version</dd> -080 * <dt>1</dt> <dd>Added cluster ID</dd> -081 * <dt>2</dt> <dd>Added Map of ServerName to ServerLoad</dd> -082 * <dt>3</dt> <dd>Added master and backupMasters</dd> -083 * </dl> -084 */ -085 private static final byte VERSION = 2; -086 -087 private String hbaseVersion; -088 private Map<ServerName, ServerLoad> liveServers; -089 private Collection<ServerName> deadServers; -090 private ServerName master; -091 private Collection<ServerName> backupMasters; -092 private List<RegionState> intransition; -093 private String clusterId; -094 private String[] masterCoprocessors; -095 private Boolean balancerOn; -096 -097 /** -098 * Use {@link ClusterStatus.Builder} to construct a ClusterStatus instead. -099 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 -100 * (<a href="https://issues.apache.org/jira/browse/HBASE-15511">HBASE-15511</a>). -101 */ -102 @Deprecated -103 public ClusterStatus(final String hbaseVersion, final String clusterid, -104 final Map<ServerName, ServerLoad> servers, -105 final Collection<ServerName> deadServers, -106 final ServerName master, -107 final Collection<ServerName> backupMasters, -108 final List<RegionState> rit, -109 final String[] masterCoprocessors, -110 final Boolean balancerOn) { -111 // TODO: make this constructor private -112 this.hbaseVersion = hbaseVersion; -113 this.liveServers = servers; -114 this.deadServers = deadServers; -115 this.master = master; -116 this.backupMasters = backupMasters; -117 this.intransition = rit; -118 this.clusterId = clusterid; -119 this.masterCoprocessors = masterCoprocessors; -120 this.balancerOn = balancerOn; -121 } -122 -123 /** -124 * @return the names of region servers on the dead list -125 */ -126 public Collection<ServerName> getDeadServerNames() { -127 if (deadServers == null) { -128 return Collections.<ServerName>emptyList(); -129 } -130 return Collections.unmodifiableCollection(deadServers); -131 } -132 -133 /** -134 * @return the number of region servers in the cluster -135 */ -136 public int getServersSize() { -137 return liveServers != null ? liveServers.size() : 0; +066 * ClusterStatus status = admin.getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)); +067 * } +068 * </pre> +069 */ +070@InterfaceAudience.Public +071public class ClusterStatus { +072 +073 // TODO: remove this in 3.0 +074 private static final byte VERSION = 2; +075 +076 private String hbaseVersion; +077 private Map<ServerName, ServerLoad> liveServers; +078 private Collection<ServerName> deadServers; +079 private ServerName master; +080 private Collection<ServerName> backupMasters; +081 private List<RegionState> intransition; +082 private String clusterId; +083 private String[] masterCoprocessors; +084 private Boolean balancerOn; +085 +086 /** +087 * Use {@link ClusterStatus.Builder} to construct a ClusterStatus instead. +088 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 +089 * (<a href="https://issues.apache.org/jira/browse/HBASE-15511">HBASE-15511</a>). +090 */ +091 @Deprecated +092 public ClusterStatus(final String hbaseVersion, final String clusterid, +093 final Map<ServerName, ServerLoad> servers, +094 final Collection<ServerName> deadServers, +095 final ServerName master, +096 final Collection<ServerName> backupMasters, +097 final List<RegionState> rit, +098 final String[] masterCoprocessors, +099 final Boolean balancerOn) { +100 // TODO: make this constructor private +101 this.hbaseVersion = hbaseVersion; +102 this.liveServers = servers; +103 this.deadServers = deadServers; +104 this.master = master; +105 this.backupMasters = backupMasters; +106 this.intransition = rit; +107 this.clusterId = clusterid; +108 this.masterCoprocessors = masterCoprocessors; +109 this.balancerOn = balancerOn; +110 } +111 +112 /** +113 * @return the names of region servers on the dead list +114 */ +115 public Collection<ServerName> getDeadServerNames() { +116 if (deadServers == null) { +117 return Collections.<ServerName>emptyList(); +118 } +119 return Collections.unmodifiableCollection(deadServers); +120 } +121 +122 /** +123 * @return the number of region servers in the cluster +124 */ +125 public int getServersSize() { +126 return liveServers != null ? liveServers.size() : 0; +127 } +128 +129 /** +130 * @return the number of dead region servers in the cluster +131 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 +132 * (<a href="https://issues.apache.org/jira/browse/HBASE-13656">HBASE-13656</a>). +133 * Use {@link #getDeadServersSize()}. +134 */ +135 @Deprecated +136 public int getDeadServers() { +137 return getDeadServersSize(); 138 } 139 140 /** 141 * @return the number of dead region servers in the cluster -142 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 -143 * (<a href="https://issues.apache.org/jira/browse/HBASE-13656">HBASE-13656</a>). -144 * Use {@link #getDeadServersSize()}. -145 */ -146 @Deprecated -147 public int getDeadServers() { -148 return getDeadServersSize(); -149 } -150 -151 /** -152 * @return the number of dead region servers in the cluster -153 */ -154 public int getDeadServersSize() { -155 return deadServers != null ? deadServers.size() : 0; -156 } -157 -158 -159 /** -160 * @return the average cluster load -161 */ -162 public double getAverageLoad() { -163 int load = getRegionsCount(); -164 int serverSize = getServersSize(); -165 return serverSize != 0 ? (double)load / (double)serverSize : 0.0; -166 } -167 -168 /** -169 * @return the number of regions deployed on the cluster -170 */ -171 public int getRegionsCount() { -172 int count = 0; -173 if (liveServers != null && !liveServers.isEmpty()) { -174 for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) { -175 count += e.getValue().getNumberOfRegions(); -176 } -177 } -178 return count; -179 } -180 -181 /** -182 * @return the number of requests since last report -183 */ -184 public int getRequestsCount() { -185 int count = 0; -186 if (liveServers != null && !liveServers.isEmpty()) { -187 for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) { -188 count += e.getValue().getNumberOfRequests(); -189 } -190 } -191 return count; -192 } -193 -194 /** -195 * @return the HBase version string as reported by the HMaster -196 */ -197 public String getHBaseVersion() { -198 return hbaseVersion; -199 } -200 -201 /** -202 * @see java.lang.Object#equals(java.lang.Object) -203 */ -204 public boolean equals(Object o) { -205 if (this == o) { -206 return true; -207 } -208 if (!(o instanceof ClusterStatus)) { -209 return false; -210 } -211 return (getVersion() == ((ClusterStatus)o).getVersion()) && -212 getHBaseVersion().equals(((ClusterStatus)o).getHBaseVersion()) && -213 this.liveServers.equals(((ClusterStatus)o).liveServers) && -214 this.deadServers.containsAll(((ClusterStatus)o).deadServers) && -215 Arrays.equals(this.masterCoprocessors, -216 ((ClusterStatus)o).masterCoprocessors) && -217 this.master.equals(((ClusterStatus)o).master) && -218 this.backupMasters.containsAll(((ClusterStatus)o).backupMasters); -219 } -220 -221 /** -222 * @see java.lang.Object#hashCode() -223 */ -224 public int hashCode() { -225 return VERSION + hbaseVersion.hashCode() + this.liveServers.hashCode() + -226 this.deadServers.hashCode() + this.master.hashCode() + -227 this.backupMasters.hashCode(); -228 } -229 -230 /** @return the object version number */ -231 public byte getVersion() { -232 return VERSION; -233 } -234 -235 // -236 // Getters -237 // +142 */ +143 public int getDeadServersSize() { +144 return deadServers != null ? deadServers.size() : 0; +145 } +146 +147 +148 /** +149 * @return the average cluster load +150 */ +151 public double getAverageLoad() { +152 int load = getRegionsCount(); +153 int serverSize = getServersSize(); +154 return serverSize != 0 ? (double)load / (double)serverSize : 0.0; +155 } +156 +157 /** +158 * @return the number of regions deployed on the cluster +159 */ +160 public int getRegionsCount() { +161 int count = 0; +162 if (liveServers != null && !liveServers.isEmpty()) { +163 for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) { +164 count += e.getValue().getNumberOfRegions(); +165 } +166 } +167 return count; +168 } +169 +170 /** +171 * @return the number of requests since last report +172 */ +173 public int getRequestsCount() { +174 int count = 0; +175 if (liveServers != null && !liveServers.isEmpty()) { +176 for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) { +177 count += e.getValue().getNumberOfRequests(); +178 } +179 } +180 return count; +181 } +182 +183 /** +184 * @return the HBase version string as reported by the HMaster +185 */ +186 public String getHBaseVersion() { +187 return hbaseVersion; +188 } +189 +190 /** +191 * @see java.lang.Object#equals(java.lang.Object) +192 */ +193 public boolean equals(Object o) { +194 if (this == o) { +195 return true; +196 } +197 if (!(o instanceof ClusterStatus)) { +198 return false; +199 } +200 ClusterStatus other = (ClusterStatus) o; +201 //TODO Override the equals() methods in ServerLoad. +202 return Objects.equal(getHBaseVersion(), other.getHBaseVersion()) && +203 Objects.equal(this.liveServers, other.liveServers) && +204 getDeadServerNames().containsAll(other.getDeadServerNames()) && +205 Arrays.equals(getMasterCoprocessors(), other.getMasterCoprocessors()) && +206 Objects.equal(getMaster(), other.getMaster()) && +207 getBackupMasters().containsAll(other.getBackupMasters()); +208 } +209 +210 /** +211 * @see java.lang.Object#hashCode() +212 */ +213 public int hashCode() { +214 return Objects.hashCode(hbaseVersion, liveServers, deadServers, +215 master, backupMasters); +216 } +217 +218 /** +219 * +220 * @return the object version number +221 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 +222 */ +223 @Deprecated +224 public byte getVersion() { +225 return VERSION; +226 } +227 +228 // +229 // Getters +230 // +231 +232 public Collection<ServerName> getServers() { +233 if (liveServers == null) { +234 return Collections.<ServerName>emptyList(); +235 } +236 return Collections.unmodifiableCollection(this.liveServers.keySet()); +237 } 238 -239 public Collection<ServerName> getServers() { -240 if (liveServers == null) { -241 return Collections.<ServerName>emptyList(); -242 } -243 return Collections.unmodifiableCollection(this.liveServers.keySet()); -244 } -245 -246 /** -247 * Returns detailed information about the current master {@link ServerName}. -248 * @return current master information if it exists +239 /** +240 * Returns detailed information about the current master {@link ServerName}. +241 * @return current master information if it exists +242 */ +243 public ServerName getMaster() { +244 return this.master; +245 } +246 +247 /** +248 * @return the number of backup masters in the cluster 249 */ -250 public ServerName getMaster() { -251 return this.master; +250 public int getBackupMastersSize() { +251 return backupMasters != null ? backupMasters.size() : 0; 252 } 253 254 /** -255 * @return the number of backup masters in the cluster +255 * @return the names of backup masters 256 */ -257 public int getBackupMastersSize() { -258 return backupMasters != null ? backupMasters.size() : 0; -259 } -260 -261 /** -262 * @return the names of backup masters -263 */ -264 public Collection<ServerName> getBackupMasters() { -265 if (backupMasters == null) { -266 return Collections.<ServerName>emptyList(); -267 } -268 return Collections.unmodifiableCollection(this.backupMasters); -269 } -270 -271 /** -272 * @param sn -273 * @return Server's load or null if not found. -274 */ -275 public ServerLoad getLoad(final ServerName sn) { -276 return liveServers != null ? liveServers.get(sn) : null; -277 } -278 -279 @InterfaceAudience.Private -280 public List<RegionState> getRegionsInTransition() { -281 return this.intransition; -282 } -283 -284 public String getClusterId() { -285 return clusterId; -286 } -287 -288 public String[] getMasterCoprocessors() { -289 return masterCoprocessors; -290 } -291 -292 public long getLastMajorCompactionTsForTable(TableName table) { -293 long result = Long.MAX_VALUE; -294 for (ServerName server : getServers()) { -295 ServerLoad load = getLoad(server); -296 for (RegionLoad rl : load.getRegionsLoad().values()) { -297 if (table.equals(HRegionInfo.getTable(rl.getName()))) { -298 result = Math.min(result, rl.getLastMajorCompactionTs()); -299 } -300 } -301 } -302 return result == Long.MAX_VALUE ? 0 : result; -303 } -304 -305 public long getLastMajorCompactionTsForRegion(final byte[] region) { -306 for (ServerName server : getServers()) { -307 ServerLoad load = getLoad(server); -308 RegionLoad rl = load.getRegionsLoad().get(region); -309 if (rl != null) { -310 return rl.getLastMajorCompactionTs(); -311 } -312 } -313 return 0; -314 } -315 -316 public boolean isBalancerOn() { -317 return balancerOn != null && balancerOn; -318 } -319 -320 public Boolean getBalancerOn() { -321 return balancerOn; -322 } -323 -324 public String toString() { -325 StringBuilder sb = new StringBuilder(1024); -326 sb.append("Master: " + master); -327 -328 int backupMastersSize = getBackupMastersSize(); -329 sb.append("\nNumber of backup masters: " + backupMastersSize); -330 if (backupMastersSize > 0) { -331 for (ServerName serverName: backupMasters) { -332 sb.append("\n " + serverName); -333 } -334 } -335 -336 int serversSize = getServersSize(); -337 sb.append("\nNumber of live region servers: " + serversSize); -338 if (serversSize > 0) { -339 for (ServerName serverName: liveServers.keySet()) { -340 sb.append("\n " + serverName.getServerName()); -341 } -342 } -343 -344 int deadServerSize = getDeadServersSize(); -345 sb.append("\nNumber of dead region servers: " + deadServerSize); -346 if (deadServerSize > 0) { -347 for (ServerName serverName: deadServers) { -348 sb.append("\n " + serverName); -349 } -350 } -351 -352 sb.append("\nAverage load: " + getAverageLoad()); -353 sb.append("\nNumber of requests: " + getRequestsCount()); -354 sb.append("\nNumber of regions: " + getRegionsCount()); -355 -356 int ritSize = (intransition != null) ? intransition.size() : 0; -357 sb.append("\nNumber of regions in transition: " + ritSize); -358 if (ritSize > 0) { -359 for (RegionState state: intransition) { -360 sb.append("\n " + state.toDescriptiveString()); -361 } -362 } -363 return sb.toString(); -364 } -365 -366 public static Builder newBuilder() { -367 return new Builder(); -368 } -369 -370 /** -371 * Builder for construct a ClusterStatus. -372 */ -373 public static class Builder { -374 private String hbaseVersion = null; -375 private Map<ServerName, ServerLoad> liveServers = null; -376 private Collection<ServerName> deadServers = null; -377 private ServerName master = null; -378 private Collection<ServerName> backupMasters = null; -379 private List<RegionState> intransition = null; -380 private String clusterId = null; -381 private String[] masterCoprocessors = null; -382 private Boolean balancerOn = null; -383 -384 private Builder() {} -385 -386 public Builder setHBaseVersion(String hbaseVersion) { -387 this.hbaseVersion = hbaseVersion; -388 return this; -389 } -390 -391 public Builder setLiveServers(Map<ServerName, ServerLoad> liveServers) { -392 this.liveServers = liveServers; -393 return this; -394 } -395 -396 public Builder setDeadServers(Collection<ServerName> deadServers) { -397 this.deadServers = deadServers; -398 return this; -399 } -400 -401 public Builder setMaster(ServerName master) { -402 this.master = master; -403 return this; -404 } -405 -406 public Builder setBackupMasters(Collection<ServerName> backupMasters) { -407 this.backupMasters = backupMasters; -408 return this; -409 } -410 -411 public Builder setRegionState(List<RegionState> intransition) { -412 this.intransition = intransition; -413 return this; -414 } -415 -416 public Builder setClusterId(String clusterId) { -417 this.clusterId = clusterId; -418 return this; -419 } -420 -421 public Builder setMasterCoprocessors(String[] masterCoprocessors) { -422 this.masterCoprocessors = masterCoprocessors; -423 return this; -424 } -425 -426 public Builder setBalancerOn(Boolean balancerOn) { -427 this.balancerOn = balancerOn; -428 return this; +257 public Collection<ServerName> getBackupMasters() { +258 if (backupMasters == null) { +259 return Collections.<ServerName>emptyList(); +260 } +261 return Collections.unmodifiableCollection(this.backupMasters); +262 } +263 +264 /** +265 * @param sn +266 * @return Server's load or null if not found. +267 */ +268 public ServerLoad getLoad(final ServerName sn) { +269 return liveServers != null ? liveServers.get(sn) : null; +270 } +271 +272 @InterfaceAudience.Private +273 public List<RegionState> getRegionsInTransition() { +274 return this.intransition; +275 } +276 +277 public String getClusterId() { +278 return clusterId; +279 } +280 +281 public String[] getMasterCoprocessors() { +282 return masterCoprocessors; +283 } +284 +285 public long getLastMajorCompactionTsForTable(TableName table) { +286 long result = Long.MAX_VALUE; +287 for (ServerName server : getServers()) { +288 ServerLoad load = getLoad(server); +289 for (RegionLoad rl : load.getRegionsLoad().values()) { +290 if (table.equals(HRegionInfo.getTable(rl.getName()))) { +291 result = Math.min(result, rl.getLastMajorCompactionTs()); +292 } +293 } +294 } +295 return result == Long.MAX_VALUE ? 0 : result; +296 } +297 +298 public long getLastMajorCompactionTsForRegion(final byte[] region) { +299 for (ServerName server : getServers()) { +300 ServerLoad load = getLoad(server); +301 RegionLoad rl = load.getRegionsLoad().get(region); +302 if (rl != null) { +303 return rl.getLastMajorCompactionTs(); +304 } +305 } +306 return 0; +307 } +308 +309 public boolean isBalancerOn() { +310 return balancerOn != null && balancerOn; +311 } +312 +313 public Boolean getBalancerOn() { +314 return balancerOn; +315 } +316 +317 public String toString() { +318 StringBuilder sb = new StringBuilder(1024); +319 sb.append("Master: " + master); +320 +321 int backupMastersSize = getBackupMastersSize(); +322 sb.append("\nNumber of backup masters: " + backupMastersSize); +323 if (backupMastersSize > 0) { +324 for (ServerName serverName: backupMasters) { +325 sb.append("\n " + serverName); +326 } +327 } +328 +329 int serversSize = getServersSize(); +330 sb.append("\nNumber of live region servers: " + serversSize); +331 if (serversSize > 0) { +332 for (ServerName serverName: liveServers.keySet()) { +333 sb.append("\n " + serverName.getServerName()); +334 } +335 } +336 +337 int deadServerSize = getDeadServersSize(); +338 sb.append("\nNumber of dead region servers: " + deadServerSize); +339 if (deadServerSize > 0) { +340 for (ServerName serverName: deadServers) { +341 sb.append("\n " + serverName); +342 } +343 } +344 +345 sb.append("\nAverage load: " + getAverageLoad()); +346 sb.append("\nNumber of requests: " + getRequestsCount()); +347 sb.append("\nNumber of regions: " + getRegionsCount()); +348 +349 int ritSize = (intransition != null) ? intransition.size() : 0; +350 sb.append("\nNumber of regions in transition: " + ritSize); +351 if (ritSize > 0) { +352 for (RegionState state: intransition) { +353 sb.append("\n " + state.toDescriptiveString()); +354 } +355 } +356 return sb.toString(); +357 } +358 +359 public static Builder newBuilder() { +360 return new Builder(); +361 } +362 +363 /** +364 * Builder for construct a ClusterStatus. +365 */ +366 @InterfaceAudience.Private +367 public static class Builder { +368 private String hbaseVersion = null; +369 private Map<ServerName, ServerLoad> liveServers = null; +370 private Collection<ServerName> deadServers = null; +371 private ServerName master = null; +372 private Collection<ServerName> backupMasters = null; +373 private List<RegionState> intransition = null; +374 private String clusterId = null; +375 private String[] masterCoprocessors = null; +376 private Boolean balancerOn = null; +377 +378 private Builder() {} +379 +380 public Builder setHBaseVersion(String hbaseVersion) { +381 this.hbaseVersion = hbaseVersion; +382 return this; +383 } +384 +385 public Builder setLiveServers(Map<ServerName, ServerLoad> liveServers) { +386 this.liveServers = liveServers; +387 return this; +388 } +389 +390 public Builder setDeadServers(Collection<ServerName> deadServers) { +391 this.deadServers = deadServers; +392 return this; +393 } +394 +395 public Builder setMaster(ServerName master) { +396 this.master = master; +397 return this; +398 } +399 +400 public Builder setBackupMasters(Collection<ServerName> backupMasters) { +401 this.backupMasters = backupMasters; +402 return this; +403 } +404 +405 public Builder setRegionState(List<RegionState> intransition) { +406 this.intransition = intransition; +407 return this; +408 } +409 +410 public Builder setClusterId(String clusterId) { +411 this.clusterId = clusterId; +412 return this; +413 } +414 +415 public Builder setMasterCoprocessors(String[] masterCoprocessors) { +416 this.masterCoprocessors = masterCoprocessors; +417 return this; +418 } +419 +420 public Builder setBalancerOn(Boolean balancerOn) { +421 this.balancerOn = balancerOn; +422 return this; +423 } +424 +425 public ClusterStatus build() { +426 return new ClusterStatus(hbaseVersion, clusterId, liveServers, +427 deadServers, master, backupMasters, intransition, masterCoprocessors, +428 balancerOn); 429 } -430 -431 public ClusterStatus build() { -432 return new ClusterStatus(hbaseVersion, clusterId, liveServers, -433 deadServers, master, backupMasters, intransition, masterCoprocessors, -434 balancerOn); -435 } -436 } -437 -438 /** -439 * Options provides a way to filter out unwanted information. -440 * For compatibility, default options includes all the information about a ClusterStatus. -441 * To filter out unwanted information, use the specific excludeXXX() method. -442 */ -443 public static class Options { -444 private boolean includeHBaseVersion = true; -445 private boolean includeLiveServers = true; -446 private boolean includeDeadServers = true; -447 private boolean includeMaster = true; -448 private boolean includeBackupMasters = true; -449 private boolean includeRegionState = true; -450 private boolean includeClusterId = true; -451 private boolean includeMasterCoprocessors = true; -452 private boolean includeBalancerOn = true; -453 -454 private Options() {} -455 -456 /** -457 * Include all information about a ClusterStatus. -458 */ -459 public static Options getDefaultOptions() { -460 return new Options(); -461 } -462 -463 /** -464 * Filter out hbase verision. -465 */ -466 public Options excludeHBaseVersion() { -467 includeHBaseVersion = false; -468 return this; -469 } -470 -471 /** -472 * Filter out live servers. -473 */ -474 public Options excludeLiveServers() { -475 includeLiveServers = false; -476 return this; -477 } -478 -479 /** -480 * Filter out dead servers info. -481 */ -482 public Options excludeDeadServers() { -483 includeDeadServers = false; -484 return this; -485 } -486 -487 /** -488 * Filter out master info. -489 */ -490 public Options excludeMaster() { -491 includeMaster = false; -492 return this; -493 } -494 -495 /** -496 * Filter out backup masters info. -497 */ -498 public Options excludeBackupMasters() { -499 includeBackupMasters = false; -500 return this; -501 } -502 -503 /** -504 * Filter out region state. -505 */ -506 public Options excludeRegionState() { -507 includeRegionState = false; -508 return this; -509 } -510 -511 /** -512 * Filter out cluster id. -513 */ -514 public Options excludeClusterId() { -515 includeClusterId = false; -516 return this; -517 } -518 -519 /** -520 * Filter out master's coprocessors info. -521 */ -522 public Options excludeMasterCoprocessors() { -523 includeMasterCoprocessors = false; -524 return this; -525 } -526 -527 /** -528 * Filter out balancer on info. -529 */ -530 public Options excludeBalancerOn() { -531 includeBalancerOn = false; -532 return this; -533 } -534 -535 /** -536 * Include hbase version info. -537 */ -538 public boolean includeHBaseVersion() { -539 return includeHBaseVersion; -540 } -541 -542 /** -543 * Include live servers info. -544 */ -545 public boolean includeLiveServers() { -546 return includeLiveServers; -547 } -548 -549 /** -550 * Include dead servers info. -551 */ -552 public boolean includeDeadServers() { -553 return includeDeadServers; -554 } -555 -556 /** -557 * Include master info. -558 */ -559 public boolean includeMaster() { -560 return includeMaster; -561 } -562 -563 /** -564 * Include backup masters info. -565 */ -566 public boolean includeBackupMasters() { -567 return includeBackupMasters; -568 } -569 -570 /** -571 * Include region states info. -572 */ -573 public boolean includeRegionState() { -574 return includeRegionState; -575 } -576 -577 /** -578 * Include cluster id info. -579 */ -580 public boolean includeClusterId() { -581 return includeClusterId; -582 } -583 -584 /** -585 * Include master's coprocessors. -586 */ -587 public boolean includeMasterCoprocessors() { -588 return includeMasterCoprocessors; -589 } -590 -591 /** -592 * Include balancer on info. -593 */ -594 public boolean includeBalancerOn() { -595 return includeBalancerOn; -596 } -597 -598 /** -599 * For an options reusable convenience, reset options to default. -600 */ -601 public Options reset() { -602 includeHBaseVersion = true; -603 includeLiveServers = true; -604 includeDeadServers = true; -605 includeMaster = true; -606 includeBackupMasters = true; -607 includeRegionState = true; -608 includeClusterId = true; -609 includeMasterCoprocessors = true; -610 includeBalancerOn = true; -611 return this; -612 } -613 -614 @Override -615 public String toString() { -616 StringBuilder builder = new StringBuilder("ClusterStatus info: ["); -617 builder.append("include hbase version: " + includeHBaseVersion + ", "); -618 builder.append("include cluster id: " + includeClusterId + ", "); -619 builder.append("include master info: " + includeMaster + ", "); -620 builder.append("include backup masters info: " + includeBackupMasters + ", "); -621 builder.append("include live servers info: " + includeLiveServers + ", "); -622 builder.append("include dead servers info: " + includeDeadServers + ", "); -623 builder.append("include masters coprocessors: " + includeMasterCoprocessors + ", "); -624 builder.append("include region state: " + includeRegionState + ", "); -625 builder.append("include balancer on: " + includeBalancerOn + "]"); -626 return builder.toString(); -627 } -628 } -629} +430 } +431 +432 /** +433 * Kinds of ClusterStatus +434 */ +435 public enum Option { +436 HBASE_VERSION, /** status about hbase version */ +437 CLUSTER_ID, /** status about cluster id */ +438 BALANCER_ON, /** status about balancer is on or not */ +439 LIVE_SERVERS, /** status about live region servers */ +440 DEAD_SERVERS, /** status about dead region servers */ +441 MASTER, /** status about master */ +442 BACKUP_MASTERS, /** status about backup masters */ +443 MASTER_COPROCESSORS, /** status about master coprocessors */ +444 REGIONS_IN_TRANSITION; /** status about regions in transition */ +445 } +446}