HBASE-25896 Implement a Region Visualization on Master WebUI (#4228)

This is a demonstration of visualization of regions on the cluster. The visualization is a stacked
bar chart showing total storefile size per table per region server, with the x-axis being server
names, the y-axis being storfile size, and the bars stacked per table. The visualization is
generated entirely on the fly from within the browser, implemented using Vega Lite. So far, Vega
appears to handle rendering this visualization for a cluster of over 700 region servers with
approximately 300,000 regions.

Per [0], include an update to the top-level LICENSE.txt. Also update LICENSE files in all binary
distributions (i.e., jars), by way of LICENSE.vm. Vega uses a BSD 3-clause variant without
advertising clause, and as such is a "Category A" license, per [1].

No changes are made to the NOTICE files, as per the existing example of bundling the minified
JQuery, which is also a Category A license.

[0]: https://infra.apache.org/licensing-howto.html
[1]: https://www.apache.org/legal/resolved.html#category-a

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Nick Dimiduk 2022-03-15 21:01:57 +01:00 committed by GitHub
parent 2507dc1b01
commit c4ec5230f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 592 additions and 3 deletions

View File

@ -639,3 +639,37 @@ under a '2-clause BSD' license.
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
----
This project bundles a copy of the Vega minified javascript library version
5.19.1, the Vega-Lite minified javascript library version 5.0.0, and the
Vega-Embed minified javascript library version 6.15.1. All three are
available under the following '3-clause BSD' license.
Copyright (c) 2015-2018, University of Washington Interactive Data Lab
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -53,6 +53,7 @@
<debug-print-included-work-info>${license.debug.print.included}</debug-print-included-work-info>
<bundled-dependencies>${license.bundles.dependencies}</bundled-dependencies>
<bundled-jquery>${license.bundles.jquery}</bundled-jquery>
<bundled-vega>${license.bundles.vega}</bundled-vega>
<bundled-logo>${license.bundles.logo}</bundled-logo>
<bundled-bootstrap>${license.bundles.bootstrap}</bundled-bootstrap>
</properties>

View File

@ -65,6 +65,7 @@
<debug-print-included-work-info>${license.debug.print.included}</debug-print-included-work-info>
<bundled-dependencies>${license.bundles.dependencies}</bundled-dependencies>
<bundled-jquery>${license.bundles.jquery}</bundled-jquery>
<bundled-vega>${license.bundles.vega}</bundled-vega>
<bundled-logo>${license.bundles.logo}</bundled-logo>
<bundled-bootstrap>${license.bundles.bootstrap}</bundled-bootstrap>
</properties>

View File

@ -222,9 +222,10 @@ under the License.
## Special cases, for e.g. ASL2.0 licensed works that bundle additional third party works
#set($bundled-jquery = ${bundled-jquery.equalsIgnoreCase("true")})
#set($bundled-vega = ${bundled-vega.equalsIgnoreCase("true")})
#set($bundled-logo = ${bundled-logo.equalsIgnoreCase("true")})
#set($bundled-dependencies = ${bundled-dependencies.equalsIgnoreCase("true")})
#if($bundled-jquery || $bundled-logo || $bundled-dependencies)
#if($bundled-jquery || $bundled-vega || $bundled-logo || $bundled-dependencies)
====
${project.name} contained works
@ -260,6 +261,40 @@ This project bundles a copy of the JQuery minified javascript library version
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#end
#macro(vega_license)
This project bundles a copy of the Vega minified javascript library version
5.19.1, the Vega-Lite minified javascript library version 5.0.0, and the
Vega-Embed minified javascript library version 6.15.1. All three are
available under the following '3-clause BSD' license.
Copyright (c) 2015-2018, University of Washington Interactive Data Lab
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#end
#macro(orca_logo_license)
----
@ -1309,6 +1344,9 @@ You can redistribute it and/or modify it under either the terms of the
#if(${bundled-jquery})
#jquery_license()
#end
#if(${bundled-vega})
#vega_license()
#end
#if(${bundled-logo})
#orca_logo_license()
#end

View File

@ -34,6 +34,7 @@
<license.bundles.logo>true</license.bundles.logo>
<license.bundles.bootstrap>true</license.bundles.bootstrap>
<license.bundles.jquery>true</license.bundles.jquery>
<license.bundles.vega>true</license.bundles.vega>
</properties>
<build>
<!-- Make sure resources get added before they are processed by placing this first
@ -100,6 +101,7 @@
<debug-print-included-work-info>${license.debug.print.included}</debug-print-included-work-info>
<bundled-dependencies>${license.bundles.dependencies}</bundled-dependencies>
<bundled-jquery>${license.bundles.jquery}</bundled-jquery>
<bundled-vega>${license.bundles.vega}</bundled-vega>
<bundled-logo>${license.bundles.logo}</bundled-logo>
<bundled-bootstrap>${license.bundles.bootstrap}</bundled-bootstrap>
</properties>

View File

@ -276,6 +276,10 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
</div>
</div>
</section>
<section>
<h2><a name="region_visualizer"></a>Region Visualizer</h2>
<& RegionVisualizerTmpl &>
</section>
<section>
<h2><a name="peers">Peers</a></h2>
<& peerConfigs &>

View File

@ -0,0 +1,119 @@
<%doc>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</%doc>
<script type="text/javascript" src="/static/js/vega@5.19.1.min.js"></script>
<script type="text/javascript" src="/static/js/vega-lite@5.0.0.min.js"></script>
<script type="text/javascript" src="/static/js/vega-embed@6.15.1.min.js"></script>
<div id="vis" style="width:80%;"></div>
<script type="text/javascript">
vega.expressionFunction('values', function(obj) { return Object.values(obj); });
var vlSpec = {
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
description: 'Total `storefileSize` per Region Server',
data: {
name: 'region_info',
url: 'http://localhost:16010/api/v1/admin/cluster_metrics/live_servers',
format: { type: 'json', property: 'data' }
},
transform: [
{ calculate: "split(datum.server_name.servername, ',', 1)[0]", as: 'server_name' },
{ calculate: 'values(datum.region_status)', as: 'region_status' },
{ flatten: ['region_status'] },
{ calculate: "split(datum.region_status.name, ',', 1)[0]", as: 'table_name' },
{ calculate: "split(datum.region_status.name, ',', 3)[2]", as: 'region_id' },
],
vconcat: [{
title: {
text: 'Total `storefileSize` per Region Server',
align: 'center'
},
height: 250,
width: 'container',
mark: { type: 'bar', tooltip: true },
params: [{
name: 'legend_selection',
select: { type: 'point', fields: ['table_name'] },
bind: 'legend'
}],
encoding: {
x: {
title:'Region Server',
field: 'server_name',
type: 'nominal',
axis: {
labelAngle: 90,
labelOverlap: 'greedy'
},
scale: { domain: { param: 'brush' } },
sort: '-y'
},
y: {
title: 'Total StoreFileSize',
field: 'region_status.store_file_size',
type: 'quantitative',
aggregate: 'sum',
format: '.4s',
axis: { format: '.2s' },
scale: { domainMin: 0 }
},
color: {
field: 'table_name',
type: 'nominal',
title: 'Table'
},
opacity: {
condition: { param: 'legend_selection', value: 0.9 },
value: 0.2
}
}
}, {
mark: 'bar',
height: 50,
width: 'container',
params: [{
name: 'brush',
select: { type: 'interval', encodings: ['x'] }
}],
encoding: {
x: {
field: 'server_name',
type: 'nominal',
axis: null,
sort: '-y'
},
y: {
field: 'region_status.store_file_size',
aggregate: 'sum',
axis: null
},
color: {
field: 'table_name',
title: 'Table'
}
}
}]
};
vegaEmbed('#vis', vlSpec)
.then(function(result) {
//result.view.logger(vega.Debug);
//console.log(result.view.data('region_info'));
})
.catch(console.Error);
</script>

View File

@ -0,0 +1,256 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.master.http;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.Size;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.AsyncAdmin;
import org.apache.hadoop.hbase.client.AsyncConnection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.gson.FieldNamingPolicy;
import org.apache.hbase.thirdparty.com.google.gson.Gson;
import org.apache.hbase.thirdparty.com.google.gson.GsonBuilder;
import org.apache.hbase.thirdparty.com.google.gson.JsonElement;
import org.apache.hbase.thirdparty.com.google.gson.JsonObject;
import org.apache.hbase.thirdparty.com.google.gson.JsonPrimitive;
import org.apache.hbase.thirdparty.com.google.gson.JsonSerializationContext;
import org.apache.hbase.thirdparty.com.google.gson.JsonSerializer;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
/**
* Support class for the "Region Visualizer" rendered out of
* {@code src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionVisualizerTmpl.jamon}
*/
@InterfaceAudience.Private
public class RegionVisualizer extends AbstractHBaseTool {
private static final Logger LOG = LoggerFactory.getLogger(RegionVisualizer.class);
private final Admin admin;
private final AsyncAdmin asyncAdmin;
private final Gson gson;
public RegionVisualizer() {
admin = null;
asyncAdmin = null;
gson = null;
}
public RegionVisualizer(final Admin admin) {
this.admin = admin;
this.asyncAdmin = null;
this.gson = buildGson();
}
public RegionVisualizer(final AsyncAdmin asyncAdmin) {
this.admin = null;
this.asyncAdmin = asyncAdmin;
this.gson = buildGson();
}
public String renderRegionDetails() {
return gson.toJson(clusterStatusToRegionDetails());
}
public static void main(final String[] argv) {
new RegionVisualizer().doStaticMain(argv);
}
static Gson buildGson() {
return new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.enableComplexMapKeySerialization()
.registerTypeAdapter(byte[].class, new ByteArraySerializer())
.registerTypeAdapter(Size.class, new SizeAsBytesSerializer())
.registerTypeAdapter(RegionDetails.class, new RegionDetailsSerializer())
.create();
}
private ClusterMetrics getClusterMetrics()
throws ExecutionException, InterruptedException, IOException {
if (admin != null) {
return admin.getClusterMetrics();
}
if (asyncAdmin != null) {
return asyncAdmin.getClusterMetrics().get();
}
throw new RuntimeException("should not happen");
}
private List<RegionDetails> clusterStatusToRegionDetails() {
final ClusterMetrics clusterMetrics;
try {
clusterMetrics = getClusterMetrics();
} catch (Exception e) {
LOG.warn("Failed to retrieve cluster metrics.", e);
return Collections.emptyList();
}
return clusterMetrics.getLiveServerMetrics().entrySet().stream()
.flatMap(serverEntry -> {
final ServerName serverName = serverEntry.getKey();
final ServerMetrics serverMetrics = serverEntry.getValue();
return serverMetrics.getRegionMetrics().values().stream()
.map(regionMetrics -> {
final TableName tableName = RegionInfo.getTable(regionMetrics.getRegionName());
return new RegionDetails(serverName, tableName, regionMetrics);
});
})
.collect(Collectors.toList());
}
@Override protected void addOptions() {
}
@Override protected void processOptions(CommandLine cmd) {
}
@Override protected int doWork() throws Exception {
final Configuration conf = HBaseConfiguration.create(getConf());
final AsyncConnection conn = ConnectionFactory.createAsyncConnection(conf).get();
final RegionVisualizer viz = new RegionVisualizer(conn.getAdmin());
System.out.println(viz.renderRegionDetails());
return 0;
}
private static final class ByteArraySerializer implements JsonSerializer<byte[]> {
@Override
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(Bytes.toString(src));
}
}
/**
* Simplify representation of a {@link Size} instance by converting to bytes.
*/
private static final class SizeAsBytesSerializer implements JsonSerializer<Size> {
@Override
public JsonElement serialize(Size src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.get(Size.Unit.BYTE));
}
}
/**
* "Flatten" the serialized representation of a {@link RegionDetails}.
*/
private static final class RegionDetailsSerializer implements JsonSerializer<RegionDetails> {
@Override
public JsonElement serialize(RegionDetails src, Type typeOfSrc,
JsonSerializationContext context) {
final JsonObject jobj = (JsonObject) context.serialize(src.getRegionMetrics());
jobj.addProperty("server_name", src.getServerName().toShortString());
jobj.addProperty("table_name", src.getTableName().getNameAsString());
return jobj;
}
}
/**
* POJO carrying detailed information about a region for use in visualizations. Intended to be
* serialized to JSON and consumed from JavaScript.
*/
public static final class RegionDetails {
private final ServerName serverName;
private final TableName tableName;
private final RegionMetrics regionMetrics;
RegionDetails(
final ServerName serverName,
final TableName tableName,
final RegionMetrics regionMetrics
) {
this.serverName = serverName;
this.tableName = tableName;
this.regionMetrics = regionMetrics;
}
public ServerName getServerName() {
return serverName;
}
public TableName getTableName() {
return tableName;
}
public RegionMetrics getRegionMetrics() {
return regionMetrics;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("serverName", serverName)
.append("tableName", tableName)
.append("regionMetrics", regionMetrics)
.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RegionDetails that = (RegionDetails) o;
return new EqualsBuilder()
.append(serverName, that.serverName)
.append(tableName, that.tableName)
.append(regionMetrics, that.regionMetrics)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(serverName)
.append(tableName)
.append(regionMetrics)
.toHashCode();
}
}
}

View File

@ -38,7 +38,7 @@ import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;
* The root object exposing a subset of {@link org.apache.hadoop.hbase.ClusterMetrics}.
*/
@InterfaceAudience.Private
@Path("cluster_metrics")
@Path("admin/cluster_metrics")
@Produces({ MediaType.APPLICATION_JSON })
public class ClusterMetricsResource {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -118,7 +118,7 @@ public class TestApiV1ClusterMetricsResource {
(hostName, infoPort) -> "http://" + hostName + ":" + infoPort)
.get();
final Client client = ClientBuilder.newClient();
target = client.target(baseUrl).path("api/v1/cluster_metrics");
target = client.target(baseUrl).path("api/v1/admin/cluster_metrics");
}
@Override

View File

@ -0,0 +1,98 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.master.http;
import static org.junit.Assert.assertEquals;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.stream.Collectors;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.RegionMetricsBuilder;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.master.http.RegionVisualizer.RegionDetails;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.gson.Gson;
import org.apache.hbase.thirdparty.com.google.gson.JsonObject;
@Category({ MasterTests.class, SmallTests.class})
public class TestRegionVisualizer {
@ClassRule
public static final HBaseClassTestRule testRule =
HBaseClassTestRule.forClass(TestRegionVisualizer.class);
private static final Random rand = new Random();
private static List<Method> regionMetricsBuilderLongValueSetters;
@BeforeClass
public static void beforeClass() {
regionMetricsBuilderLongValueSetters =
Arrays.stream(RegionMetricsBuilder.class.getDeclaredMethods())
.filter(method -> method.getName().startsWith("set"))
.filter(method -> method.getParameterTypes().length == 1)
.filter(method -> Objects.equals(method.getParameterTypes()[0], long.class))
.collect(Collectors.toList());
}
@Test
public void testRegionDetailsJsonSerialization() throws Exception {
final ServerName serverName =
ServerName.valueOf("example.org", 1234, System.currentTimeMillis());
final TableName tableName = TableName.valueOf("foo", "bar");
final RegionDetails regionDetails =
new RegionDetails(serverName, tableName, buildRegionMetrics(tableName));
final Gson gson = RegionVisualizer.buildGson();
final JsonObject result = gson.fromJson(gson.toJson(regionDetails), JsonObject.class);
Assert.assertNotNull(result);
assertEquals(serverName.toShortString(), result.get("server_name").getAsString());
assertEquals(tableName.getNameAsString(), result.get("table_name").getAsString());
}
/**
* Build a {@link RegionMetrics} object for {@code tableName}. Populates a couple random fields
* with non-empty values.
*/
final RegionMetrics buildRegionMetrics(final TableName tableName) throws Exception {
final List<Method> setters = new ArrayList<>(regionMetricsBuilderLongValueSetters);
Collections.shuffle(setters, rand);
final RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tableName).build();
final RegionMetricsBuilder builder =
RegionMetricsBuilder.newBuilder(regionInfo.getRegionName());
for (final Method setter : setters.subList(0, 3)) {
setter.invoke(builder, rand.nextLong());
}
return builder.build();
}
}

View File

@ -97,6 +97,7 @@
<debug-print-included-work-info>${license.debug.print.included}</debug-print-included-work-info>
<bundled-dependencies>${license.bundles.dependencies}</bundled-dependencies>
<bundled-jquery>${license.bundles.jquery}</bundled-jquery>
<bundled-vega>${license.bundles.vega}</bundled-vega>
<bundled-logo>${license.bundles.logo}</bundled-logo>
<bundled-bootstrap>${license.bundles.bootstrap}</bundled-bootstrap>
</properties>

View File

@ -974,6 +974,8 @@
<exclude>**/parser-date-iso8601.min.js</exclude>
<!-- MIT: bootstrap -->
<exclude>**/src/main/resources/hbase-webapps/static/*/bootstrap*</exclude>
<!-- BSD 3-clause: Vega, Vega-Lite, Vega-Embed -->
<exclude>**/hbase-webapps/static/js/vega*.min.js</exclude>
<!-- vector graphics -->
<exclude>**/*.vm</exclude>
<!-- apache doxia generated -->
@ -1726,6 +1728,8 @@
<license.bundles.bootstrap>false</license.bundles.bootstrap>
<!-- modules that include jquery in their source tree should set true -->
<license.bundles.jquery>false</license.bundles.jquery>
<!-- modules that include vega in their source tree should set true -->
<license.bundles.vega>false</license.bundles.vega>
<tar.name>${project.build.finalName}.tar.gz</tar.name>
<maven.build.timestamp.format>
yyyy-MM-dd'T'HH:mm