You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/12/15 17:30:37 UTC
accumulo git commit: ACCUMULO-3408 fix many assumptions about
NumberType, and move the class to the proper package
Repository: accumulo
Updated Branches:
refs/heads/1.6 c07e3d063 -> cabf265ae
ACCUMULO-3408 fix many assumptions about NumberType, and move the class to the proper package
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cabf265a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cabf265a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cabf265a
Branch: refs/heads/1.6
Commit: cabf265ae44d27120d13ceef13a030d7698c365f
Parents: c07e3d0
Author: Eric C. Newton <er...@gmail.com>
Authored: Mon Dec 15 11:30:10 2014 -0500
Committer: Eric C. Newton <er...@gmail.com>
Committed: Mon Dec 15 11:30:10 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/monitor/Monitor.java | 4 +-
.../monitor/servlets/MasterServlet.java | 2 +
.../monitor/servlets/PreciseNumberType.java | 39 ------------------
.../accumulo/monitor/servlets/ScanServlet.java | 16 ++++----
.../util/celltypes/PreciseNumberType.java | 42 ++++++++++++++++++++
.../util/celltypes/PreciseNumberTypeTest.java | 4 +-
6 files changed, 55 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cabf265a/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 64db98f..5385657 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
@@ -511,7 +511,7 @@ public class Monitor {
public static class ScanStats {
public final long scanCount;
- public final long oldestScan;
+ public final Long oldestScan;
public final long fetched;
ScanStats(List<ActiveScan> active) {
this.scanCount = active.size();
@@ -519,7 +519,7 @@ public class Monitor {
for (ActiveScan scan : active) {
oldest = Math.max(oldest, scan.age);
}
- this.oldestScan = oldest;
+ this.oldestScan = oldest < 0 ? null : oldest;
this.fetched = System.currentTimeMillis();
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cabf265a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/MasterServlet.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/MasterServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/MasterServlet.java
index 0466405..c7767f7 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/MasterServlet.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/MasterServlet.java
@@ -27,6 +27,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.accumulo.monitor.util.celltypes.PreciseNumberType;
+
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.master.thrift.DeadServer;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cabf265a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/PreciseNumberType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/PreciseNumberType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/PreciseNumberType.java
deleted file mode 100644
index 1642fc2..0000000
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/PreciseNumberType.java
+++ /dev/null
@@ -1,39 +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.apache.accumulo.monitor.util.celltypes.NumberType;
-
-public class PreciseNumberType extends NumberType<Integer> {
-
- public PreciseNumberType(int warnMin, int warnMax, int errMin, int errMax) {
- super(warnMin, warnMax, errMin, errMax);
- }
-
- @Override
- public String format(Object obj) {
- int i = (Integer)obj;
- String display = String.format("%,d", obj);
- if (i < errMin || i > errMax)
- return String.format("<span class='error'>%s</span>", display);
- if (i < warnMin || i > warnMax)
- return String.format("<span class='warning'>%s</span>", display);
- return display;
- }
-
- public PreciseNumberType() {}
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cabf265a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ScanServlet.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ScanServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ScanServlet.java
index b6bda20..87c1755 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ScanServlet.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ScanServlet.java
@@ -22,6 +22,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.accumulo.monitor.util.celltypes.PreciseNumberType;
+
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.monitor.Monitor;
import org.apache.accumulo.monitor.Monitor.ScanStats;
@@ -48,17 +50,13 @@ public class ScanServlet extends BasicServlet {
scanTable.addSortableColumn("Oldest Age", new DurationType(0l, 5 * 60 * 1000l), "The age of the oldest scan on this server.");
for (TabletServerStatus tserverInfo : Monitor.getMmi().getTServerInfo()) {
ScanStats stats = scans.get(tserverInfo.name);
- long count = 0;
- long oldest = 0;
if (stats != null) {
- count = stats.scanCount;
- oldest = stats.oldestScan;
+ TableRow row = scanTable.prepareRow();
+ row.add(tserverInfo);
+ row.add(stats.scanCount);
+ row.add(stats.oldestScan);
+ scanTable.addRow(row);
}
- TableRow row = scanTable.prepareRow();
- row.add(tserverInfo);
- row.add(count);
- row.add(oldest);
- scanTable.addRow(row);
}
scanTable.generate(req, sb);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cabf265a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberType.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberType.java
new file mode 100644
index 0000000..0fd5d96
--- /dev/null
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberType.java
@@ -0,0 +1,42 @@
+/*
+ * 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 PreciseNumberType extends NumberType<Integer> {
+
+ public PreciseNumberType(int warnMin, int warnMax, int errMin, int errMax) {
+ super(warnMin, warnMax, errMin, errMax);
+ }
+
+ @Override
+ public String format(Object obj) {
+ if (obj == null)
+ return "-";
+ int i = ((Number)obj).intValue();
+ String display = String.format("%,d", obj);
+ if ((errMin != null && i < errMin) || (errMax != null && i > errMax)) {
+ return String.format("<span class='error'>%s</span>", display);
+ }
+ if ((warnMin != null && i < warnMin) || (warnMax != null && i > warnMax)) {
+ return String.format("<span class='warning'>%s</span>", display);
+ }
+ return display;
+ }
+
+ public PreciseNumberType() {}
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cabf265a/server/monitor/src/test/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberTypeTest.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/test/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberTypeTest.java b/server/monitor/src/test/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberTypeTest.java
index 38d3d2b..ab3c31c 100644
--- a/server/monitor/src/test/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberTypeTest.java
+++ b/server/monitor/src/test/java/org/apache/accumulo/monitor/util/celltypes/PreciseNumberTypeTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.accumulo.monitor.util.celltypes;
-import org.apache.accumulo.monitor.servlets.PreciseNumberType;
-
import org.junit.Test;
import static org.junit.Assert.*;
@@ -30,6 +28,8 @@ public class PreciseNumberTypeTest {
assertEquals("<span class='error'>1</span>", p.format(1));
assertEquals("<span class='warning'>5,005</span>", p.format(5005));
assertEquals("<span class='error'>10,000</span>", p.format(10000));
+ assertEquals("-", p.format(null));
+ assertEquals("3,000", p.format(Long.valueOf(3000L)));
}
}