Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.apache.hadoop.hbase.generated.master.table_jsp Maven / Gradle / Ivy
package org.apache.hadoop.hbase.generated.master;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.net.URLEncoder;
import static org.apache.commons.lang3.StringEscapeUtils.escapeXml;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.AsyncAdmin;
import org.apache.hadoop.hbase.client.AsyncConnection;
import org.apache.hadoop.hbase.client.CompactionState;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.quotas.QuotaTableUtil;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.util.StringUtils;
import org.apache.hbase.thirdparty.com.google.protobuf.ByteString;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;
import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.Size;
import org.apache.hadoop.hbase.RegionMetricsBuilder;
public final class table_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
/**
* @return An empty region load stamped with the passed in regionInfo
* region name.
*/
private RegionMetrics getEmptyRegionMetrics(final RegionInfo regionInfo) {
return RegionMetricsBuilder.toRegionMetrics(ClusterStatusProtos.RegionLoad.newBuilder().
setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().
setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME).
setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build());
}
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
private static java.util.List _jspx_dependants;
private org.glassfish.jsp.api.ResourceInjector _jspx_resourceInjector;
public java.util.List getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
out.write("\n\n\n\n\n\n\n\n\n\n\n");
out.write('\n');
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
Configuration conf = master.getConfiguration();
MetaTableLocator metaTableLocator = new MetaTableLocator();
String fqtn = request.getParameter("name");
final String escaped_fqtn = StringEscapeUtils.escapeHtml4(fqtn);
Table table;
String tableHeader;
boolean withReplica = false;
boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false);
int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM,
HConstants.DEFAULT_META_REPLICA_NUM);
Map frags = null;
if (showFragmentation) {
frags = FSUtils.getTableFragmentation(master);
}
boolean quotasEnabled = conf.getBoolean("hbase.quota.enabled", false);
String action = request.getParameter("action");
String key = request.getParameter("key");
String left = request.getParameter("left");
String right = request.getParameter("right");
long totalStoreFileSizeMB = 0;
final String numRegionsParam = request.getParameter("numRegions");
// By default, the page render up to 10000 regions to improve the page load time
int numRegionsToRender = 10000;
if (numRegionsParam != null) {
// either 'all' or a number
if (numRegionsParam.equals("all")) {
numRegionsToRender = -1;
} else {
try {
numRegionsToRender = Integer.parseInt(numRegionsParam);
} catch (NumberFormatException ex) {
// ignore
}
}
}
int numRegions = 0;
String pageTitle;
if ( !readOnly && action != null ) {
pageTitle = "HBase Master: " + StringEscapeUtils.escapeHtml4(master.getServerName().toString());
} else {
pageTitle = "Table: " + escaped_fqtn;
}
pageContext.setAttribute("pageTitle", pageTitle);
AsyncConnection connection = ConnectionFactory.createAsyncConnection(master.getConfiguration()).get();
AsyncAdmin admin = connection.getAdminBuilder().setOperationTimeout(5, TimeUnit.SECONDS).build();
out.write('\n');
out.write('\n');
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "header.jsp" + "?" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("pageTitle", request.getCharacterEncoding())+ "=" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${pageTitle}", java.lang.String.class, (PageContext)_jspx_page_context, null), request.getCharacterEncoding()), out, false);
out.write('\n');
out.write('\n');
if (fqtn != null && master.isInitialized()) {
try {
table = master.getConnection().getTable(TableName.valueOf(fqtn));
if (table.getTableDescriptor().getRegionReplication() > 1) {
tableHeader = "Table Regions Name Region Server ReadRequests WriteRequests StorefileSize Num.Storefiles MemSize Locality Start Key End Key ReplicaID ";
withReplica = true;
} else {
tableHeader = "Table Regions Name Region Server ReadRequests WriteRequests StorefileSize Num.Storefiles MemSize Locality Start Key End Key ";
}
if ( !readOnly && action != null ) {
out.write("\n\n
\n \n
\n
\n");
if (action.equals("split")) {
if (key != null && key.length() > 0) {
admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key));
} else {
admin.split(TableName.valueOf(fqtn));
}
out.write(" Split request accepted. ");
} else if (action.equals("compact")) {
if (key != null && key.length() > 0) {
List regions = admin.getRegions(TableName.valueOf(fqtn)).get();
byte[] row = Bytes.toBytes(key);
for (RegionInfo region : regions) {
if (region.containsRow(row)) {
admin.compactRegion(region.getRegionName());
}
}
} else {
admin.compact(TableName.valueOf(fqtn));
}
out.write(" Compact request accepted. ");
} else if (action.equals("merge")) {
if (left != null && left.length() > 0 && right != null && right.length() > 0) {
admin.mergeRegions(Bytes.toBytesBinary(left), Bytes.toBytesBinary(right), false);
}
out.write(" Merge request accepted. ");
}
out.write('\n');
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "redirect.jsp", out, false);
out.write("\n
\n");
} else {
out.write("\n\n
\n \n
\n
\n");
if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) {
out.write('\n');
out.print( tableHeader );
out.write("\n
\n");
// NOTE: Presumes meta with one or more replicas
for (int j = 0; j < numMetaReplicas; j++) {
RegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica(
RegionInfoBuilder.FIRST_META_REGIONINFO, j);
ServerName metaLocation = metaTableLocator.waitMetaRegionLocation(master.getZooKeeper(), j, 1);
for (int i = 0; i < 1; i++) {
String hostAndPort = "";
String readReq = "N/A";
String writeReq = "N/A";
String fileSize = "N/A";
String fileCount = "N/A";
String memSize = "N/A";
float locality = 0.0f;
if (metaLocation != null) {
ServerMetrics sl = master.getServerManager().getLoad(metaLocation);
// The host name portion should be safe, but I don't know how we handle IDNs so err on the side of failing safely.
hostAndPort = URLEncoder.encode(metaLocation.getHostname()) + ":" + master.getRegionServerInfoPort(metaLocation);
if (sl != null) {
Map map = sl.getRegionMetrics();
if (map.containsKey(meta.getRegionName())) {
RegionMetrics load = map.get(meta.getRegionName());
readReq = String.format("%,1d", load.getReadRequestCount());
writeReq = String.format("%,1d", load.getWriteRequestCount());
fileSize = StringUtils.byteDesc((long) load.getStoreFileSize().get(Size.Unit.BYTE));
fileCount = String.format("%,1d", load.getStoreFileCount());
memSize = StringUtils.byteDesc((long) load.getMemStoreSize().get(Size.Unit.BYTE));
locality = load.getDataLocality();
}
}
}
out.write("\n\n ");
out.print( escapeXml(meta.getRegionNameAsString()) );
out.write(" \n ");
out.print( StringEscapeUtils.escapeHtml4(hostAndPort) );
out.write(" \n ");
out.print( readReq);
out.write(" \n ");
out.print( writeReq);
out.write(" \n ");
out.print( fileSize);
out.write(" \n ");
out.print( fileCount);
out.write(" \n ");
out.print( memSize);
out.write(" \n ");
out.print( locality);
out.write(" \n ");
out.print( escapeXml(Bytes.toString(meta.getStartKey())) );
out.write(" \n ");
out.print( escapeXml(Bytes.toString(meta.getEndKey())) );
out.write(" \n");
if (withReplica) {
out.write("\n ");
out.print( meta.getReplicaId() );
out.write(" \n");
}
out.write("\n \n");
}
out.write('\n');
}
out.write("\n \n
\n");
} else {
RegionLocator r = master.getConnection().getRegionLocator(table.getName());
try {
out.write("\nTable Attributes \n\n \n Attribute Name \n Value \n Description \n \n \n Enabled \n ");
out.print( admin.isTableEnabled(table.getName()).get() );
out.write(" \n Is the table enabled \n \n \n Compaction \n \n");
try {
CompactionState compactionState = admin.getCompactionState(table.getName()).get();
out.write('\n');
out.print( compactionState );
out.write('\n');
} catch (Exception e) {
// Nothing really to do here
for(StackTraceElement element : e.getStackTrace()) {
out.print( StringEscapeUtils.escapeHtml4(element.toString()) );
}
out.write(" Unknown ");
}
out.write("\n \n Is the table compacting \n \n");
if (showFragmentation) {
out.write("\n \n Fragmentation \n ");
out.print( frags.get(fqtn) != null ? frags.get(fqtn).intValue() + "%" : "n/a" );
out.write(" \n How fragmented is the table. After a major compaction it is 0%. \n \n");
}
out.write('\n');
if (quotasEnabled) {
TableName tn = TableName.valueOf(fqtn);
SpaceQuotaSnapshot masterSnapshot = null;
Quotas quota = QuotaTableUtil.getTableQuota(master.getConnection(), tn);
if (quota == null || !quota.hasSpace()) {
quota = QuotaTableUtil.getNamespaceQuota(master.getConnection(), tn.getNamespaceAsString());
if (quota != null) {
masterSnapshot = QuotaTableUtil.getCurrentSnapshot(master.getConnection(), tn.getNamespaceAsString());
}
} else {
masterSnapshot = QuotaTableUtil.getCurrentSnapshot(master.getConnection(), tn);
}
if (quota != null && quota.hasSpace()) {
SpaceQuota spaceQuota = quota.getSpace();
out.write("\n \n Space Quota \n \n \n \n Property \n Value \n \n \n Limit \n ");
out.print( StringUtils.byteDesc(spaceQuota.getSoftLimit()) );
out.write(" \n \n \n Policy \n ");
out.print( spaceQuota.getViolationPolicy() );
out.write(" \n \n");
if (masterSnapshot != null) {
out.write("\n \n Usage \n ");
out.print( StringUtils.byteDesc(masterSnapshot.getUsage()) );
out.write(" \n \n \n State \n ");
out.print( masterSnapshot.getQuotaStatus().isInViolation() ? "In Violation" : "In Observance" );
out.write(" \n \n");
}
out.write("\n
\n \n Information about a Space Quota on this table, if set. \n \n");
}
}
out.write("\n
\nTable Schema \n\n \n Column Name \n \n \n ");
Collection families = table.getTableDescriptor().getFamilies();
for (HColumnDescriptor family: families) {
out.write("\n \n ");
out.print( StringEscapeUtils.escapeHtml4(family.getNameAsString()) );
out.write(" \n \n \n \n Property \n Value \n \n ");
Map familyValues = family.getValues();
for (Bytes familyKey: familyValues.keySet()) {
out.write("\n \n \n ");
out.print( StringEscapeUtils.escapeHtml4(familyKey.toString()) );
out.write("\n\t\t \n \n ");
out.print( StringEscapeUtils.escapeHtml4(familyValues.get(familyKey).toString()) );
out.write("\n \n \n ");
}
out.write("\n
\n \n \n ");
}
out.write("\n
\n");
long totalReadReq = 0;
long totalWriteReq = 0;
long totalSize = 0;
long totalStoreFileCount = 0;
long totalMemSize = 0;
String urlRegionServer = null;
Map regDistribution = new TreeMap<>();
Map primaryRegDistribution = new TreeMap<>();
List regions = r.getAllRegionLocations();
Map regionsToLoad = new LinkedHashMap<>();
Map regionsToServer = new LinkedHashMap<>();
for (HRegionLocation hriEntry : regions) {
RegionInfo regionInfo = hriEntry.getRegionInfo();
ServerName addr = hriEntry.getServerName();
regionsToServer.put(regionInfo, addr);
if (addr != null) {
ServerMetrics sl = master.getServerManager().getLoad(addr);
if (sl != null) {
RegionMetrics regionMetrics = sl.getRegionMetrics().get(regionInfo.getRegionName());
regionsToLoad.put(regionInfo, regionMetrics);
if(regionMetrics != null) {
totalReadReq += regionMetrics.getReadRequestCount();
totalWriteReq += regionMetrics.getWriteRequestCount();
totalSize += regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE);
totalStoreFileCount += regionMetrics.getStoreFileCount();
totalMemSize += regionMetrics.getMemStoreSize().get(Size.Unit.MEGABYTE);
totalStoreFileSizeMB += regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE);
} else {
RegionMetrics load0 = getEmptyRegionMetrics(regionInfo);
regionsToLoad.put(regionInfo, load0);
}
} else{
RegionMetrics load0 = getEmptyRegionMetrics(regionInfo);
regionsToLoad.put(regionInfo, load0);
}
} else {
RegionMetrics load0 = getEmptyRegionMetrics(regionInfo);
regionsToLoad.put(regionInfo, load0);
}
}
if(regions != null && regions.size() > 0) {
out.write("\nTable Regions \n\n\n\nName(");
out.print( String.format("%,1d", regions.size()));
out.write(") \nRegion Server \nReadRequests (");
out.print( String.format("%,1d", totalReadReq));
out.write(") \nWriteRequests (");
out.print( String.format("%,1d", totalWriteReq));
out.write(") \nStorefileSize (");
out.print( StringUtils.byteDesc(totalSize*1024l*1024));
out.write(") \nNum.Storefiles (");
out.print( String.format("%,1d", totalStoreFileCount));
out.write(") \nMemSize (");
out.print( StringUtils.byteDesc(totalMemSize*1024l*1024));
out.write(") \nLocality \nStart Key \nEnd Key \n");
if (withReplica) {
out.write("\nReplicaID \n");
}
out.write("\n \n\n\n\n");
List> entryList = new ArrayList<>(regionsToLoad.entrySet());
numRegions = regions.size();
int numRegionsRendered = 0;
// render all regions
if (numRegionsToRender < 0) {
numRegionsToRender = numRegions;
}
for (Map.Entry hriEntry : entryList) {
RegionInfo regionInfo = hriEntry.getKey();
ServerName addr = regionsToServer.get(regionInfo);
RegionMetrics load = hriEntry.getValue();
String readReq = "N/A";
String writeReq = "N/A";
String regionSize = "N/A";
String fileCount = "N/A";
String memSize = "N/A";
float locality = 0.0f;
if(load != null) {
readReq = String.format("%,1d", load.getReadRequestCount());
writeReq = String.format("%,1d", load.getWriteRequestCount());
regionSize = StringUtils.byteDesc((long) load.getStoreFileSize().get(Size.Unit.BYTE));
fileCount = String.format("%,1d", load.getStoreFileCount());
memSize = StringUtils.byteDesc((long) load.getMemStoreSize().get(Size.Unit.BYTE));
locality = load.getDataLocality();
}
if (addr != null) {
ServerMetrics sl = master.getServerManager().getLoad(addr);
// This port might be wrong if RS actually ended up using something else.
urlRegionServer =
"//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status";
if(sl != null) {
Integer i = regDistribution.get(addr);
if (null == i) i = Integer.valueOf(0);
regDistribution.put(addr, i + 1);
if (withReplica && RegionReplicaUtil.isDefaultReplica(regionInfo.getReplicaId())) {
i = primaryRegDistribution.get(addr);
if (null == i) i = Integer.valueOf(0);
primaryRegDistribution.put(addr, i+1);
}
}
}
if (numRegionsRendered < numRegionsToRender) {
numRegionsRendered++;
out.write("\n\n ");
out.print( escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) );
out.write(" \n ");
if (urlRegionServer != null) {
out.write("\n \n ');
out.print( addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) );
out.write(" \n \n ");
} else {
out.write("\n not deployed \n ");
}
out.write("\n ");
out.print( readReq);
out.write(" \n ");
out.print( writeReq);
out.write(" \n ");
out.print( regionSize);
out.write(" \n ");
out.print( fileCount);
out.write(" \n ");
out.print( memSize);
out.write(" \n ");
out.print( locality);
out.write(" \n ");
out.print( escapeXml(Bytes.toStringBinary(regionInfo.getStartKey())));
out.write(" \n ");
out.print( escapeXml(Bytes.toStringBinary(regionInfo.getEndKey())));
out.write(" \n ");
if (withReplica) {
out.write("\n ");
out.print( regionInfo.getReplicaId() );
out.write(" \n ");
}
out.write("\n \n");
}
out.write('\n');
}
out.write("\n \n
\n");
if (numRegions > numRegionsRendered) {
String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all";
out.write("\n This table has ");
out.print( numRegions );
out.write(" regions in total, in order to improve the page load time,\n only ");
out.print( numRegionsRendered );
out.write(" regions are displayed here, click\n here to see all regions.
\n");
}
out.write("\nRegions by Region Server \n");
if (withReplica) {
out.write("\nRegion Server Region Count Primary Region Count \n");
} else {
out.write("\n\n");
}
} catch(Exception ex) {
for(StackTraceElement element : ex.getStackTrace()) {
out.print( StringEscapeUtils.escapeHtml4(element.toString()) );
}
} finally {
connection.close();
}
} // end else
out.write("\n\nTable Stats \n\n \n Name \n Value \n Description \n \n \n Size \n ");
out.print( StringUtils.TraditionalBinaryPrefix.long2String(totalStoreFileSizeMB * 1024 * 1024, "B", 2));
out.write(" \n Total size of store files \n \n
\n\n");
if (!readOnly) {
out.write("\n
\nActions:\n\n
\n\n \n\n");
}
out.write("\n\n\n");
}
} catch(TableNotFoundException e) {
out.write("\n ");
} catch(IllegalArgumentException e) {
out.write("\n ");
}
}
else { // handle the case for fqtn is null or master is not initialized with error message + redirect
out.write("\n\n
\n \n
\n
\n");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "redirect.jsp", out, false);
out.write("\n
\n");
}
out.write('\n');
out.write('\n');
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "footer.jsp", out, false);
out.write("\n\n\n\n\n\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}