Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DCA4B10366 for ; Mon, 15 Dec 2014 16:30:37 +0000 (UTC) Received: (qmail 44264 invoked by uid 500); 15 Dec 2014 16:30:37 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 44229 invoked by uid 500); 15 Dec 2014 16:30:37 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 44220 invoked by uid 99); 15 Dec 2014 16:30:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Dec 2014 16:30:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 26BFDA2B58F; Mon, 15 Dec 2014 16:30:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ecn@apache.org To: commits@accumulo.apache.org Message-Id: <7a691a1c9e904a30bb17b80eb6cb29b7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: accumulo git commit: ACCUMULO-3408 fix many assumptions about NumberType, and move the class to the proper package Date: Mon, 15 Dec 2014 16:30:37 +0000 (UTC) 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 Authored: Mon Dec 15 11:30:10 2014 -0500 Committer: Eric C. Newton 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 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 { - - 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("%s", display); - if (i < warnMin || i > warnMax) - return String.format("%s", 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 { + + 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("%s", display); + } + if ((warnMin != null && i < warnMin) || (warnMax != null && i > warnMax)) { + return String.format("%s", 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("1", p.format(1)); assertEquals("5,005", p.format(5005)); assertEquals("10,000", p.format(10000)); + assertEquals("-", p.format(null)); + assertEquals("3,000", p.format(Long.valueOf(3000L))); } }