Delete unused items from monitor
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cc8d3353 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cc8d3353 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cc8d3353 Branch: refs/heads/master Commit: cc8d335332afc8fae3d6083dd4a163e93c71ac88 Parents: 0ca5cd3 Author: Christopher Tubbs <[email protected]> Authored: Tue Apr 4 17:13:11 2017 -0400 Committer: Christopher Tubbs <[email protected]> Committed: Thu Jul 6 16:22:41 2017 -0400 ---------------------------------------------------------------------- .../accumulo/monitor/EmbeddedWebServer.java | 65 ++-- .../org/apache/accumulo/monitor/Monitor.java | 34 +- .../monitor/rest/api/trace/TracesResource.java | 49 ++- .../rest/api/tserver/TabletServerResource.java | 2 +- .../accumulo/monitor/servlets/BasicServlet.java | 279 -------------- .../monitor/servlets/OperationServlet.java | 202 ---------- .../monitor/servlets/ProblemServlet.java | 196 ---------- .../monitor/servlets/ReplicationServlet.java | 164 --------- .../accumulo/monitor/servlets/ShellServlet.java | 369 ------------------- .../servlets/StaticWebResourcesServlet.java | 30 -- .../servlets/trace/NullKeyValueIterator.java | 40 -- .../monitor/servlets/trace/NullScanner.java | 159 -------- .../org/apache/accumulo/monitor/util/Table.java | 276 -------------- .../accumulo/monitor/util/TableColumn.java | 48 --- .../apache/accumulo/monitor/util/TableRow.java | 68 ---- .../monitor/util/celltypes/CellType.java | 38 -- .../monitor/util/celltypes/DateTimeType.java | 67 ---- .../monitor/util/celltypes/DurationType.java | 52 --- .../monitor/util/celltypes/NumberType.java | 119 ------ .../monitor/util/celltypes/StringType.java | 42 --- .../src/main/resources/resources/summary.js | 2 +- .../ThriftServerBindsBeforeZooKeeperLockIT.java | 4 +- 22 files changed, 72 insertions(+), 2233 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/EmbeddedWebServer.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/EmbeddedWebServer.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/EmbeddedWebServer.java index 2befd37..43261ea 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/EmbeddedWebServer.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/EmbeddedWebServer.java @@ -16,40 +16,48 @@ */ package org.apache.accumulo.monitor; -import javax.servlet.http.HttpServlet; +import java.util.EnumSet; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; import org.apache.commons.lang.StringUtils; import org.eclipse.jetty.security.ConstraintMapping; import org.eclipse.jetty.security.ConstraintSecurityHandler; +import org.eclipse.jetty.server.AbstractConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.security.Constraint; import org.eclipse.jetty.util.ssl.SslContextFactory; public class EmbeddedWebServer { - private static String EMPTY = ""; - - Server server = null; - ServerConnector connector = null; - ServletContextHandler handler; - boolean usingSsl; - - public EmbeddedWebServer() { - this("0.0.0.0", 0); - } + private final Server server; + private final ServerConnector connector; + private final ServletContextHandler handler; public EmbeddedWebServer(String host, int port) { server = new Server(); final AccumuloConfiguration conf = Monitor.getContext().getConfiguration(); - if (EMPTY.equals(conf.get(Property.MONITOR_SSL_KEYSTORE)) || EMPTY.equals(conf.get(Property.MONITOR_SSL_KEYSTOREPASS)) - || EMPTY.equals(conf.get(Property.MONITOR_SSL_TRUSTSTORE)) || EMPTY.equals(conf.get(Property.MONITOR_SSL_TRUSTSTOREPASS))) { - connector = new ServerConnector(server, new HttpConnectionFactory()); - usingSsl = false; + connector = new ServerConnector(server, getConnectionFactory(conf)); + connector.setHost(host); + connector.setPort(port); + + handler = new ServletContextHandler(ServletContextHandler.SESSIONS | ServletContextHandler.SECURITY); + handler.getSessionHandler().getSessionManager().getSessionCookieConfig().setHttpOnly(true); + handler.setContextPath("/"); + + // constraint security handler gets instantiated as the default when retrieved + ((ConstraintSecurityHandler) handler.getSecurityHandler()).addConstraintMapping(disableTraceConstraint("/")); + } + + private static AbstractConnectionFactory getConnectionFactory(AccumuloConfiguration conf) { + EnumSet<Property> requireForSecure = EnumSet.of(Property.MONITOR_SSL_KEYSTORE, Property.MONITOR_SSL_KEYSTOREPASS, Property.MONITOR_SSL_TRUSTSTORE, + Property.MONITOR_SSL_TRUSTSTOREPASS); + if (requireForSecure.stream().map(p -> conf.get(p)).anyMatch(s -> s == null || s.isEmpty())) { + return new HttpConnectionFactory(); } else { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(conf.get(Property.MONITOR_SSL_KEYSTORE)); @@ -74,28 +82,15 @@ public class EmbeddedWebServer { sslContextFactory.setIncludeProtocols(StringUtils.split(includeProtocols, ',')); } - connector = new ServerConnector(server, sslContextFactory); - usingSsl = true; + return new SslConnectionFactory(sslContextFactory, new HttpConnectionFactory().getProtocol()); } - - connector.setHost(host); - connector.setPort(port); - - handler = new ServletContextHandler(ServletContextHandler.SESSIONS | ServletContextHandler.SECURITY); - handler.getSessionHandler().getSessionManager().getSessionCookieConfig().setHttpOnly(true); - handler.setContextPath("/"); - disableTrace("/"); - } - - public ServletHolder addServlet(Class<? extends HttpServlet> klass, String where) { - return handler.addServlet(klass, where); } public void addServlet(ServletHolder restServlet, String where) { handler.addServlet(restServlet, where); } - private void disableTrace(String where) { + private static ConstraintMapping disableTraceConstraint(String where) { Constraint constraint = new Constraint(); constraint.setName("Disable TRACE"); constraint.setAuthenticate(true); // require auth, but no roles defined, so it'll never match @@ -105,8 +100,7 @@ public class EmbeddedWebServer { mapping.setMethod("TRACE"); mapping.setPathSpec(where); - ConstraintSecurityHandler security = (ConstraintSecurityHandler) handler.getSecurityHandler(); - security.addConstraintMapping(mapping); + return mapping; } public int getPort() { @@ -124,18 +118,15 @@ public class EmbeddedWebServer { } } - public void stop() { + private void stop() { try { server.stop(); + server.join(); } catch (Exception e) { throw new RuntimeException(e); } } - public boolean isUsingSsl() { - return usingSsl; - } - public boolean isRunning() { return server.isRunning(); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java index 03d81f1..984eb3d 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java @@ -64,8 +64,6 @@ import org.apache.accumulo.fate.util.LoggingRunnable; import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy; -import org.apache.accumulo.monitor.servlets.ShellServlet; -import org.apache.accumulo.monitor.servlets.StaticWebResourcesServlet; import org.apache.accumulo.server.Accumulo; import org.apache.accumulo.server.AccumuloServerContext; import org.apache.accumulo.server.HighlyAvailableService; @@ -84,15 +82,15 @@ import org.apache.accumulo.server.util.time.SimpleTimer; import org.apache.accumulo.server.zookeeper.ZooLock; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; import org.apache.zookeeper.KeeperException; +import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.resource.Resource; import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.mvc.MvcFeature; import org.glassfish.jersey.server.mvc.freemarker.FreemarkerMvcFeature; import org.glassfish.jersey.servlet.ServletContainer; -import org.glassfish.jersey.servlet.ServletProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -466,11 +464,7 @@ public class Monitor implements HighlyAvailableService { try { log.debug("Creating monitor on port " + port); server = new EmbeddedWebServer(hostname, port); - server.addServlet(StaticWebResourcesServlet.class, "/resources/*"); - // server.addServlet(OperationServlet.class, "/op"); - // server.addServlet(ProblemServlet.class, "/problems"); - if (server.isUsingSsl()) - server.addServlet(ShellServlet.class, "/shell"); + server.addServlet(getDefaultServlet(), "/resources/*"); server.addServlet(getRestServlet(), "/*"); server.start(); break; @@ -551,13 +545,22 @@ public class Monitor implements HighlyAvailableService { monitorInitialized.set(true); } + private ServletHolder getDefaultServlet() { + return new ServletHolder(new DefaultServlet() { + private static final long serialVersionUID = 1L; + + @Override + public Resource getResource(String pathInContext) { + return Resource.newClassPathResource(pathInContext); + } + }); + } + private ServletHolder getRestServlet() { final ResourceConfig rc = new ResourceConfig().register(FreemarkerMvcFeature.class) .register(new LoggingFeature(java.util.logging.Logger.getLogger(this.getClass().getSimpleName()))).register(JacksonFeature.class) - .packages("org.apache.accumulo.monitor.rest").property(MvcFeature.TEMPLATE_BASE_PATH, "/templates").property(ServerProperties.TRACING, "ALL") - .property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/resources/.*"); - ServletHolder holder = new ServletHolder(new ServletContainer(rc)); - return holder; + .packages("org.apache.accumulo.monitor.rest").property(MvcFeature.TEMPLATE_BASE_PATH, "/templates"); + return new ServletHolder(new ServletContainer(rc)); } public static class ScanStats { @@ -848,10 +851,6 @@ public class Monitor implements HighlyAvailableService { } } - public static boolean isUsingSsl() { - return server.isUsingSsl(); - } - public static AccumuloServerContext getContext() { return context; } @@ -860,4 +859,5 @@ public class Monitor implements HighlyAvailableService { public boolean isActiveService() { return monitorInitialized.get(); } + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/trace/TracesResource.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/trace/TracesResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/trace/TracesResource.java index bc77ece..7e14abf 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/trace/TracesResource.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/trace/TracesResource.java @@ -22,13 +22,13 @@ import static java.nio.charset.StandardCharsets.UTF_8; import java.io.IOException; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; -import java.util.AbstractMap; import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -47,9 +47,9 @@ import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.util.Pair; import org.apache.accumulo.monitor.Monitor; import org.apache.accumulo.monitor.rest.api.BasicResource; -import org.apache.accumulo.monitor.servlets.trace.NullScanner; import org.apache.accumulo.server.client.HdfsZooInstance; import org.apache.accumulo.server.security.SecurityUtil; import org.apache.accumulo.tracer.SpanTree; @@ -79,22 +79,22 @@ public class TracesResource extends BasicResource { */ @Path("/summary/{minutes}") @GET - public RecentTracesList getTraces(@PathParam("minutes") int minutes) throws Exception { + public RecentTracesList getTraces(@DefaultValue("10") @PathParam("minutes") int minutes) throws Exception { RecentTracesList recentTraces = new RecentTracesList(); - Entry<Scanner,UserGroupInformation> pair = getScanner(); - final Scanner scanner = pair.getKey(); + Pair<Scanner,UserGroupInformation> pair = getScanner(); + final Scanner scanner = pair.getFirst(); if (scanner == null) { - return null; + return recentTraces; } Range range = getRangeForTrace(minutes); scanner.setRange(range); final Map<String,RecentTracesInformation> summary = new TreeMap<>(); - if (null != pair.getValue()) { - pair.getValue().doAs(new PrivilegedAction<Void>() { + if (null != pair.getSecond()) { + pair.getSecond().doAs(new PrivilegedAction<Void>() { @Override public Void run() { parseSpans(scanner, summary); @@ -128,18 +128,18 @@ public class TracesResource extends BasicResource { TraceType typeTraces = new TraceType(type); - Entry<Scanner,UserGroupInformation> pair = getScanner(); - final Scanner scanner = pair.getKey(); + Pair<Scanner,UserGroupInformation> pair = getScanner(); + final Scanner scanner = pair.getFirst(); if (scanner == null) { - return null; + return typeTraces; } Range range = getRangeForTrace(minutes); scanner.setRange(range); - if (null != pair.getValue()) { - pair.getValue().doAs(new PrivilegedAction<Void>() { + if (null != pair.getSecond()) { + pair.getSecond().doAs(new PrivilegedAction<Void>() { @Override public Void run() { for (Entry<Key,Value> entry : scanner) { @@ -179,10 +179,10 @@ public class TracesResource extends BasicResource { return null; } - Entry<Scanner,UserGroupInformation> entry = getScanner(); - final Scanner scanner = entry.getKey(); + Pair<Scanner,UserGroupInformation> entry = getScanner(); + final Scanner scanner = entry.getFirst(); if (scanner == null) { - return null; + return traces; } Range range = new Range(new Text(id)); @@ -190,8 +190,8 @@ public class TracesResource extends BasicResource { final SpanTree tree = new SpanTree(); long start; - if (null != entry.getValue()) { - start = entry.getValue().doAs(new PrivilegedAction<Long>() { + if (null != entry.getSecond()) { + start = entry.getSecond().doAs(new PrivilegedAction<Long>() { @Override public Long run() { return addSpans(scanner, tree, Long.MAX_VALUE); @@ -273,7 +273,7 @@ public class TracesResource extends BasicResource { } } - protected Entry<Scanner,UserGroupInformation> getScanner() throws AccumuloException, AccumuloSecurityException { + protected Pair<Scanner,UserGroupInformation> getScanner() throws AccumuloException, AccumuloSecurityException { AccumuloConfiguration conf = Monitor.getContext().getConfiguration(); final boolean saslEnabled = conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED); UserGroupInformation traceUgi = null; @@ -343,21 +343,18 @@ public class TracesResource extends BasicResource { scanner = getScanner(table, principal, at); } - return new AbstractMap.SimpleEntry<>(scanner, traceUgi); + return new Pair<>(scanner, traceUgi); } private Scanner getScanner(String table, String principal, AuthenticationToken at) throws AccumuloException, AccumuloSecurityException { try { Connector conn = HdfsZooInstance.getInstance().getConnector(principal, at); if (!conn.tableOperations().exists(table)) { - return new NullScanner(); + return null; } - Scanner scanner = conn.createScanner(table, conn.securityOperations().getUserAuthorizations(principal)); - return scanner; - } catch (AccumuloSecurityException ex) { + return conn.createScanner(table, conn.securityOperations().getUserAuthorizations(principal)); + } catch (AccumuloSecurityException | TableNotFoundException ex) { return null; - } catch (TableNotFoundException ex) { - return new NullScanner(); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/tserver/TabletServerResource.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/tserver/TabletServerResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/tserver/TabletServerResource.java index b04f9ec..9cfdea8 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/tserver/TabletServerResource.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/api/tserver/TabletServerResource.java @@ -128,7 +128,7 @@ public class TabletServerResource extends BasicResource { for (RecoveryStatus recovery : server.logSorts) { recoveryObj.put("server", AddressUtil.parseAddress(server.name, false).getHostText()); recoveryObj.put("log", recovery.name); - recoveryObj.put("time", Long.toString((long) recovery.runtime)); + recoveryObj.put("time", Long.toString(recovery.runtime)); recoveryObj.put("copySort", Double.toString(recovery.progress)); recoveryList.add(recoveryObj); http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java deleted file mode 100644 index 27f479b..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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.accumulo.monitor.servlets; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.Date; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.accumulo.core.Constants; -import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.server.monitor.DedupedLogEvent; -import org.apache.accumulo.server.monitor.LogService; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -abstract public class BasicServlet extends HttpServlet { - public static final String STANDBY_MONITOR_MESSAGE = "This is not the active Monitor"; - - private static final long serialVersionUID = 1L; - protected static final Logger log = Logger.getLogger(BasicServlet.class); - private String bannerText; - private String bannerColor; - private String bannerBackground; - - abstract protected String getTitle(HttpServletRequest req); - - public boolean isActiveMonitor() { - // If the HighlyAvailableService is not initialized or it's not the active service, throw an exception - // to prevent processing of the servlet. - if (null == Monitor.HA_SERVICE_INSTANCE || !Monitor.HA_SERVICE_INSTANCE.isActiveService()) { - return false; - } - return true; - } - - @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - StringBuilder sb = new StringBuilder(); - try { - Monitor.fetchData(); - bannerText = sanitize(Monitor.getContext().getConfiguration().get(Property.MONITOR_BANNER_TEXT)); - bannerColor = Monitor.getContext().getConfiguration().get(Property.MONITOR_BANNER_COLOR).replace("'", "'"); - bannerBackground = Monitor.getContext().getConfiguration().get(Property.MONITOR_BANNER_BACKGROUND).replace("'", "'"); - pageStart(req, resp, sb); - pageBody(req, resp, sb); - pageEnd(req, resp, sb); - } catch (Throwable t) { - log.error("Error building page " + req.getRequestURI(), t); - sb.append("\n<pre>\n"); - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - sb.append(sanitize(sw.getBuffer().toString())); - sb.append("</pre>\n"); - } finally { - resp.getWriter().print(sb); - resp.getWriter().flush(); - } - } - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - doGet(req, resp); - } - - private static final String DEFAULT_CONTENT_TYPE = "text/html"; - - public static final void setCookie(HttpServletResponse resp, String name, String value) { - resp.addCookie(new Cookie(name, value)); - } - - public static final String getCookieValue(HttpServletRequest req, String name) { - if (req.getCookies() != null) - for (Cookie c : req.getCookies()) - if (c.getName().equals(name)) - return c.getValue(); - return null; - } - - protected void pageStart(HttpServletRequest req, HttpServletResponse resp, StringBuilder sb) throws Exception { - resp.setContentType(DEFAULT_CONTENT_TYPE); - int refresh = -1; - String refreshStr = getCookieValue(req, "page.refresh.rate"); - if (refreshStr != null) { - try { - refresh = Integer.parseInt(BasicServlet.decode(refreshStr)); - } catch (NumberFormatException e) { - // ignore improperly formatted user cookie - } - } - - // BEGIN PAGE - sb.append("<!--\n"); - sb.append(" Licensed to the Apache Software Foundation (ASF) under one or more\n"); - sb.append(" contributor license agreements. See the NOTICE file distributed with\n"); - sb.append(" this work for additional information regarding copyright ownership.\n"); - sb.append(" The ASF licenses this file to You under the Apache License, Version 2.0\n"); - sb.append(" (the \"License\"); you may not use this file except in compliance with\n"); - sb.append(" the License. You may obtain a copy of the License at\n"); - sb.append("\n"); - sb.append(" http://www.apache.org/licenses/LICENSE-2.0\n"); - sb.append("\n"); - sb.append(" Unless required by applicable law or agreed to in writing, software\n"); - sb.append(" distributed under the License is distributed on an \"AS IS\" BASIS,\n"); - sb.append(" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"); - sb.append(" See the License for the specific language governing permissions and\n"); - sb.append(" limitations under the License.\n"); - sb.append("-->\n"); - sb.append("<html>\n"); - - // BEGIN HEADER - sb.append("<head>\n"); - sb.append("<title>").append(getTitle(req)).append(" - Accumulo ").append(Constants.VERSION).append("</title>\n"); - if ((refresh > 0) && (req.getRequestURI().startsWith("/vis") == false) && (req.getRequestURI().startsWith("/shell") == false)) - sb.append("<meta http-equiv='refresh' content='" + refresh + "' />\n"); - sb.append("<meta http-equiv='Content-Type' content='").append(DEFAULT_CONTENT_TYPE).append("' />\n"); - sb.append("<meta http-equiv='Content-Script-Type' content='text/javascript' />\n"); - sb.append("<meta http-equiv='Content-Style-Type' content='text/css' />\n"); - sb.append("<link rel='shortcut icon' type='image/jpg' href='/resources/favicon.png' />\n"); - sb.append("<link rel='stylesheet' type='text/css' href='/resources/screen.css' media='screen' />\n"); - sb.append("<script src='/resources/functions.js' type='text/javascript'></script>\n"); - - sb.append("<!--[if lte IE 8]><script language=\"javascript\" type=\"text/javascript\" src=\"/resources/flot/excanvas.min.js\"></script><![endif]-->\n"); - sb.append("<script language=\"javascript\" type=\"text/javascript\" src=\"/resources/flot/jquery.js\"></script>\n"); - sb.append("<script language=\"javascript\" type=\"text/javascript\" src=\"/resources/flot/jquery.flot.js\"></script>\n"); - - sb.append("</head>\n"); - - // BEGIN BODY OPENING - sb.append("\n<body ").append(getBodyAttributes()).append(">\n"); - sb.append("<div id='content-wrapper'>\n"); - sb.append("<div id='content'>\n"); - sb.append("<div id='header'>"); - if (!bannerText.isEmpty()) { - sb.append("<div id='banner' style='color:").append(bannerColor).append(";background:").append(bannerBackground).append("'>").append(bannerText) - .append("</div>\n"); - } - sb.append("<div id='headertitle'>"); - sb.append("<h1>").append(getTitle(req)).append("</h1></div>\n"); - sb.append("<div id='subheader'>Instance Name: ").append(Monitor.cachedInstanceName.get()).append(" Version: ") - .append(Constants.VERSION).append("\n"); - sb.append("<br><span class='smalltext'>Instance ID: ").append(Monitor.getContext().getInstance().getInstanceID()).append("</span>\n"); - sb.append("<br><span class='smalltext'>").append(new Date().toString().replace(" ", " ")).append("</span>"); - sb.append("</div>\n"); // end <div id='subheader'> - sb.append("</div>\n"); // end <div id='header'> - - // BEGIN LEFT SIDE - sb.append("<div id='nav'>\n"); - sb.append("<span id='nav-title'><a href='/'>Overview</a></span><br />\n"); - sb.append("<hr />\n"); - sb.append("<a href='/master'>Master Server</a><br />\n"); - sb.append("<a href='/tservers'>Tablet Servers</a><br />\n"); - sb.append("<a href='/scans'>Active Scans</a><br />\n"); - sb.append("<a href='/bulkImports'>Bulk Imports</a><br />\n"); - sb.append("<a href='/vis'>Server Activity</a><br />\n"); - sb.append("<a href='/gc'>Garbage Collector</a><br />\n"); - sb.append("<a href='/tables'>Tables</a><br />\n"); - sb.append("<a href='/trace/summary?minutes=10'>Recent Traces</a><br />\n"); - sb.append("<a href='/replication'>Replication</a><br />\n"); - List<DedupedLogEvent> dedupedLogEvents = LogService.getInstance().getEvents(); - int numLogs = dedupedLogEvents.size(); - boolean logsHaveError = false; - for (DedupedLogEvent dedupedLogEvent : dedupedLogEvents) - if (dedupedLogEvent.getEvent().getLevel().isGreaterOrEqual(Level.ERROR)) { - logsHaveError = true; - break; - } - if (numLogs > 0) - sb.append("<span class='" + (logsHaveError ? "error" : "warning") + "'><a href='/log'>Recent Logs <span class='smalltext'>(" + numLogs - + ")</a></span></span><br />\n"); - int numProblems = Monitor.getProblemSummary().entrySet().size(); - if (numProblems > 0) - sb.append("<span class='error'><a href='/problems'>Table Problems <span class='smalltext'>(" + numProblems + ")</a></span></span><br />\n"); - sb.append("<hr />\n"); - sb.append("<a href='/xml'>XML</a><br />\n"); - sb.append("<a href='/json'>JSON</a><hr />\n"); - if (Monitor.isUsingSsl()) - sb.append("<a href='/shell'>Shell</a><hr />\n"); - sb.append("<div class='smalltext'>[<a href='").append("/op?action=refresh&value=").append(refresh < 1 ? "5" : "-1"); - sb.append("&redir=").append(currentPage(req)).append("'>"); - sb.append(refresh < 1 ? "en" : "dis").append("able auto-refresh</a>]</div><hr />\n"); - sb.append("<div class='smalltext'><a href='https://accumulo.apache.org/' target='_blank'>Apache Accumulo</a></div>\n"); - sb.append("</div>\n"); // end <div id='nav'> - - sb.append("<div id='main'"); - if (bannerText.isEmpty()) - sb.append(" style='bottom:0'"); - sb.append(">\n"); - sb.append("<!-- BEGIN MAIN BODY CONTENT -->\n\n"); - } - - protected void pageBody(HttpServletRequest req, HttpServletResponse resp, StringBuilder sb) throws Exception { - sb.append("This page intentionally left blank."); - } - - protected void pageEnd(HttpServletRequest req, HttpServletResponse resp, StringBuilder sb) throws Exception { - sb.append("\n<!-- END MAIN BODY CONTENT -->\n"); - sb.append("</div>\n"); // end <div id='main'> - - // BEGIN FOOTER - sb.append("</div>\n"); // end <div id='content'> - sb.append("</div>\n"); // end <div id='content-wrapper'> - if (!bannerText.isEmpty()) { - sb.append("<div id='footer' style='color:").append(bannerColor).append(";background:").append(bannerBackground).append("'>").append(bannerText) - .append("</div>\n"); - } - sb.append("</body>\n"); - sb.append("</html>\n"); - } - - /** - * Allow the concrete servlet implementation to provide attributes on the body HTML tag, such as 'onload', which can be used to call Javascript methods on - * page load. By default, nothing is specified. - */ - protected String getBodyAttributes() { - return ""; - } - - public static String encode(String s) { - try { - return URLEncoder.encode(s, UTF_8.name()); - } catch (UnsupportedEncodingException e) { - Logger.getLogger(BasicServlet.class).fatal(UTF_8.name() + " is not a recognized encoding", e); - throw new AssertionError(e); // can't happen with UTF-8 - } - } - - public static String decode(String s) { - try { - return URLDecoder.decode(s, UTF_8.name()); - } catch (UnsupportedEncodingException e) { - Logger.getLogger(BasicServlet.class).fatal(UTF_8.name() + " is not a recognized encoding", e); - throw new AssertionError(e); // can't happen with UTF-8 - } - } - - public static String sanitize(String xml) { - return xml.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"); - } - - public static String currentPage(HttpServletRequest req) { - String redir = req.getRequestURI(); - if (req.getQueryString() != null) - redir += "?" + req.getQueryString(); - return encode(redir); - } - - protected static void banner(StringBuilder sb, String klass, String text) { - sb.append("<br />\n<h2 class='").append(klass).append("'>").append(text).append("</h2>\n"); - } - -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/OperationServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/OperationServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/OperationServlet.java deleted file mode 100644 index 0792d56..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/OperationServlet.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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.accumulo.monitor.servlets; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.accumulo.core.Constants; -import org.apache.accumulo.core.zookeeper.ZooUtil; -import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.server.master.state.DeadServerList; -import org.apache.accumulo.server.monitor.LogService; -import org.apache.accumulo.server.problems.ProblemReports; -import org.apache.accumulo.server.problems.ProblemType; -import org.apache.log4j.Logger; - -public class OperationServlet extends BasicServlet { - - private static final long serialVersionUID = 1L; - - @Override - protected String getTitle(HttpServletRequest req) { - return "Operations"; - } - - @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { - String redir = null; - List<Cookie> cookiesToSet = Collections.emptyList(); - try { - String operation = req.getParameter("action"); - redir = req.getParameter("redir"); - - if (operation != null) { - for (Class<?> subclass : OperationServlet.class.getClasses()) { - Object t; - try { - t = subclass.newInstance(); - } catch (Exception e) { - continue; - } - if (t instanceof WebOperation) { - WebOperation op = (WebOperation) t; - if (op.getClass().getSimpleName().equalsIgnoreCase(operation + "Operation")) { - cookiesToSet = op.execute(req, log); - break; - } - } - } - } - } catch (Throwable t) { - log.error(t, t); - } finally { - try { - for (Cookie c : cookiesToSet) { - resp.addCookie(c); - } - resp.sendRedirect(sanitizeRedirect(redir)); - resp.flushBuffer(); - } catch (Throwable t) { - log.error(t, t); - } - } - } - - private static String sanitizeRedirect(final String url) { - if (url == null || url.isEmpty() || url.contains("\r") || url.contains("\n")) { - // prevent HTTP response splitting - return "/"; - } - return url.startsWith("/") ? url : ("/" + url); - } - - private interface WebOperation { - List<Cookie> execute(HttpServletRequest req, Logger log) throws Exception; - } - - public static class RefreshOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) { - String value = req.getParameter("value"); - return Collections.singletonList(new Cookie("page.refresh.rate", value == null ? "5" : BasicServlet.encode(value))); - } - } - - public static class ClearLogOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) { - LogService.getInstance().clear(); - return Collections.emptyList(); - } - } - - public static class ClearTableProblemsOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) { - String table = req.getParameter("table"); - try { - ProblemReports.getInstance(Monitor.getContext()).deleteProblemReports(table); - } catch (Exception e) { - log.error("Failed to delete problem reports for table " + table, e); - } - return Collections.emptyList(); - } - } - - public static class ClearProblemOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) { - String table = req.getParameter("table"); - String resource = req.getParameter("resource"); - String ptype = req.getParameter("ptype"); - try { - ProblemReports.getInstance(Monitor.getContext()).deleteProblemReport(table, ProblemType.valueOf(ptype), resource); - } catch (Exception e) { - log.error("Failed to delete problem reports for table " + table, e); - } - return Collections.emptyList(); - } - } - - public static class SortTableOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) throws IOException { - String page = req.getParameter("page"); - String table = req.getParameter("table"); - String asc = req.getParameter("asc"); - String col = req.getParameter("col"); - if (table == null || page == null || (asc == null && col == null)) - return Collections.emptyList(); - page = BasicServlet.encode(page); - table = BasicServlet.encode(table); - if (asc == null) { - col = BasicServlet.encode(col); - return Collections.singletonList(new Cookie("tableSort." + page + "." + table + "." + "sortCol", col)); - } else { - asc = BasicServlet.encode(asc); - return Collections.singletonList(new Cookie("tableSort." + page + "." + table + "." + "sortAsc", asc)); - } - } - } - - public static class ToggleLegendOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) throws Exception { - String page = req.getParameter("page"); - String table = req.getParameter("table"); - String show = req.getParameter("show"); - if (table == null || page == null || show == null) - return Collections.emptyList(); - page = BasicServlet.encode(page); - table = BasicServlet.encode(table); - show = BasicServlet.encode(show); - return Collections.singletonList(new Cookie("tableLegend." + page + "." + table + "." + "show", show)); - } - } - - public static class ClearDeadServerOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) { - String server = req.getParameter("server"); - // a dead server should have a uniq address: a logger or tserver - DeadServerList obit = new DeadServerList(ZooUtil.getRoot(Monitor.getContext().getInstance()) + Constants.ZDEADTSERVERS); - obit.delete(server); - return Collections.emptyList(); - } - } - - public static class NamespaceOperation implements WebOperation { - @Override - public List<Cookie> execute(HttpServletRequest req, Logger log) throws Exception { - String page = req.getParameter("page"); - String table = req.getParameter("table"); - String selected = req.getParameter("selected"); - if (table == null || page == null || selected == null) - return Collections.emptyList(); - page = BasicServlet.encode(page); - table = BasicServlet.encode(table); - selected = BasicServlet.encode(selected); - return Collections.singletonList(new Cookie("namespaceDropdown." + page + "." + table + "." + "selected", selected)); - } - } -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ProblemServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ProblemServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ProblemServlet.java deleted file mode 100644 index 29ab6c6..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ProblemServlet.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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.accumulo.monitor.servlets; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.accumulo.core.client.impl.Tables; -import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.monitor.util.Table; -import org.apache.accumulo.monitor.util.TableRow; -import org.apache.accumulo.monitor.util.celltypes.CellType; -import org.apache.accumulo.monitor.util.celltypes.DateTimeType; -import org.apache.accumulo.monitor.util.celltypes.NumberType; -import org.apache.accumulo.monitor.util.celltypes.StringType; -import org.apache.accumulo.server.problems.ProblemReport; -import org.apache.accumulo.server.problems.ProblemReports; -import org.apache.accumulo.server.problems.ProblemType; - -public class ProblemServlet extends BasicServlet { - - private static final long serialVersionUID = 1L; - - @Override - protected String getTitle(HttpServletRequest req) { - return "Per-Table Problem Report"; - } - - @Override - protected void pageBody(final HttpServletRequest req, HttpServletResponse resp, StringBuilder sb) { - Map<String,String> tidToNameMap = Tables.getIdToNameMap(Monitor.getContext().getInstance()); - doProblemSummary(req, sb, tidToNameMap); - doProblemDetails(req, sb, req.getParameter("table"), tidToNameMap); - } - - private static void doProblemSummary(final HttpServletRequest req, StringBuilder sb, final Map<String,String> tidToNameMap) { - if (Monitor.getProblemSummary().isEmpty() && Monitor.getProblemException() == null) - return; - - Table problemSummary = new Table("problemSummary", "Problem Summary", "error"); - problemSummary.addSortableColumn("Table", new TableProblemLinkType(tidToNameMap), null); - for (ProblemType type : ProblemType.values()) - problemSummary.addSortableColumn(type.name(), new NumberType<Integer>(), null); - problemSummary.addUnsortableColumn("Operations", new ClearTableProblemsLinkType(req, tidToNameMap), null); - - if (Monitor.getProblemException() != null) { - StringBuilder cell = new StringBuilder(); - cell.append("<b>Failed to obtain problem reports</b> : " + Monitor.getProblemException().getMessage()); - Throwable cause = Monitor.getProblemException().getCause(); - while (cause != null) { - if (cause.getMessage() != null) - cell.append("<br />\n caused by : " + cause.getMessage()); - cause = cause.getCause(); - } - problemSummary.setSubCaption(cell.toString()); - } else { - for (Entry<String,Map<ProblemType,Integer>> entry : Monitor.getProblemSummary().entrySet()) { - TableRow row = problemSummary.prepareRow(); - row.add(entry.getKey()); - for (ProblemType pt : ProblemType.values()) { - Integer pcount = entry.getValue().get(pt); - row.add(pcount == null ? Integer.valueOf(0) : pcount); - } - row.add(entry.getKey()); - problemSummary.addRow(row); - } - } - problemSummary.generate(req, sb); - } - - private static void doProblemDetails(final HttpServletRequest req, StringBuilder sb, String tableId, Map<String,String> tidToNameMap) { - - if (Monitor.getProblemException() != null) - return; - - ArrayList<ProblemReport> problemReports = new ArrayList<>(); - Iterator<ProblemReport> iter = tableId == null ? ProblemReports.getInstance(Monitor.getContext()).iterator() : ProblemReports.getInstance( - Monitor.getContext()).iterator(tableId); - while (iter.hasNext()) - problemReports.add(iter.next()); - final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss zzz"); - Table problemTable = new Table("problemDetails", "Problem Details", "error"); - problemTable.setSubCaption("Problems identified with tables."); - problemTable.addSortableColumn("Table", new TableProblemLinkType(tidToNameMap), null); - problemTable.addSortableColumn("Problem Type"); - problemTable.addSortableColumn("Server"); - problemTable.addSortableColumn("Time", new DateTimeType(sdf), null); - problemTable.addSortableColumn("Resource"); - problemTable.addSortableColumn("Exception"); - problemTable.addUnsortableColumn("Operations", new ClearProblemLinkType(req), null); - for (ProblemReport pr : problemReports) { - - TableRow row = problemTable.prepareRow(); - row.add(pr.getTableName()); - row.add(pr.getProblemType().name()); - row.add(pr.getServer()); - row.add(pr.getTime()); - row.add(pr.getResource()); - row.add(pr.getException()); - row.add(pr); - problemTable.addRow(row); - } - problemTable.generate(req, sb); - } - - private static class TableProblemLinkType extends StringType<String> { - private static final long serialVersionUID = 1L; - private Map<String,String> tidToNameMap; - - public TableProblemLinkType(Map<String,String> tidToNameMap) { - this.tidToNameMap = tidToNameMap; - } - - @Override - public String format(Object obj) { - if (obj == null) - return "-"; - String table = String.valueOf(obj); - return String.format("<a href='/problems?table=%s'>%s</a>", encode(table), encode((Tables.getPrintableTableNameFromId(tidToNameMap, table)))); - } - } - - private static class ClearTableProblemsLinkType extends StringType<String> { - private static final long serialVersionUID = 1L; - private final String currentPage; - private Map<String,String> tidToNameMap; - - public ClearTableProblemsLinkType(HttpServletRequest req, Map<String,String> tidToNameMap) { - this.tidToNameMap = tidToNameMap; - this.currentPage = currentPage(req); - } - - @Override - public String alignment() { - return "right"; - } - - @Override - public String format(Object obj) { - if (obj == null) - return "-"; - String table = String.valueOf(obj); - return String.format("<a href='/op?table=%s&action=clearTableProblems&redir=%s'>clear ALL %s problems</a>", encode(table), currentPage, - Tables.getPrintableTableNameFromId(tidToNameMap, table)); - } - } - - private static class ClearProblemLinkType extends CellType<ProblemReport> { - private static final long serialVersionUID = 1L; - private final String currentPage; - - public ClearProblemLinkType(HttpServletRequest req) { - this.currentPage = currentPage(req); - } - - @Override - public String alignment() { - return "right"; - } - - @Override - public String format(Object obj) { - if (obj == null) - return "-"; - ProblemReport p = (ProblemReport) obj; - return String.format("<a href='/op?table=%s&action=clearProblem&redir=%s&resource=%s&ptype=%s'>clear this problem</a>", encode(p.getTableName()), - currentPage, encode(p.getResource()), encode(p.getProblemType().name())); - } - - @Override - public int compare(ProblemReport o1, ProblemReport o2) { - return 0; - } - } - -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java deleted file mode 100644 index f333be0..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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.accumulo.monitor.servlets; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.core.client.admin.TableOperations; -import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; -import org.apache.accumulo.core.replication.ReplicationConstants; -import org.apache.accumulo.core.replication.ReplicationTable; -import org.apache.accumulo.core.replication.ReplicationTarget; -import org.apache.accumulo.core.zookeeper.ZooUtil; -import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.monitor.util.Table; -import org.apache.accumulo.monitor.util.celltypes.NumberType; -import org.apache.accumulo.server.replication.DistributedWorkQueueWorkAssignerHelper; -import org.apache.accumulo.server.replication.ReplicationUtil; -import org.apache.accumulo.server.zookeeper.DistributedWorkQueue; -import org.apache.zookeeper.KeeperException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReplicationServlet extends BasicServlet { - private static final Logger log = LoggerFactory.getLogger(ReplicationServlet.class); - - private static final long serialVersionUID = 1L; - - // transient because it's not serializable and servlets are serializable - private transient volatile ReplicationUtil replicationUtil = null; - - private synchronized ReplicationUtil getReplicationUtil() { - // make transient replicationUtil available as needed - if (replicationUtil == null) { - replicationUtil = new ReplicationUtil(Monitor.getContext()); - } - return replicationUtil; - } - - @Override - protected String getTitle(HttpServletRequest req) { - return "Replication Overview"; - } - - @Override - protected void pageBody(HttpServletRequest req, HttpServletResponse response, StringBuilder sb) throws Exception { - final Connector conn = Monitor.getContext().getConnector(); - final MasterMonitorInfo mmi = Monitor.getMmi(); - - // The total number of "slots" we have to replicate data - int totalWorkQueueSize = getReplicationUtil().getMaxReplicationThreads(mmi); - - TableOperations tops = conn.tableOperations(); - if (!ReplicationTable.isOnline(conn)) { - banner(sb, "", "Replication table is offline"); - return; - } - - Table replicationStats = new Table("replicationStats", "Replication Status"); - replicationStats.addSortableColumn("Table"); - replicationStats.addSortableColumn("Peer"); - replicationStats.addSortableColumn("Remote Identifier"); - replicationStats.addSortableColumn("ReplicaSystem Type"); - replicationStats.addSortableColumn("Files needing replication", new NumberType<Long>(), null); - - Map<String,String> peers = getReplicationUtil().getPeers(); - - // The total set of configured targets - Set<ReplicationTarget> allConfiguredTargets = getReplicationUtil().getReplicationTargets(); - - // Number of files per target we have to replicate - Map<ReplicationTarget,Long> targetCounts = getReplicationUtil().getPendingReplications(); - - Map<String,String> tableNameToId = tops.tableIdMap(); - Map<String,String> tableIdToName = getReplicationUtil().invert(tableNameToId); - - long filesPendingOverAllTargets = 0l; - for (ReplicationTarget configuredTarget : allConfiguredTargets) { - String tableName = tableIdToName.get(configuredTarget.getSourceTableId()); - if (null == tableName) { - log.trace("Could not determine table name from id {}", configuredTarget.getSourceTableId()); - continue; - } - - String replicaSystemClass = peers.get(configuredTarget.getPeerName()); - if (null == replicaSystemClass) { - log.trace("Could not determine configured ReplicaSystem for {}", configuredTarget.getPeerName()); - continue; - } - - Long numFiles = targetCounts.get(configuredTarget); - - if (null == numFiles) { - replicationStats.addRow(tableName, configuredTarget.getPeerName(), configuredTarget.getRemoteIdentifier(), replicaSystemClass, 0); - } else { - replicationStats.addRow(tableName, configuredTarget.getPeerName(), configuredTarget.getRemoteIdentifier(), replicaSystemClass, numFiles); - filesPendingOverAllTargets += numFiles; - } - } - - // Up to 2x the number of slots for replication available, WARN - // More than 2x the number of slots for replication available, ERROR - NumberType<Long> filesPendingFormat = new NumberType<>(Long.valueOf(0), Long.valueOf(2 * totalWorkQueueSize), Long.valueOf(0), - Long.valueOf(4 * totalWorkQueueSize)); - - String utilization = filesPendingFormat.format(filesPendingOverAllTargets); - - sb.append("<div><center><br /><span class=\"table-caption\">Total files pending replication: ").append(utilization).append("</span></center></div>"); - - replicationStats.generate(req, sb); - - // Make a table for the replication data in progress - Table replicationInProgress = new Table("replicationInProgress", "In-Progress Replication"); - replicationInProgress.addSortableColumn("File"); - replicationInProgress.addSortableColumn("Peer"); - replicationInProgress.addSortableColumn("Source Table ID"); - replicationInProgress.addSortableColumn("Peer Identifier"); - replicationInProgress.addUnsortableColumn("Status"); - - // Read the files from the workqueue in zk - String zkRoot = ZooUtil.getRoot(Monitor.getContext().getInstance()); - final String workQueuePath = zkRoot + ReplicationConstants.ZOO_WORK_QUEUE; - - DistributedWorkQueue workQueue = new DistributedWorkQueue(workQueuePath, Monitor.getContext().getConfiguration()); - - try { - for (String queueKey : workQueue.getWorkQueued()) { - Entry<String,ReplicationTarget> queueKeyPair = DistributedWorkQueueWorkAssignerHelper.fromQueueKey(queueKey); - String filename = queueKeyPair.getKey(); - ReplicationTarget target = queueKeyPair.getValue(); - - String path = getReplicationUtil().getAbsolutePath(conn, workQueuePath, queueKey); - String progress = getReplicationUtil().getProgress(conn, path, target); - - // Add a row in the table - replicationInProgress.addRow(null == path ? ".../" + filename : path, target.getPeerName(), target.getSourceTableId(), target.getRemoteIdentifier(), - progress); - } - } catch (KeeperException | InterruptedException e) { - log.warn("Could not calculate replication in progress", e); - } - - replicationInProgress.generate(req, sb); - } -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java deleted file mode 100644 index 24e07c0..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * 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.accumulo.monitor.servlets; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.accumulo.shell.Shell; - -import jline.console.ConsoleReader; - -public class ShellServlet extends BasicServlet { - private static final long serialVersionUID = 1L; - private transient volatile Map<String,ShellExecutionThread> userShells = null; - private transient volatile ExecutorService service = null; - - private synchronized Map<String,ShellExecutionThread> userShells() { - if (userShells == null) { - userShells = new HashMap<>(); - } - return userShells; - } - - private synchronized ExecutorService service() { - if (service == null) { - service = Executors.newCachedThreadPool(); - } - return service; - } - - public static final String CSRF_KEY = "csrf_token"; - - @Override - protected String getTitle(HttpServletRequest req) { - return "Shell"; - } - - @Override - protected void pageBody(HttpServletRequest req, HttpServletResponse response, StringBuilder sb) throws IOException { - HttpSession session = req.getSession(true); - final String CSRF_TOKEN; - if (null == session.getAttribute(CSRF_KEY)) { - // No token, make one - CSRF_TOKEN = UUID.randomUUID().toString(); - session.setAttribute(CSRF_KEY, CSRF_TOKEN); - } else { - // Pull the token out of the session - CSRF_TOKEN = (String) session.getAttribute(CSRF_KEY); - if (null == CSRF_TOKEN) { - throw new RuntimeException("No valid CSRF token exists in session"); - } - } - - String user = (String) session.getAttribute("user"); - if (user == null) { - // user attribute is null, check to see if username and password are passed as parameters - user = req.getParameter("user"); - String pass = req.getParameter("pass"); - String mock = req.getParameter("mock"); - if (user == null || pass == null) { - // username or password are null, re-authenticate - sb.append(authenticationForm(req.getRequestURI(), CSRF_TOKEN)); - return; - } - try { - // get a new shell for this user - ShellExecutionThread shellThread = new ShellExecutionThread(user, pass, mock); - service().submit(shellThread); - userShells().put(session.getId(), shellThread); - } catch (IOException e) { - // error validating user, reauthenticate - sb.append("<div id='loginError'>Invalid user/password</div>" + authenticationForm(req.getRequestURI(), CSRF_TOKEN)); - return; - } - session.setAttribute("user", user); - } - if (!userShells().containsKey(session.getId())) { - // no existing shell for this user, re-authenticate - sb.append(authenticationForm(req.getRequestURI(), UUID.randomUUID().toString())); - return; - } - - ShellExecutionThread shellThread = userShells().get(session.getId()); - shellThread.getOutput(); - shellThread.printInfo(); - sb.append("<div id='shell'>\n"); - sb.append("<pre id='shellResponse'>").append(shellThread.getOutput()).append("</pre>\n"); - sb.append("<form><span id='shellPrompt'>").append(shellThread.getPrompt()); - sb.append("</span><input type='text' name='cmd' id='cmd' onkeydown='return handleKeyDown(event.keyCode);'>\n"); - sb.append("</form>\n</div>\n"); - sb.append("<script type='text/javascript'>\n"); - sb.append("var url = '").append(req.getRequestURL().toString()).append("';\n"); - sb.append("var xmlhttp = new XMLHttpRequest();\n"); - sb.append("var hsize = 1000;\n"); - sb.append("var hindex = 0;\n"); - sb.append("var history = new Array();\n"); - sb.append("\n"); - sb.append("function handleKeyDown(keyCode) {\n"); - sb.append(" if (keyCode==13) {\n"); - sb.append(" submitCmd(document.getElementById('cmd').value);\n"); - sb.append(" hindex = history.length;\n"); - sb.append(" return false;\n"); - sb.append(" } else if (keyCode==38) {\n"); - sb.append(" hindex = hindex==0 ? history.length : hindex - 1;\n"); - sb.append(" if (hindex == history.length)\n"); - sb.append(" document.getElementById('cmd').value = '';\n"); - sb.append(" else\n"); - sb.append(" document.getElementById('cmd').value = history[hindex];\n"); - sb.append(" return false;\n"); - sb.append(" } else if (keyCode==40) {\n"); - sb.append(" hindex = hindex==history.length ? history.length : hindex + 1;\n"); - sb.append(" if (hindex == history.length)\n"); - sb.append(" document.getElementById('cmd').value = '';\n"); - sb.append(" else\n"); - sb.append(" document.getElementById('cmd').value = history[hindex];\n"); - sb.append(" return false;\n"); - sb.append(" }\n"); - sb.append(" return true;\n"); - sb.append("}\n"); - sb.append("\n"); - sb.append("function submitCmd(cmd) {\n"); - sb.append(" if (cmd=='history') {\n"); - sb.append(" document.getElementById('shellResponse').innerHTML += document.getElementById('shellPrompt').innerHTML+cmd+'\\n';\n"); - sb.append(" document.getElementById('shellResponse').innerHTML += history.join('\\n');\n"); - sb.append(" return\n"); - sb.append(" }\n"); - sb.append(" xmlhttp.open('POST',url+'?cmd='+cmd+'&'+'").append(CSRF_KEY).append("=").append(CSRF_TOKEN).append("',false);\n"); - sb.append(" xmlhttp.send();\n"); - sb.append(" var text = xmlhttp.responseText;\n"); - sb.append(" var index = text.lastIndexOf('\\n');\n"); - sb.append(" if (index >= 0) {\n"); - sb.append(" if (index > 0 && document.getElementById('cmd').type == 'text') {\n"); - sb.append(" if (history.length == hsize)\n"); - sb.append(" history.shift()\n"); - sb.append(" history.push(cmd)\n"); - sb.append(" }\n"); - sb.append(" if (text.charAt(text.length-1)=='*') {\n"); - sb.append(" document.getElementById('cmd').type = 'password';\n"); - sb.append(" text = text.substring(0,xmlhttp.responseText.length-2);\n"); - sb.append(" } else {\n"); - sb.append(" document.getElementById('cmd').type = 'text';\n"); - sb.append(" }\n"); - sb.append(" document.getElementById('shellResponse').innerHTML += text.substring(0,index+1);\n"); - sb.append(" document.getElementById('shellPrompt').innerHTML = text.substring(index+1);\n"); - sb.append(" document.getElementById('cmd').value = '';\n"); - sb.append(" document.getElementById('shell').scrollTop = document.getElementById('cmd').offsetTop;\n"); - sb.append(" } else {\n"); - sb.append(" window.location = url;\n"); - sb.append(" }\n"); - sb.append("}\n"); - sb.append("</script>\n"); - sb.append("<script type='text/javascript'>window.onload = function() { document.getElementById('cmd').select(); }</script>\n"); - } - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - final HttpSession session = req.getSession(true); - String user = (String) session.getAttribute("user"); - if (user == null || !userShells().containsKey(session.getId())) { - // no existing shell for user, re-authenticate - doGet(req, resp); - return; - } - final String CSRF_TOKEN = (String) session.getAttribute(CSRF_KEY); - if (null == CSRF_TOKEN) { - // no csrf token, need to re-auth - doGet(req, resp); - } - ShellExecutionThread shellThread = userShells().get(session.getId()); - String cmd = req.getParameter("cmd"); - if (cmd == null) { - // the command is null, just print prompt - resp.getWriter().append(shellThread.getPrompt()); - resp.getWriter().flush(); - return; - } - shellThread.addInputString(cmd); - shellThread.waitUntilReady(); - if (shellThread.isDone()) { - // the command was exit, invalidate session - userShells().remove(session.getId()); - session.invalidate(); - return; - } - // get the shell's output - StringBuilder sb = new StringBuilder(); - sb.append(shellThread.getOutput().replace("<", "<").replace(">", ">")); - if (sb.length() == 0 || !(sb.charAt(sb.length() - 1) == '\n')) - sb.append("\n"); - // check if shell is waiting for input - if (!shellThread.isWaitingForInput()) - sb.append(shellThread.getPrompt()); - // check if shell is waiting for password input - if (shellThread.isMasking()) - sb.append("*"); - resp.getWriter().append(sb.toString()); - resp.getWriter().flush(); - } - - private String authenticationForm(String requestURI, String csrfToken) { - return "<div id='login'><form method=POST action='" + requestURI + "'>" - + "<table><tr><td>Mock: </td><td><input type='checkbox' name='mock' value='mock'></td></tr>" - + "<tr><td>Username: </td><td><input type='text' name='user'></td></tr>" - + "<tr><td>Password: </td><td><input type='password' name='pass'></td><td>" + "<input type='hidden' name='" + CSRF_KEY + "' value='" + csrfToken - + "'/><input type='submit' value='Enter'></td></tr></table></form></div>"; - } - - private static class StringBuilderOutputStream extends OutputStream { - StringBuilder sb = new StringBuilder(); - - @Override - public void write(int b) throws IOException { - sb.append((char) (0xff & b)); - } - - public String get() { - return sb.toString(); - } - - public void clear() { - sb.setLength(0); - } - } - - private static class ShellExecutionThread extends InputStream implements Runnable { - private Shell shell; - StringBuilderOutputStream output; - private String cmd; - private int cmdIndex; - private boolean done; - private boolean readWait; - - private ShellExecutionThread(String username, String password, String mock) throws IOException { - this.done = false; - this.cmd = null; - this.cmdIndex = 0; - this.readWait = false; - this.output = new StringBuilderOutputStream(); - ConsoleReader reader = new ConsoleReader(this, output); - this.shell = new Shell(reader); - shell.setLogErrorsToConsole(); - if (mock != null) { - if (shell.config("--fake", "-u", username, "-p", password)) - throw new IOException("mock shell config error"); - } else if (shell.config("-u", username, "-p", password)) { - throw new IOException("shell config error"); - } - } - - @Override - public synchronized int read() throws IOException { - if (cmd == null) { - readWait = true; - this.notifyAll(); - } - while (cmd == null) { - try { - this.wait(); - } catch (InterruptedException e) {} - } - readWait = false; - int c; - if (cmdIndex == cmd.length()) - c = '\n'; - else - c = cmd.charAt(cmdIndex); - cmdIndex++; - if (cmdIndex > cmd.length()) { - cmd = null; - cmdIndex = 0; - this.notifyAll(); - } - return c; - } - - @Override - public synchronized void run() { - Thread.currentThread().setName("shell thread"); - while (!shell.hasExited()) { - while (cmd == null) { - try { - this.wait(); - } catch (InterruptedException e) {} - } - String tcmd = cmd; - cmd = null; - cmdIndex = 0; - try { - shell.execCommand(tcmd, false, true); - } catch (IOException e) { - // ignored - } - this.notifyAll(); - } - done = true; - this.notifyAll(); - } - - public synchronized void addInputString(String s) { - if (done) - throw new IllegalStateException("adding string to exited shell"); - if (cmd == null) { - cmd = s; - } else { - throw new IllegalStateException("adding string to shell not waiting for input"); - } - this.notifyAll(); - } - - public synchronized void waitUntilReady() { - while (cmd != null) { - try { - this.wait(); - } catch (InterruptedException e) {} - } - } - - public synchronized String getOutput() { - String s = output.get(); - output.clear(); - return s; - } - - public String getPrompt() { - return shell.getDefaultPrompt(); - } - - public void printInfo() throws IOException { - shell.printInfo(); - } - - public boolean isMasking() { - return shell.isMasking(); - } - - public synchronized boolean isWaitingForInput() { - return readWait; - } - - public boolean isDone() { - return done; - } - } -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/StaticWebResourcesServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/StaticWebResourcesServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/StaticWebResourcesServlet.java deleted file mode 100644 index 1443e5b..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/StaticWebResourcesServlet.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.accumulo.monitor.servlets; - -import org.eclipse.jetty.util.resource.Resource; - -public class StaticWebResourcesServlet extends org.eclipse.jetty.servlet.DefaultServlet { - - private static final long serialVersionUID = 1L; - - @Override - public Resource getResource(String pathInContext) { - return Resource.newResource(BasicServlet.class.getClassLoader().getResource(pathInContext.substring(1))); - } - -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullKeyValueIterator.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullKeyValueIterator.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullKeyValueIterator.java deleted file mode 100644 index 1a72b4b..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullKeyValueIterator.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.accumulo.monitor.servlets.trace; - -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.NoSuchElementException; - -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Value; - -public class NullKeyValueIterator implements Iterator<Entry<Key,Value>> { - - @Override - public boolean hasNext() { - return false; - } - - @Override - public Entry<Key,Value> next() { - throw new NoSuchElementException(getClass().getName() + " contains no elements"); - } - - @Override - public void remove() {} -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cc8d3353/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java deleted file mode 100644 index b91d454..0000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/NullScanner.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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.accumulo.monitor.servlets.trace; - -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; - -import org.apache.accumulo.core.client.IteratorSetting; -import org.apache.accumulo.core.client.IteratorSetting.Column; -import org.apache.accumulo.core.client.sample.SamplerConfiguration; -import org.apache.accumulo.core.client.Scanner; -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Range; -import org.apache.accumulo.core.data.Value; -import org.apache.accumulo.core.security.Authorizations; -import org.apache.hadoop.io.Text; - -public class NullScanner implements Scanner { - - @Override - public void addScanIterator(IteratorSetting cfg) {} - - @Override - public void updateScanIteratorOption(String iteratorName, String key, String value) {} - - @Override - public void fetchColumnFamily(Text col) {} - - @Override - public void fetchColumn(Text colFam, Text colQual) {} - - @Override - public void fetchColumn(Column column) {} - - @Override - public void clearColumns() {} - - @Override - public void clearScanIterators() {} - - @Deprecated - @Override - public void setTimeOut(int timeOut) {} - - @Deprecated - @Override - public int getTimeOut() { - return 0; - } - - @Override - public void setRange(Range range) {} - - @Override - public Range getRange() { - return null; - } - - @Override - public void setBatchSize(int size) { - - } - - @Override - public int getBatchSize() { - return 0; - } - - @Override - public void enableIsolation() { - - } - - @Override - public void disableIsolation() { - - } - - @Override - public Iterator<Entry<Key,Value>> iterator() { - return new NullKeyValueIterator(); - } - - @Override - public void removeScanIterator(String iteratorName) {} - - @Override - public void setTimeout(long timeOut, TimeUnit timeUnit) {} - - @Override - public long getTimeout(TimeUnit timeUnit) { - return 0; - } - - @Override - public void close() {} - - @Override - public Authorizations getAuthorizations() { - return null; - } - - @Override - public long getReadaheadThreshold() { - return 0l; - } - - @Override - public void setReadaheadThreshold(long batches) { - - } - - @Override - public void setBatchTimeout(long timeout, TimeUnit milliseconds) { - - } - - @Override - public long getBatchTimeout(TimeUnit timeUnit) { - return 0; - } - - @Override - public void setSamplerConfiguration(SamplerConfiguration samplerConfig) {} - - @Override - public SamplerConfiguration getSamplerConfiguration() { - return null; - } - - @Override - public void clearSamplerConfiguration() {} - - @Override - public void setClassLoaderContext(String context) {} - - @Override - public void clearClassLoaderContext() {} - - @Override - public String getClassLoaderContext() { - return null; - } -}
