accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [32/59] [abbrv] ACCUMULO-656,ACCUMULO-658 Update package names
Date Sat, 07 Sep 2013 03:28:35 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
new file mode 100644
index 0000000..e2578c9
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
@@ -0,0 +1,233 @@
+/*
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.accumulo.monitor.servlets.BasicServlet;
+import org.apache.accumulo.monitor.util.celltypes.CellType;
+import org.apache.accumulo.monitor.util.celltypes.StringType;
+
+public class Table {
+  private String table;
+  private String caption;
+  private String captionclass;
+  private String subcaption;
+  private ArrayList<TableColumn<?>> columns;
+  private ArrayList<TableRow> rows;
+  private boolean hasBegunAddingRows = false;
+  
+  public Table(String tableName, String caption) {
+    this(tableName, caption, null);
+  }
+  
+  public Table(String tableName, String caption, String captionClass) {
+    this.table = tableName;
+    this.caption = caption;
+    this.captionclass = captionClass;
+    this.subcaption = null;
+    this.columns = new ArrayList<TableColumn<?>>();
+    this.rows = new ArrayList<TableRow>();
+  }
+  
+  public synchronized void setSubCaption(String subcaption) {
+    this.subcaption = subcaption;
+  }
+  
+  public synchronized <T> void addColumn(TableColumn<T> column) {
+    if (hasBegunAddingRows)
+      throw new IllegalStateException("Cannot add more columns newServer rows have been added");
+    columns.add(column);
+  }
+  
+  private synchronized <T> void addColumn(String title, CellType<T> type, String legend, boolean sortable) {
+    if (type == null)
+      type = new StringType<T>();
+    type.setSortable(sortable);
+    addColumn(new TableColumn<T>(title, type, legend));
+  }
+  
+  public synchronized <T> void addUnsortableColumn(String title, CellType<T> type, String legend) {
+    addColumn(title, type, legend, false);
+  }
+  
+  public synchronized <T> void addSortableColumn(String title, CellType<T> type, String legend) {
+    addColumn(title, type, legend, true);
+  }
+  
+  public synchronized void addUnsortableColumn(String title) {
+    addUnsortableColumn(title, null, null);
+  }
+  
+  public synchronized void addSortableColumn(String title) {
+    addSortableColumn(title, null, null);
+  }
+  
+  public synchronized TableRow prepareRow() {
+    hasBegunAddingRows = true;
+    return new TableRow(columns.size());
+  }
+  
+  public synchronized void addRow(TableRow row) {
+    hasBegunAddingRows = true;
+    if (columns.size() != row.size())
+      throw new IllegalStateException("Row must be the same size as the columns");
+    rows.add(row);
+  }
+  
+  public synchronized void addRow(Object... cells) {
+    TableRow row = prepareRow();
+    if (cells.length != columns.size())
+      throw new IllegalArgumentException("Argument length not equal to the number of columns");
+    for (Object cell : cells)
+      row.add(cell);
+    addRow(row);
+  }
+  
+  public synchronized void generate(HttpServletRequest req, StringBuilder sb) {
+    String page = req.getRequestURI();
+    if (columns.isEmpty())
+      throw new IllegalStateException("No columns in table");
+    for (TableRow row : rows)
+      if (row.size() != columns.size())
+        throw new RuntimeException("Each row must have the same number of columns");
+    
+    boolean sortAscending = true;
+    Cookie c = BasicServlet.getCookie(req, "tableSort." + page + "." + table + "." + "sortAsc");
+    if (c != null && "false".equals(c.getValue()))
+      sortAscending = false;
+    
+    int sortCol = -1; // set to first sortable column by default
+    int numLegends = 0;
+    for (int i = 0; i < columns.size(); ++i) {
+      TableColumn<?> col = columns.get(i);
+      if (sortCol < 0 && col.getCellType().isSortable())
+        sortCol = i;
+      if (col.getLegend() != null && !col.getLegend().isEmpty())
+        ++numLegends;
+    }
+    
+    // only get cookie if there is a possibility that it is sortable
+    if (sortCol >= 0) {
+      c = BasicServlet.getCookie(req, "tableSort." + page + "." + table + "." + "sortCol");
+      if (c != null && c.getValue() != null) {
+        try {
+          int col = Integer.parseInt(c.getValue());
+          // only bother if specified column is sortable
+          if (!(col < 0 || sortCol >= columns.size()) && columns.get(col).getCellType().isSortable())
+            sortCol = col;
+        } catch (NumberFormatException e) {
+          // ignore improperly formatted user cookie
+        }
+      }
+    }
+    
+    boolean showLegend = false;
+    if (numLegends > 0) {
+      c = BasicServlet.getCookie(req, "tableLegend." + page + "." + table + "." + "show");
+      showLegend = c != null && Boolean.parseBoolean(c.getValue());
+    }
+    
+    sb.append("<div>\n");
+    sb.append("<a name='").append(table).append("'>&nbsp;</a>\n");
+    sb.append("<table id='").append(table).append("' class='sortable'>\n");
+    sb.append("<caption");
+    if (captionclass != null && !captionclass.isEmpty())
+      sb.append(" class='").append(captionclass).append("'");
+    sb.append(">\n");
+    if (caption != null && !caption.isEmpty())
+      sb.append("<span class='table-caption'>").append(caption).append("</span><br />\n");
+    if (subcaption != null && !subcaption.isEmpty())
+      sb.append("<span class='table-subcaption'>").append(subcaption).append("</span><br />\n");
+    
+    String redir = BasicServlet.currentPage(req);
+    if (numLegends > 0) {
+      String legendUrl = String.format("/op?action=toggleLegend&redir=%s&page=%s&table=%s&show=%s", redir, page, table, !showLegend);
+      sb.append("<a href='").append(legendUrl).append("'>").append(showLegend ? "Hide" : "Show").append("&nbsp;Legend</a>\n");
+      if (showLegend)
+        sb.append("<div class='left ").append(showLegend ? "show" : "hide").append("'><dl>\n");
+    }
+    for (int i = 0; i < columns.size(); ++i) {
+      TableColumn<?> col = columns.get(i);
+      String title = col.getTitle();
+      if (rows.size() > 1 && col.getCellType().isSortable()) {
+        String url = String.format("/op?action=sortTable&redir=%s&page=%s&table=%s&%s=%s", redir, page, table, sortCol == i ? "asc" : "col",
+            sortCol == i ? !sortAscending : i);
+        String img = "";
+        if (sortCol == i)
+          img = String.format("&nbsp;<img width='10px' height='10px' src='/web/%s.gif' alt='%s' />", sortAscending ? "up" : "down", !sortAscending ? "^" : "v");
+        col.setTitle(String.format("<a href='%s'>%s%s</a>", url, title, img));
+      }
+      String legend = col.getLegend();
+      if (showLegend && legend != null && !legend.isEmpty())
+        sb.append("<dt class='smalltext'><b>").append(title.replace("<br />", "&nbsp;")).append("</b><dd>").append(legend).append("</dd></dt>\n");
+    }
+    if (showLegend && numLegends > 0)
+      sb.append("</dl></div>\n");
+    sb.append("</caption>\n");
+    sb.append("<tr>");
+    boolean first = true;
+    for (TableColumn<?> col : columns) {
+      String cellValue = col.getTitle() == null ? "" : String.valueOf(col.getTitle()).trim();
+      sb.append("<th").append(first ? " class='firstcell'" : "").append(">").append(cellValue.isEmpty() ? "-" : cellValue).append("</th>");
+      first = false;
+    }
+    sb.append("</tr>\n");
+    // don't sort if no columns are sortable or if there aren't enough rows
+    if (rows.size() > 1 && sortCol > -1) {
+      Collections.sort(rows, TableRow.getComparator(sortCol, columns.get(sortCol).getCellType()));
+      if (!sortAscending)
+        Collections.reverse(rows);
+    }
+    boolean highlight = true;
+    for (TableRow row : rows) {
+      for (int i = 0; i < row.size(); ++i) {
+        try {
+          row.set(i, columns.get(i).getCellType().format(row.get(i)));
+        } catch (Exception ex) {
+          throw new RuntimeException("Unable to process column " + i, ex);
+        }
+      }
+      row(sb, highlight, columns, row);
+      highlight = !highlight;
+    }
+    if (rows.isEmpty())
+      sb.append("<tr><td class='center' colspan='").append(columns.size()).append("'><i>Empty</i></td></tr>\n");
+    sb.append("</table>\n</div>\n\n");
+  }
+  
+  private static void row(StringBuilder sb, boolean highlight, ArrayList<TableColumn<?>> columns, TableRow row) {
+    sb.append(highlight ? "<tr class='highlight'>" : "<tr>");
+    boolean first = true;
+    for (int i = 0; i < row.size(); ++i) {
+      String cellValue = String.valueOf(row.get(i)).trim();
+      if (cellValue.isEmpty() || cellValue.equals(String.valueOf((Object) null)))
+        cellValue = "-";
+      sb.append("<td class='").append(first ? "firstcell" : "");
+      if (columns.get(i).getCellType().alignment() != null)
+        sb.append(first ? " " : "").append(columns.get(i).getCellType().alignment());
+      sb.append("'>").append(cellValue).append("</td>");
+      first = false;
+    }
+    sb.append("</tr>\n");
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableColumn.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableColumn.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableColumn.java
new file mode 100644
index 0000000..a7330ac
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableColumn.java
@@ -0,0 +1,48 @@
+/*
+ * 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.util;
+
+import org.apache.accumulo.monitor.util.celltypes.CellType;
+import org.apache.accumulo.monitor.util.celltypes.StringType;
+
+public class TableColumn<T> {
+  private String title;
+  private CellType<T> type;
+  private String legend;
+  
+  public TableColumn(String title, CellType<T> type, String legend) {
+    this.title = title;
+    this.type = type != null ? type : new StringType<T>();
+    this.legend = legend;
+  }
+  
+  public void setTitle(String title) {
+    this.title = title;
+  }
+  
+  public String getTitle() {
+    return title;
+  }
+  
+  public String getLegend() {
+    return legend;
+  }
+  
+  public CellType<T> getCellType() {
+    return type;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableRow.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableRow.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableRow.java
new file mode 100644
index 0000000..5de0863
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/TableRow.java
@@ -0,0 +1,68 @@
+/*
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+
+public class TableRow {
+  private int size;
+  private ArrayList<Object> row;
+  
+  TableRow(int size) {
+    this.size = size;
+    this.row = new ArrayList<Object>(size);
+  }
+  
+  public boolean add(Object obj) {
+    if (row.size() == size)
+      throw new IllegalStateException("Row is full.");
+    return row.add(obj);
+  }
+  
+  Object get(int index) {
+    return row.get(index);
+  }
+  
+  int size() {
+    return row.size();
+  }
+  
+  Object set(int i, Object value) {
+    return row.set(i, value);
+  }
+  
+  public static <T> Comparator<TableRow> getComparator(int index, Comparator<T> comp) {
+    return new TableRowComparator<T>(index, comp);
+  }
+  
+  private static class TableRowComparator<T> implements Comparator<TableRow> {
+    private int index;
+    private Comparator<T> comp;
+    
+    public TableRowComparator(int index, Comparator<T> comp) {
+      this.index = index;
+      this.comp = comp;
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Override
+    public int compare(TableRow o1, TableRow o2) {
+      return comp.compare((T) o1.get(index), (T) o2.get(index));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CellType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CellType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CellType.java
new file mode 100644
index 0000000..23071a8
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CellType.java
@@ -0,0 +1,35 @@
+/*
+ * 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.util.celltypes;
+
+import java.util.Comparator;
+
+public abstract class CellType<T> implements Comparator<T> {
+  private boolean sortable = true;
+  
+  abstract public String alignment();
+  
+  abstract public String format(Object obj);
+  
+  public final void setSortable(boolean sortable) {
+    this.sortable = sortable;
+  }
+  
+  public final boolean isSortable() {
+    return sortable;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CompactionsType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CompactionsType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CompactionsType.java
new file mode 100644
index 0000000..704aa42
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/CompactionsType.java
@@ -0,0 +1,72 @@
+/*
+ * 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.util.celltypes;
+
+import org.apache.accumulo.core.master.thrift.Compacting;
+import org.apache.accumulo.core.master.thrift.TableInfo;
+
+public class CompactionsType extends CellType<TableInfo> {
+  
+  private String fieldName;
+  
+  public CompactionsType(String which) {
+    this.fieldName = which;
+  }
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    TableInfo summary = (TableInfo) obj;
+    Compacting c = summary.majors;
+    if (fieldName.equals("minor"))
+      c = summary.minors;
+    else if (fieldName.equals("scans"))
+      c = summary.scans;
+    if (c == null)
+      c = new Compacting();
+    return String.format("%s&nbsp;(%,d)", NumberType.commas(c.running, c.queued == 0 ? 0 : 1, summary.onlineTablets), c.queued);
+  }
+  
+  @Override
+  public int compare(TableInfo o1, TableInfo o2) {
+    if (o1 == null)
+      return -1;
+    if (o2 == null)
+      return 1;
+    Compacting c1 = o1.majors;
+    Compacting c2 = o2.majors;
+    if (fieldName.equals("minor")) {
+      c1 = o1.minors;
+      c2 = o2.minors;
+    } else if (fieldName.equals("scans")) {
+      c1 = o1.scans;
+      c2 = o2.scans;
+    }
+    if (c1 == null)
+      return -1;
+    if (c2 == null)
+      return 1;
+    return c1.running + c1.queued - c2.running - c2.queued;
+  }
+  
+  @Override
+  public String alignment() {
+    return "right";
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DateTimeType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DateTimeType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DateTimeType.java
new file mode 100644
index 0000000..8ff3b60
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DateTimeType.java
@@ -0,0 +1,66 @@
+/*
+ * 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.util.celltypes;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class DateTimeType extends CellType<Long> {
+  private SimpleDateFormat simple;
+  private int dateFormat;
+  private int timeFormat;
+  
+  public DateTimeType(int dateFormat, int timeFormat) {
+    this.dateFormat = dateFormat;
+    this.timeFormat = timeFormat;
+    this.simple = null;
+  }
+  
+  public DateTimeType(SimpleDateFormat fmt) {
+    simple = fmt;
+  }
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    Long millis = (Long) obj;
+    if (millis == 0)
+      return "-";
+    if (simple != null)
+      return simple.format(new Date(millis)).replace(" ", "&nbsp;");
+    return DateFormat.getDateTimeInstance(dateFormat, timeFormat, Locale.getDefault()).format(new Date(millis)).replace(" ", "&nbsp;");
+  }
+  
+  @Override
+  public int compare(Long o1, Long o2) {
+    if (o1 == null && o2 == null)
+      return 0;
+    else if (o1 == null)
+      return -1;
+    else
+      return o1.compareTo(o2);
+  }
+  
+  @Override
+  public String alignment() {
+    return "right";
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DurationType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DurationType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DurationType.java
new file mode 100644
index 0000000..7f3472e
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/DurationType.java
@@ -0,0 +1,51 @@
+/*
+ * 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.util.celltypes;
+
+import org.apache.accumulo.core.util.Duration;
+
+public class DurationType extends NumberType<Long> {
+  private Long errMin;
+  private Long errMax;
+  
+  public DurationType() {
+    this(null, null);
+  }
+  
+  public DurationType(Long errMin, Long errMax) {
+    this.errMin = errMin;
+    this.errMax = errMax;
+  }
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    Long millis = (Long) obj;
+    if (errMin != null && errMax != null)
+      return seconds(millis, errMin, errMax);
+    return Duration.format(millis);
+  }
+  
+  private static String seconds(long secs, long errMin, long errMax) {
+    String numbers = Duration.format(secs);
+    if (secs < errMin || secs > errMax)
+      return "<span class='error'>" + numbers + "</span>";
+    return numbers;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/NumberType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/NumberType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/NumberType.java
new file mode 100644
index 0000000..d311603
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/NumberType.java
@@ -0,0 +1,118 @@
+/*
+ * 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.util.celltypes;
+
+import static org.apache.accumulo.core.util.NumUtil.bigNumberForQuantity;
+
+public class NumberType<T extends Number> extends CellType<T> {
+  
+  private T warnMin, warnMax, errMin, errMax;
+  
+  public NumberType(T warnMin, T warnMax, T errMin, T errMax) {
+    this.warnMin = warnMin;
+    this.warnMax = warnMax;
+    this.errMin = errMin;
+    this.errMax = errMax;
+  }
+  
+  public NumberType(T errMin, T errMax) {
+    this(null, null, errMin, errMax);
+  }
+  
+  public NumberType() {
+    this(null, null);
+  }
+  
+  @SuppressWarnings("unchecked")
+  @Override
+  public String format(Object obj) {
+    T number = (T) obj;
+    String s = "-";
+    if (number instanceof Double || number instanceof Float) {
+      if (warnMin != null && warnMax != null && errMin != null && errMax != null)
+        s = commas(number.doubleValue(), warnMin.doubleValue(), warnMax.doubleValue(), errMin.doubleValue(), errMax.doubleValue());
+      else if (errMin != null && errMax != null)
+        s = commas(number.doubleValue(), errMin.doubleValue(), errMax.doubleValue());
+      else
+        s = commas(number.doubleValue());
+    } else if (number instanceof Long || number instanceof Integer || number instanceof Short || number instanceof Byte) {
+      if (warnMin != null && warnMax != null && errMin != null && errMax != null)
+        s = commas(number.longValue(), warnMin.longValue(), warnMax.longValue(), errMin.longValue(), errMax.longValue());
+      else if (errMin != null && errMax != null)
+        s = commas(number.longValue(), errMin.longValue(), errMax.longValue());
+      else
+        s = commas(number.longValue());
+    } else {
+      if (number != null)
+        s = String.valueOf(number);
+    }
+    return s;
+  }
+  
+  @Override
+  public int compare(T o1, T o2) {
+    if (o1 == null && o2 == null)
+      return 0;
+    else if (o1 == null)
+      return -1;
+    else if (o2 == null)
+      return 1;
+    else
+      return Double.valueOf(o1.doubleValue()).compareTo(o2.doubleValue());
+  }
+  
+  public static String commas(long i) {
+    return bigNumberForQuantity(i);
+  }
+  
+  public static String commas(long i, long errMin, long errMax) {
+    if (i < errMin || i > errMax)
+      return String.format("<span class='error'>%s</span>", bigNumberForQuantity(i));
+    return bigNumberForQuantity(i);
+  }
+  
+  public static String commas(double i) {
+    return bigNumberForQuantity((long) i);
+  }
+  
+  public static String commas(double d, double errMin, double errMax) {
+    if (d < errMin || d > errMax)
+      return String.format("<span class='error'>%s</span>", bigNumberForQuantity(d));
+    return bigNumberForQuantity(d);
+  }
+  
+  public static String commas(long i, long warnMin, long warnMax, long errMin, long errMax) {
+    if (i < errMin || i > errMax)
+      return String.format("<span class='error'>%s</span>", bigNumberForQuantity(i));
+    if (i < warnMin || i > warnMax)
+      return String.format("<span class='warning'>%s</span>", bigNumberForQuantity(i));
+    return bigNumberForQuantity(i);
+  }
+  
+  public static String commas(double d, double warnMin, double warnMax, double errMin, double errMax) {
+    if (d < errMin || d > errMax)
+      return String.format("<span class='error'>%s</span>", bigNumberForQuantity(d));
+    if (d < warnMin || d > warnMax)
+      return String.format("<span class='warning'>%s</span>", bigNumberForQuantity(d));
+    return bigNumberForQuantity(d);
+  }
+  
+  @Override
+  public String alignment() {
+    return "right";
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PercentageType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PercentageType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PercentageType.java
new file mode 100644
index 0000000..2efc65f
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PercentageType.java
@@ -0,0 +1,40 @@
+/*
+ * 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.util.celltypes;
+
+public class PercentageType extends CellType<Double> {
+  
+  @Override
+  public int compare(Double o1, Double o2) {
+    return o1.compareTo(o2);
+  }
+  
+  @Override
+  public String alignment() {
+    return "right";
+  }
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    
+    return String.format("%.0f%s", 100 * (Double) obj, "%");
+    
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/ProgressChartType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/ProgressChartType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/ProgressChartType.java
new file mode 100644
index 0000000..20db871
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/ProgressChartType.java
@@ -0,0 +1,59 @@
+/*
+ * 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.util.celltypes;
+
+public class ProgressChartType extends NumberType<Double> {
+  
+  private double max;
+  
+  public ProgressChartType() {
+    this(1.0);
+  }
+  
+  public ProgressChartType(Double total) {
+    max = total == null ? 1.0 : total;
+  }
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    Double num = (Double) obj;
+    return getChart(num, max);
+  }
+  
+  public static String getChart(double num, double total) {
+    StringBuilder result = new StringBuilder();
+    double percent = 0;
+    if (total != 0)
+      percent = (num / total) * 100;
+    
+    int width = 0;
+    if (percent < 1)
+      width = 0;
+    else if (percent > 100)
+      width = 100;
+    else
+      width = (int) percent;
+    
+    result.append("<div class='progress-chart'>");
+    result.append("<div style='width: ").append(width).append("%;'></div>");
+    result.append("</div>&nbsp;");
+    result.append((percent < 1 && percent > 0) ? "&lt;1" : (int) percent).append("%");
+    return result.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/StringType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/StringType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/StringType.java
new file mode 100644
index 0000000..8807423
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/StringType.java
@@ -0,0 +1,40 @@
+/*
+ * 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.util.celltypes;
+
+public class StringType<T> extends CellType<T> {
+  @Override
+  public String format(Object obj) {
+    return obj == null ? "-" : obj.toString();
+  }
+  
+  @Override
+  public int compare(T o1, T o2) {
+    if (o1 == null && o2 == null)
+      return 0;
+    else if (o1 == null)
+      return -1;
+    else if (o2 == null)
+      return 1;
+    return o1.toString().compareTo(o2.toString());
+  }
+  
+  @Override
+  public String alignment() {
+    return "left";
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TServerLinkType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TServerLinkType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TServerLinkType.java
new file mode 100644
index 0000000..8ef0139
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TServerLinkType.java
@@ -0,0 +1,55 @@
+/*
+ * 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.util.celltypes;
+
+import java.net.InetSocketAddress;
+
+import org.apache.accumulo.core.master.thrift.TabletServerStatus;
+import org.apache.accumulo.core.util.AddressUtil;
+
+public class TServerLinkType extends CellType<TabletServerStatus> {
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    TabletServerStatus status = (TabletServerStatus) obj;
+    return String.format("<a href='/tservers?s=%s'>%s</a>", status.name, displayName(status));
+  }
+  
+  public static String displayName(TabletServerStatus status) {
+    return displayName(status == null ? null : status.name);
+  }
+  
+  public static String displayName(String address) {
+    if (address == null)
+      return "--Unknown--";
+    InetSocketAddress inetAddress = AddressUtil.parseAddress(address, 0);
+    return inetAddress.getHostName() + ":" + inetAddress.getPort();
+  }
+  
+  @Override
+  public int compare(TabletServerStatus o1, TabletServerStatus o2) {
+    return displayName(o1).compareTo(displayName(o2));
+  }
+  
+  @Override
+  public String alignment() {
+    return "left";
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java
new file mode 100644
index 0000000..03bd06b
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java
@@ -0,0 +1,56 @@
+/*
+ * 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.util.celltypes;
+
+import java.util.Map;
+
+import org.apache.accumulo.core.client.impl.Tables;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+
+public class TableLinkType extends CellType<String> {
+  
+  private Map<String,String> tidToNameMap;
+  
+  public TableLinkType() {
+    tidToNameMap = Tables.getIdToNameMap(HdfsZooInstance.getInstance());
+  }
+  
+  @Override
+  public String format(Object obj) {
+    if (obj == null)
+      return "-";
+    String tableId = (String) obj;
+    return String.format("<a href='/tables?t=%s'>%s</a>", tableId, displayName(tableId));
+  }
+  
+  private String displayName(String tableId) {
+    if (tableId == null)
+      return "-";
+    return Tables.getPrintableTableNameFromId(tidToNameMap, tableId);
+  }
+  
+  @Override
+  public int compare(String o1, String o2) {
+    return displayName(o1).compareTo(displayName(o2));
+  }
+  
+  @Override
+  public String alignment() {
+    return "left";
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableStateType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableStateType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableStateType.java
new file mode 100644
index 0000000..22fb498
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableStateType.java
@@ -0,0 +1,57 @@
+/*
+ * 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.util.celltypes;
+
+import org.apache.accumulo.core.master.state.tables.TableState;
+
+public class TableStateType extends CellType<TableState> {
+  
+  @Override
+  public String alignment() {
+    return "center";
+  }
+  
+  @Override
+  public String format(Object obj) {
+    TableState state = obj == null ? TableState.UNKNOWN : (TableState) obj;
+    String style = null;
+    switch (state) {
+      case ONLINE:
+      case OFFLINE:
+        break;
+      case NEW:
+      case DELETING:
+        style = "warning";
+        break;
+      case UNKNOWN:
+      default:
+        style = "error";
+    }
+    style = style != null ? " class='" + style + "'" : "";
+    return String.format("<span%s>%s</span>", style, state);
+  }
+  
+  @Override
+  public int compare(TableState o1, TableState o2) {
+    if (o1 == null && o2 == null)
+      return 0;
+    else if (o1 == null)
+      return -1;
+    return o1.compareTo(o2);
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/server/monitor/DedupedLogEvent.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/DedupedLogEvent.java b/server/monitor/src/main/java/org/apache/accumulo/server/monitor/DedupedLogEvent.java
deleted file mode 100644
index 4acb1a9..0000000
--- a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/DedupedLogEvent.java
+++ /dev/null
@@ -1,68 +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.server.monitor;
-
-import org.apache.log4j.spi.LoggingEvent;
-
-public class DedupedLogEvent {
-  
-  private LoggingEvent event;
-  private int count = 0;
-  private int hash = -1;
-  
-  public DedupedLogEvent(LoggingEvent event) {
-    this(event, 1);
-  }
-  
-  public DedupedLogEvent(LoggingEvent event, int count) {
-    this.event = event;
-    this.count = count;
-  }
-  
-  public LoggingEvent getEvent() {
-    return event;
-  }
-  
-  public int getCount() {
-    return count;
-  }
-  
-  public void setCount(int count) {
-    this.count = count;
-  }
-  
-  @Override
-  public int hashCode() {
-    if (hash == -1) {
-      String eventId = event.getMDC("application").toString() + ":" + event.getLevel().toString() + ":" + event.getMessage().toString();
-      hash = eventId.hashCode();
-    }
-    return hash;
-  }
-  
-  @Override
-  public boolean equals(Object obj) {
-    if (obj instanceof DedupedLogEvent)
-      return this.event.equals(((DedupedLogEvent) obj).event);
-    return false;
-  }
-  
-  @Override
-  public String toString() {
-    return event.getMDC("application").toString() + ":" + event.getLevel().toString() + ":" + event.getMessage().toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/server/monitor/EmbeddedWebServer.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/EmbeddedWebServer.java b/server/monitor/src/main/java/org/apache/accumulo/server/monitor/EmbeddedWebServer.java
deleted file mode 100644
index 95d39ea..0000000
--- a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/EmbeddedWebServer.java
+++ /dev/null
@@ -1,94 +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.server.monitor;
-
-import javax.servlet.http.HttpServlet;
-
-import org.apache.accumulo.core.conf.Property;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.bio.SocketConnector;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.SessionHandler;
-
-public class EmbeddedWebServer {
-  
-  Server server = null;
-  SocketConnector sock;
-  ContextHandlerCollection handler;
-  Context root;
-  boolean usingSsl;
-  
-  public EmbeddedWebServer() {
-    this("0.0.0.0", 0);
-  }
-  
-  public EmbeddedWebServer(String host, int port) {
-    server = new Server();
-    handler = new ContextHandlerCollection();
-    root = new Context(handler, "/", new SessionHandler(), null, null, null);
-    
-    if (Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE) == ""
-        || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS) == ""
-        || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE) == ""
-        || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS) == "") {
-      sock = new SocketConnector();
-      usingSsl = false;
-    } else {
-      sock = new SslSocketConnector();
-      ((SslSocketConnector) sock).setKeystore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE));
-      ((SslSocketConnector) sock).setKeyPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS));
-      ((SslSocketConnector) sock).setTruststore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE));
-      ((SslSocketConnector) sock).setTrustPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS));
-      usingSsl = true;
-    }
-    sock.setHost(host);
-    sock.setPort(port);
-  }
-  
-  public void addServlet(Class<? extends HttpServlet> klass, String where) {
-    root.addServlet(klass, where);
-  }
-  
-  public int getPort() {
-    return sock.getLocalPort();
-  }
-  
-  public void start() {
-    try {
-      server.addConnector(sock);
-      server.setHandler(handler);
-      server.start();
-    } catch (Exception e) {
-      stop();
-      throw new RuntimeException(e);
-    }
-  }
-  
-  public void stop() {
-    try {
-      server.stop();
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
-  
-  public boolean isUsingSsl() {
-    return usingSsl;
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/server/monitor/LogService.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/LogService.java b/server/monitor/src/main/java/org/apache/accumulo/server/monitor/LogService.java
deleted file mode 100644
index a123e9f..0000000
--- a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/LogService.java
+++ /dev/null
@@ -1,146 +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.server.monitor;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.util.Daemon;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.net.SocketNode;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Hijack log4j and capture log events for display.
- * 
- */
-public class LogService extends org.apache.log4j.AppenderSkeleton {
-  
-  private static final Logger log = Logger.getLogger(LogService.class);
-  
-  /**
-   * Read logging events forward to us over the net.
-   * 
-   */
-  static class SocketServer implements Runnable {
-    private ServerSocket server = null;
-    
-    public SocketServer(int port) {
-      try {
-        server = new ServerSocket(port);
-      } catch (IOException io) {
-        throw new RuntimeException(io);
-      }
-    }
-    
-    public void run() {
-      try {
-        while (true) {
-          log.debug("Waiting for log message senders");
-          Socket socket = server.accept();
-          log.debug("Got a new connection");
-          Thread t = new Daemon(new SocketNode(socket, LogManager.getLoggerRepository()));
-          t.start();
-        }
-      } catch (IOException io) {
-        log.error(io, io);
-      }
-    }
-  }
-  
-  static void startLogListener(AccumuloConfiguration conf) {
-    try {
-      new Daemon(new SocketServer(conf.getPort(Property.MONITOR_LOG4J_PORT))).start();
-    } catch (Throwable t) {
-      log.info("Unable to listen to cluster-wide ports", t);
-    }
-  }
-  
-  static private LogService instance = null;
-  
-  synchronized public static LogService getInstance() {
-    if (instance == null)
-      return new LogService();
-    return instance;
-  }
-  
-  private static final int MAX_LOGS = 50;
-  
-  private LinkedHashMap<String,DedupedLogEvent> events = new LinkedHashMap<String,DedupedLogEvent>(MAX_LOGS + 1, (float) .75, true) {
-    
-    private static final long serialVersionUID = 1L;
-    
-    @Override
-    @SuppressWarnings("rawtypes")
-    protected boolean removeEldestEntry(Map.Entry eldest) {
-      return size() > MAX_LOGS;
-    }
-  };
-  
-  public LogService() {
-    synchronized (LogService.class) {
-      instance = this;
-    }
-  }
-  
-  @Override
-  synchronized protected void append(LoggingEvent ev) {
-    Object application = ev.getMDC("application");
-    if (application == null || application.toString().isEmpty())
-      return;
-    
-    DedupedLogEvent dev = new DedupedLogEvent(ev);
-    
-    // if event is present, increase the count
-    if (events.containsKey(dev.toString())) {
-      DedupedLogEvent oldDev = events.remove(dev.toString());
-      dev.setCount(oldDev.getCount() + 1);
-    }
-    events.put(dev.toString(), dev);
-  }
-  
-  @Override
-  public void close() {
-    events = null;
-  }
-  
-  @Override
-  public synchronized void doAppend(LoggingEvent event) {
-    super.doAppend(event);
-  }
-  
-  @Override
-  public boolean requiresLayout() {
-    return false;
-  }
-  
-  synchronized public List<DedupedLogEvent> getEvents() {
-    return new ArrayList<DedupedLogEvent>(events.values());
-  }
-  
-  synchronized public void clear() {
-    events.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
deleted file mode 100644
index bff5731..0000000
--- a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
+++ /dev/null
@@ -1,669 +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.server.monitor;
-
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.impl.MasterClient;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.gc.thrift.GCMonitorService;
-import org.apache.accumulo.core.gc.thrift.GCStatus;
-import org.apache.accumulo.core.master.thrift.Compacting;
-import org.apache.accumulo.core.master.thrift.MasterClientService;
-import org.apache.accumulo.core.master.thrift.MasterMonitorInfo;
-import org.apache.accumulo.core.master.thrift.TableInfo;
-import org.apache.accumulo.core.master.thrift.TabletServerStatus;
-import org.apache.accumulo.core.security.SecurityUtil;
-import org.apache.accumulo.core.util.Daemon;
-import org.apache.accumulo.core.util.LoggingRunnable;
-import org.apache.accumulo.core.util.Pair;
-import org.apache.accumulo.core.util.ServerServices;
-import org.apache.accumulo.core.util.ServerServices.Service;
-import org.apache.accumulo.core.util.ThriftUtil;
-import org.apache.accumulo.core.util.UtilWaitThread;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
-import org.apache.accumulo.server.Accumulo;
-import org.apache.accumulo.server.ServerOpts;
-import org.apache.accumulo.server.client.HdfsZooInstance;
-import org.apache.accumulo.server.conf.ServerConfiguration;
-import org.apache.accumulo.server.fs.VolumeManager;
-import org.apache.accumulo.server.fs.VolumeManagerImpl;
-import org.apache.accumulo.server.monitor.servlets.DefaultServlet;
-import org.apache.accumulo.server.monitor.servlets.GcStatusServlet;
-import org.apache.accumulo.server.monitor.servlets.JSONServlet;
-import org.apache.accumulo.server.monitor.servlets.LogServlet;
-import org.apache.accumulo.server.monitor.servlets.MasterServlet;
-import org.apache.accumulo.server.monitor.servlets.OperationServlet;
-import org.apache.accumulo.server.monitor.servlets.ProblemServlet;
-import org.apache.accumulo.server.monitor.servlets.ShellServlet;
-import org.apache.accumulo.server.monitor.servlets.TServersServlet;
-import org.apache.accumulo.server.monitor.servlets.TablesServlet;
-import org.apache.accumulo.server.monitor.servlets.VisServlet;
-import org.apache.accumulo.server.monitor.servlets.XMLServlet;
-import org.apache.accumulo.server.monitor.servlets.trace.ListType;
-import org.apache.accumulo.server.monitor.servlets.trace.ShowTrace;
-import org.apache.accumulo.server.monitor.servlets.trace.Summary;
-import org.apache.accumulo.server.problems.ProblemReports;
-import org.apache.accumulo.server.problems.ProblemType;
-import org.apache.accumulo.server.security.SystemCredentials;
-import org.apache.accumulo.server.monitor.EmbeddedWebServer;
-import org.apache.accumulo.trace.instrument.Tracer;
-import org.apache.log4j.Logger;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-
-/**
- * Serve master statistics with an embedded web server.
- */
-public class Monitor {
-  private static final Logger log = Logger.getLogger(Monitor.class);
-  
-  public static final int REFRESH_TIME = 5;
-  private static long lastRecalc = 0L;
-  private static double totalIngestRate = 0.0;
-  private static double totalIngestByteRate = 0.0;
-  private static double totalQueryRate = 0.0;
-  private static double totalScanRate = 0.0;
-  private static double totalQueryByteRate = 0.0;
-  private static long totalEntries = 0L;
-  private static int totalTabletCount = 0;
-  private static int onlineTabletCount = 0;
-  private static long totalHoldTime = 0;
-  private static long totalLookups = 0;
-  private static int totalTables = 0;
-  
-  private static class MaxList<T> extends LinkedList<Pair<Long,T>> {
-    private static final long serialVersionUID = 1L;
-    
-    private long maxDelta;
-    
-    public MaxList(long maxDelta) {
-      this.maxDelta = maxDelta;
-    }
-    
-    @Override
-    public boolean add(Pair<Long,T> obj) {
-      boolean result = super.add(obj);
-      
-      if (obj.getFirst() - get(0).getFirst() > maxDelta)
-        remove(0);
-      
-      return result;
-    }
-    
-  }
-  
-  private static final int MAX_TIME_PERIOD = 60 * 60 * 1000;
-  private static final List<Pair<Long,Double>> loadOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Double>> ingestRateOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Double>> ingestByteRateOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Integer>> recoveriesOverTime = Collections.synchronizedList(new MaxList<Integer>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Integer>> minorCompactionsOverTime = Collections.synchronizedList(new MaxList<Integer>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Integer>> majorCompactionsOverTime = Collections.synchronizedList(new MaxList<Integer>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Double>> lookupsOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Integer>> queryRateOverTime = Collections.synchronizedList(new MaxList<Integer>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Integer>> scanRateOverTime = Collections.synchronizedList(new MaxList<Integer>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Double>> queryByteRateOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Double>> indexCacheHitRateOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static final List<Pair<Long,Double>> dataCacheHitRateOverTime = Collections.synchronizedList(new MaxList<Double>(MAX_TIME_PERIOD));
-  private static EventCounter lookupRateTracker = new EventCounter();
-  private static EventCounter indexCacheHitTracker = new EventCounter();
-  private static EventCounter indexCacheRequestTracker = new EventCounter();
-  private static EventCounter dataCacheHitTracker = new EventCounter();
-  private static EventCounter dataCacheRequestTracker = new EventCounter();
-  
-  private static volatile boolean fetching = false;
-  private static MasterMonitorInfo mmi;
-  private static Map<String,Map<ProblemType,Integer>> problemSummary = Collections.emptyMap();
-  private static Exception problemException;
-  private static GCStatus gcStatus;
-  
-  private static Instance instance;
-  
-  private static ServerConfiguration config;
-  
-  private static EmbeddedWebServer server;
-  
-  public static Map<String,Double> summarizeTableStats(MasterMonitorInfo mmi) {
-    Map<String,Double> compactingByTable = new HashMap<String,Double>();
-    if (mmi != null && mmi.tServerInfo != null) {
-      for (TabletServerStatus status : mmi.tServerInfo) {
-        if (status != null && status.tableMap != null) {
-          for (String table : status.tableMap.keySet()) {
-            Double holdTime = compactingByTable.get(table);
-            compactingByTable.put(table, Math.max(holdTime == null ? 0. : holdTime.doubleValue(), status.holdTime));
-          }
-        }
-      }
-    }
-    return compactingByTable;
-  }
-  
-  public static void add(TableInfo total, TableInfo more) {
-    if (total.minors == null)
-      total.minors = new Compacting();
-    if (total.majors == null)
-      total.majors = new Compacting();
-    if (total.scans == null)
-      total.scans = new Compacting();
-    if (more.minors != null) {
-      total.minors.running += more.minors.running;
-      total.minors.queued += more.minors.queued;
-    }
-    if (more.majors != null) {
-      total.majors.running += more.majors.running;
-      total.majors.queued += more.majors.queued;
-    }
-    if (more.scans != null) {
-      total.scans.running += more.scans.running;
-      total.scans.queued += more.scans.queued;
-    }
-    total.onlineTablets += more.onlineTablets;
-    total.recs += more.recs;
-    total.recsInMemory += more.recsInMemory;
-    total.tablets += more.tablets;
-    total.ingestRate += more.ingestRate;
-    total.ingestByteRate += more.ingestByteRate;
-    total.queryRate += more.queryRate;
-    total.queryByteRate += more.queryByteRate;
-    total.scanRate += more.scanRate;
-  }
-  
-  public static TableInfo summarizeTableStats(TabletServerStatus status) {
-    TableInfo summary = new TableInfo();
-    summary.majors = new Compacting();
-    summary.minors = new Compacting();
-    summary.scans = new Compacting();
-    for (TableInfo rates : status.tableMap.values()) {
-      add(summary, rates);
-    }
-    return summary;
-  }
-  
-  private static class EventCounter {
-    
-    Map<String,Pair<Long,Long>> prevSamples = new HashMap<String,Pair<Long,Long>>();
-    Map<String,Pair<Long,Long>> samples = new HashMap<String,Pair<Long,Long>>();
-    Set<String> serversUpdated = new HashSet<String>();
-    
-    void startingUpdates() {
-      serversUpdated.clear();
-    }
-    
-    void updateTabletServer(String name, long sampleTime, long numEvents) {
-      Pair<Long,Long> newSample = new Pair<Long,Long>(sampleTime, numEvents);
-      Pair<Long,Long> lastSample = samples.get(name);
-      
-      if (lastSample == null || !lastSample.equals(newSample)) {
-        samples.put(name, newSample);
-        if (lastSample != null) {
-          prevSamples.put(name, lastSample);
-        }
-      }
-      serversUpdated.add(name);
-    }
-    
-    void finishedUpdating() {
-      // remove any tablet servers not updated
-      samples.keySet().retainAll(serversUpdated);
-      prevSamples.keySet().retainAll(serversUpdated);
-    }
-    
-    double calculateRate() {
-      double totalRate = 0;
-      
-      for (Entry<String,Pair<Long,Long>> entry : prevSamples.entrySet()) {
-        Pair<Long,Long> prevSample = entry.getValue();
-        Pair<Long,Long> sample = samples.get(entry.getKey());
-        
-        totalRate += (sample.getSecond() - prevSample.getSecond()) / ((sample.getFirst() - prevSample.getFirst()) / (double) 1000);
-      }
-      
-      return totalRate;
-    }
-    
-    long calculateCount() {
-      long count = 0;
-      
-      for (Entry<String,Pair<Long,Long>> entry : prevSamples.entrySet()) {
-        Pair<Long,Long> prevSample = entry.getValue();
-        Pair<Long,Long> sample = samples.get(entry.getKey());
-        
-        count += sample.getSecond() - prevSample.getSecond();
-      }
-      
-      return count;
-    }
-  }
-  
-  public static void fetchData() {
-    double totalIngestRate = 0.;
-    double totalIngestByteRate = 0.;
-    double totalQueryRate = 0.;
-    double totalQueryByteRate = 0.;
-    double totalScanRate = 0.;
-    long totalEntries = 0;
-    int totalTabletCount = 0;
-    int onlineTabletCount = 0;
-    long totalHoldTime = 0;
-    long totalLookups = 0;
-    boolean retry = true;
-    
-    // only recalc every so often
-    long currentTime = System.currentTimeMillis();
-    if (currentTime - lastRecalc < REFRESH_TIME * 1000)
-      return;
-    
-    synchronized (Monitor.class) {
-      if (fetching)
-        return;
-      fetching = true;
-    }
-    
-    try {
-      while (retry) {
-        MasterClientService.Iface client = null;
-        try {
-          client = MasterClient.getConnection(HdfsZooInstance.getInstance());
-          if (client != null) {
-            mmi = client.getMasterStats(Tracer.traceInfo(), SystemCredentials.get().toThrift(HdfsZooInstance.getInstance()));
-            retry = false;
-          } else {
-            mmi = null;
-          }
-          Monitor.gcStatus = fetchGcStatus();
-        } catch (Exception e) {
-          mmi = null;
-          log.info("Error fetching stats: " + e);
-        } finally {
-          if (client != null) {
-            MasterClient.close(client);
-          }
-        }
-        if (mmi == null)
-          UtilWaitThread.sleep(1000);
-      }
-      if (mmi != null) {
-        int majorCompactions = 0;
-        int minorCompactions = 0;
-        
-        lookupRateTracker.startingUpdates();
-        indexCacheHitTracker.startingUpdates();
-        indexCacheRequestTracker.startingUpdates();
-        dataCacheHitTracker.startingUpdates();
-        dataCacheRequestTracker.startingUpdates();
-        
-        for (TabletServerStatus server : mmi.tServerInfo) {
-          TableInfo summary = Monitor.summarizeTableStats(server);
-          totalIngestRate += summary.ingestRate;
-          totalIngestByteRate += summary.ingestByteRate;
-          totalQueryRate += summary.queryRate;
-          totalScanRate += summary.scanRate;
-          totalQueryByteRate += summary.queryByteRate;
-          totalEntries += summary.recs;
-          totalHoldTime += server.holdTime;
-          totalLookups += server.lookups;
-          majorCompactions += summary.majors.running;
-          minorCompactions += summary.minors.running;
-          lookupRateTracker.updateTabletServer(server.name, server.lastContact, server.lookups);
-          indexCacheHitTracker.updateTabletServer(server.name, server.lastContact, server.indexCacheHits);
-          indexCacheRequestTracker.updateTabletServer(server.name, server.lastContact, server.indexCacheRequest);
-          dataCacheHitTracker.updateTabletServer(server.name, server.lastContact, server.dataCacheHits);
-          dataCacheRequestTracker.updateTabletServer(server.name, server.lastContact, server.dataCacheRequest);
-        }
-        
-        lookupRateTracker.finishedUpdating();
-        indexCacheHitTracker.finishedUpdating();
-        indexCacheRequestTracker.finishedUpdating();
-        dataCacheHitTracker.finishedUpdating();
-        dataCacheRequestTracker.finishedUpdating();
-        
-        int totalTables = 0;
-        for (TableInfo tInfo : mmi.tableMap.values()) {
-          totalTabletCount += tInfo.tablets;
-          onlineTabletCount += tInfo.onlineTablets;
-          totalTables++;
-        }
-        Monitor.totalIngestRate = totalIngestRate;
-        Monitor.totalTables = totalTables;
-        totalIngestByteRate = totalIngestByteRate / 1000000.0;
-        Monitor.totalIngestByteRate = totalIngestByteRate;
-        Monitor.totalQueryRate = totalQueryRate;
-        Monitor.totalScanRate = totalScanRate;
-        totalQueryByteRate = totalQueryByteRate / 1000000.0;
-        Monitor.totalQueryByteRate = totalQueryByteRate;
-        Monitor.totalEntries = totalEntries;
-        Monitor.totalTabletCount = totalTabletCount;
-        Monitor.onlineTabletCount = onlineTabletCount;
-        Monitor.totalHoldTime = totalHoldTime;
-        Monitor.totalLookups = totalLookups;
-        
-        ingestRateOverTime.add(new Pair<Long,Double>(currentTime, totalIngestRate));
-        ingestByteRateOverTime.add(new Pair<Long,Double>(currentTime, totalIngestByteRate));
-        
-        double totalLoad = 0.;
-        for (TabletServerStatus status : mmi.tServerInfo) {
-          if (status != null)
-            totalLoad += status.osLoad;
-        }
-        loadOverTime.add(new Pair<Long,Double>(currentTime, totalLoad));
-        
-        minorCompactionsOverTime.add(new Pair<Long,Integer>(currentTime, minorCompactions));
-        majorCompactionsOverTime.add(new Pair<Long,Integer>(currentTime, majorCompactions));
-        
-        lookupsOverTime.add(new Pair<Long,Double>(currentTime, lookupRateTracker.calculateRate()));
-        
-        queryRateOverTime.add(new Pair<Long,Integer>(currentTime, (int) totalQueryRate));
-        queryByteRateOverTime.add(new Pair<Long,Double>(currentTime, totalQueryByteRate));
-        
-        scanRateOverTime.add(new Pair<Long,Integer>(currentTime, (int) totalScanRate));
-        
-        calcCacheHitRate(indexCacheHitRateOverTime, currentTime, indexCacheHitTracker, indexCacheRequestTracker);
-        calcCacheHitRate(dataCacheHitRateOverTime, currentTime, dataCacheHitTracker, dataCacheRequestTracker);
-      }
-      try {
-        Monitor.problemSummary = ProblemReports.getInstance().summarize();
-        Monitor.problemException = null;
-      } catch (Exception e) {
-        log.info("Failed to obtain problem reports ", e);
-        Monitor.problemSummary = Collections.emptyMap();
-        Monitor.problemException = e;
-      }
-      
-    } finally {
-      synchronized (Monitor.class) {
-        fetching = false;
-        lastRecalc = currentTime;
-      }
-    }
-  }
-  
-  private static void calcCacheHitRate(List<Pair<Long,Double>> hitRate, long currentTime, EventCounter cacheHits, EventCounter cacheReq) {
-    long req = cacheReq.calculateCount();
-    if (req > 0)
-      hitRate.add(new Pair<Long,Double>(currentTime, cacheHits.calculateCount() / (double) cacheReq.calculateCount()));
-    else
-      hitRate.add(new Pair<Long,Double>(currentTime, null));
-  }
-  
-  private static GCStatus fetchGcStatus() {
-    GCStatus result = null;
-    InetSocketAddress address = null;
-    try {
-      // Read the gc location from its lock
-      Instance instance = HdfsZooInstance.getInstance();
-      String zooKeepers = instance.getZooKeepers();
-      log.debug("connecting to zookeepers " + zooKeepers);
-      ZooKeeper zk = new ZooKeeper(zooKeepers, (int) config.getConfiguration().getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), new Watcher() {
-        @Override
-        public void process(WatchedEvent event) {}
-      });
-      try {
-        String path = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZGC_LOCK;
-        List<String> locks = zk.getChildren(path, null);
-        if (locks != null && locks.size() > 0) {
-          Collections.sort(locks);
-          address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null, null))).getAddress(Service.GC_CLIENT);
-          GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(), address, config.getConfiguration());
-          try {
-            result = client.getStatus(Tracer.traceInfo(), SystemCredentials.get().toThrift(instance));
-          } finally {
-            ThriftUtil.returnClient(client);
-          }
-        }
-      } finally {
-        zk.close();
-      }
-    } catch (Exception ex) {
-      log.warn("Unable to contact the garbage collector at " + address, ex);
-    }
-    return result;
-  }
-  
-  public static void main(String[] args) throws Exception {
-    SecurityUtil.serverLogin();
-    
-    VolumeManager fs = VolumeManagerImpl.get();
-    ServerOpts opts = new ServerOpts();
-    opts.parseArgs("monitor", args);
-    String hostname = opts.getAddress();
-    instance = HdfsZooInstance.getInstance();
-    config = new ServerConfiguration(instance);
-    Accumulo.init(fs, config, "monitor");
-    Monitor monitor = new Monitor();
-    Accumulo.enableTracing(hostname, "monitor");
-    monitor.run(hostname);
-  }
-  
-  private static long START_TIME;
-  
-  public void run(String hostname) {
-    Monitor.START_TIME = System.currentTimeMillis();
-    int port = config.getConfiguration().getPort(Property.MONITOR_PORT);
-    try {
-      log.debug("Creating monitor on port " + port);
-      server = new EmbeddedWebServer(hostname, port);
-    } catch (Throwable ex) {
-      log.error("Unable to start embedded web server", ex);
-      throw new RuntimeException(ex);
-    }
-    
-    server.addServlet(DefaultServlet.class, "/");
-    server.addServlet(OperationServlet.class, "/op");
-    server.addServlet(MasterServlet.class, "/master");
-    server.addServlet(TablesServlet.class, "/tables");
-    server.addServlet(TServersServlet.class, "/tservers");
-    server.addServlet(ProblemServlet.class, "/problems");
-    server.addServlet(GcStatusServlet.class, "/gc");
-    server.addServlet(LogServlet.class, "/log");
-    server.addServlet(XMLServlet.class, "/xml");
-    server.addServlet(JSONServlet.class, "/json");
-    server.addServlet(VisServlet.class, "/vis");
-    server.addServlet(Summary.class, "/trace/summary");
-    server.addServlet(ListType.class, "/trace/listType");
-    server.addServlet(ShowTrace.class, "/trace/show");
-    if (server.isUsingSsl())
-      server.addServlet(ShellServlet.class, "/shell");
-    LogService.startLogListener(Monitor.getSystemConfiguration());
-    server.start();
-    
-    new Daemon(new LoggingRunnable(log, new ZooKeeperStatus()), "ZooKeeperStatus").start();
-    
-    // need to regularly fetch data so plot data is updated
-    new Daemon(new LoggingRunnable(log, new Runnable() {
-      
-      @Override
-      public void run() {
-        while (true) {
-          try {
-            Monitor.fetchData();
-          } catch (Exception e) {
-            log.warn(e.getMessage(), e);
-          }
-          
-          UtilWaitThread.sleep(333);
-        }
-        
-      }
-    }), "Data fetcher").start();
-  }
-  
-  public static MasterMonitorInfo getMmi() {
-    return mmi;
-  }
-  
-  public static int getTotalTables() {
-    return totalTables;
-  }
-  
-  public static int getTotalTabletCount() {
-    return totalTabletCount;
-  }
-  
-  public static int getOnlineTabletCount() {
-    return onlineTabletCount;
-  }
-  
-  public static long getTotalEntries() {
-    return totalEntries;
-  }
-  
-  public static double getTotalIngestRate() {
-    return totalIngestRate;
-  }
-  
-  public static double getTotalIngestByteRate() {
-    return totalIngestByteRate;
-  }
-  
-  public static double getTotalQueryRate() {
-    return totalQueryRate;
-  }
-  
-  public static double getTotalScanRate() {
-    return totalScanRate;
-  }
-  
-  public static double getTotalQueryByteRate() {
-    return totalQueryByteRate;
-  }
-  
-  public static long getTotalHoldTime() {
-    return totalHoldTime;
-  }
-  
-  public static Exception getProblemException() {
-    return problemException;
-  }
-  
-  public static Map<String,Map<ProblemType,Integer>> getProblemSummary() {
-    return problemSummary;
-  }
-  
-  public static GCStatus getGcStatus() {
-    return gcStatus;
-  }
-  
-  public static long getTotalLookups() {
-    return totalLookups;
-  }
-  
-  public static long getStartTime() {
-    return START_TIME;
-  }
-  
-  public static List<Pair<Long,Double>> getLoadOverTime() {
-    synchronized (loadOverTime) {
-      return new ArrayList<Pair<Long,Double>>(loadOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Double>> getIngestRateOverTime() {
-    synchronized (ingestRateOverTime) {
-      return new ArrayList<Pair<Long,Double>>(ingestRateOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Double>> getIngestByteRateOverTime() {
-    synchronized (ingestByteRateOverTime) {
-      return new ArrayList<Pair<Long,Double>>(ingestByteRateOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Integer>> getRecoveriesOverTime() {
-    synchronized (recoveriesOverTime) {
-      return new ArrayList<Pair<Long,Integer>>(recoveriesOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Integer>> getMinorCompactionsOverTime() {
-    synchronized (minorCompactionsOverTime) {
-      return new ArrayList<Pair<Long,Integer>>(minorCompactionsOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Integer>> getMajorCompactionsOverTime() {
-    synchronized (majorCompactionsOverTime) {
-      return new ArrayList<Pair<Long,Integer>>(majorCompactionsOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Double>> getLookupsOverTime() {
-    synchronized (lookupsOverTime) {
-      return new ArrayList<Pair<Long,Double>>(lookupsOverTime);
-    }
-  }
-  
-  public static double getLookupRate() {
-    return lookupRateTracker.calculateRate();
-  }
-  
-  public static List<Pair<Long,Integer>> getQueryRateOverTime() {
-    synchronized (queryRateOverTime) {
-      return new ArrayList<Pair<Long,Integer>>(queryRateOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Integer>> getScanRateOverTime() {
-    synchronized (scanRateOverTime) {
-      return new ArrayList<Pair<Long,Integer>>(scanRateOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Double>> getQueryByteRateOverTime() {
-    synchronized (queryByteRateOverTime) {
-      return new ArrayList<Pair<Long,Double>>(queryByteRateOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Double>> getIndexCacheHitRateOverTime() {
-    synchronized (indexCacheHitRateOverTime) {
-      return new ArrayList<Pair<Long,Double>>(indexCacheHitRateOverTime);
-    }
-  }
-  
-  public static List<Pair<Long,Double>> getDataCacheHitRateOverTime() {
-    synchronized (dataCacheHitRateOverTime) {
-      return new ArrayList<Pair<Long,Double>>(dataCacheHitRateOverTime);
-    }
-  }
-  
-  public static AccumuloConfiguration getSystemConfiguration() {
-    return config.getConfiguration();
-  }
-  
-  public static Instance getInstance() {
-    return instance;
-  }
-  
-  public static boolean isUsingSsl() {
-    return server.isUsingSsl();
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e0533561/server/monitor/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java b/server/monitor/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
deleted file mode 100644
index c3ef3a0..0000000
--- a/server/monitor/src/main/java/org/apache/accumulo/server/monitor/ZooKeeperStatus.java
+++ /dev/null
@@ -1,138 +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.server.monitor;
-
-import java.net.InetSocketAddress;
-import java.util.Collection;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.util.TTimeoutTransport;
-import org.apache.accumulo.core.util.UtilWaitThread;
-import org.apache.accumulo.server.conf.ServerConfiguration;
-import org.apache.log4j.Logger;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-
-public class ZooKeeperStatus implements Runnable {
-  
-  private static final Logger log = Logger.getLogger(ZooKeeperStatus.class);
-  
-  private volatile boolean stop = false;
-  
-  public static class ZooKeeperState implements Comparable<ZooKeeperState> {
-    public final String keeper;
-    public final String mode;
-    public final int clients;
-    
-    public ZooKeeperState(String keeper, String mode, int clients) {
-      this.keeper = keeper;
-      this.mode = mode;
-      this.clients = clients;
-    }
-    
-    @Override
-    public int compareTo(ZooKeeperState other) {
-      if (this == other) {
-        return 0;
-      } else if (other == null) {
-        return 1;
-      } else {
-        if (this.keeper == other.keeper) {
-          return 0;
-        } else if (null == this.keeper) {
-          return -1;
-        } else if (null == other.keeper) {
-          return 1;
-        } else {
-          return this.keeper.compareTo(other.keeper);
-        }
-      }
-    }
-  }
-  
-  private static SortedSet<ZooKeeperState> status = new TreeSet<ZooKeeperState>();
-  
-  public static Collection<ZooKeeperState> getZooKeeperStatus() {
-    return status;
-  }
-  
-  public void stop() {
-    this.stop = true;
-  }
-  
-  @Override
-  public void run() {
-    
-    while (!stop) {
-      
-      TreeSet<ZooKeeperState> update = new TreeSet<ZooKeeperState>();
-      
-      String zookeepers[] = ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST).split(",");
-      for (String keeper : zookeepers) {
-        int clients = 0;
-        String mode = "unknown";
-        
-        String[] parts = keeper.split(":");
-        TTransport transport = null;
-        try {
-          InetSocketAddress addr;
-          if (parts.length > 1)
-            addr = new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
-          else
-            addr = new InetSocketAddress(parts[0], 2181);
-          
-          transport = TTimeoutTransport.create(addr, 10 * 1000l);
-          transport.write("stat\n".getBytes(), 0, 5);
-          StringBuilder response = new StringBuilder();
-          try {
-            transport.flush();
-            byte[] buffer = new byte[1024 * 100];
-            int n = 0;
-            while ((n = transport.read(buffer, 0, buffer.length)) > 0) {
-              response.append(new String(buffer, 0, n));
-            }
-          } catch (TTransportException ex) {
-            // happens at EOF
-          }
-          for (String line : response.toString().split("\n")) {
-            if (line.startsWith(" "))
-              clients++;
-            if (line.startsWith("Mode"))
-              mode = line.split(":")[1];
-          }
-          update.add(new ZooKeeperState(keeper, mode, clients));
-        } catch (Exception ex) {
-          log.info("Exception talking to zookeeper " + keeper, ex);
-          update.add(new ZooKeeperState(keeper, "Down", -1));
-        } finally {
-          if (transport != null) {
-            try {
-              transport.close();
-            } catch (Exception ex) {
-              log.error(ex, ex);
-            }
-          }
-        }
-      }
-      status = update;
-      UtilWaitThread.sleep(1000);
-    }
-  }
-  
-}


Mime
View raw message