accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [1/6] git commit: ACCUMULO-2631 Make sure a valid range is created.
Date Sat, 05 Apr 2014 01:46:09 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.5.2-SNAPSHOT ab41a5f86 -> 7ffa80a18
  refs/heads/1.6.0-SNAPSHOT b6dee7fbb -> 6831e127a
  refs/heads/master 9c3aec816 -> 2ba701e87


ACCUMULO-2631 Make sure a valid range is created.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/7ffa80a1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7ffa80a1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7ffa80a1

Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 7ffa80a183ad5e8e4d9487a521acae0eb6951c26
Parents: ab41a5f
Author: Josh Elser <elserj@apache.org>
Authored: Fri Apr 4 21:23:32 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Apr 4 21:23:32 2014 -0400

----------------------------------------------------------------------
 .../server/monitor/servlets/trace/Summary.java  | 21 ++++++++--
 .../monitor/servlets/trace/SummaryTest.java     | 42 ++++++++++++++++++++
 2 files changed, 60 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7ffa80a1/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Summary.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Summary.java
b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Summary.java
index 329cf4f..e9f7d4a 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Summary.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Summary.java
@@ -121,18 +121,33 @@ public class Summary extends Basic {
       return 0;
     }
   }
+
+  protected Range getRangeForTrace(long minutesSince) {
+    long endTime = System.currentTimeMillis();
+    long millisSince = minutesSince * 60 * 1000;
+    // Catch the overflow
+    if (millisSince < minutesSince) {
+      millisSince = endTime;
+    }
+    long startTime = endTime - millisSince;
+
+    String startHexTime = Long.toHexString(startTime), endHexTime = Long.toHexString(endTime);
+    while (startHexTime.length() < endHexTime.length()) {
+      startHexTime = "0" + startHexTime;
+    }
+
+    return new Range(new Text("start:" + startHexTime), new Text("start:" + endHexTime));
+  }
   
   @Override
   public void pageBody(HttpServletRequest req, HttpServletResponse resp, StringBuilder sb)
throws Exception {
     int minutes = getMinutes(req);
-    long endTime = System.currentTimeMillis();
-    long startTime = endTime - minutes * 60 * 1000;
     
     Scanner scanner = getScanner(sb);
     if (scanner == null) {
       return;
     }
-    Range range = new Range(new Text("start:" + Long.toHexString(startTime)), new Text("start:"
+ Long.toHexString(endTime)));
+    Range range = getRangeForTrace(minutes);
     scanner.setRange(range);
     Map<String,Stats> summary = new TreeMap<String,Stats>();
     for (Entry<Key,Value> entry : scanner) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7ffa80a1/server/src/test/java/org/apache/accumulo/server/monitor/servlets/trace/SummaryTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/monitor/servlets/trace/SummaryTest.java
b/server/src/test/java/org/apache/accumulo/server/monitor/servlets/trace/SummaryTest.java
new file mode 100644
index 0000000..f983066
--- /dev/null
+++ b/server/src/test/java/org/apache/accumulo/server/monitor/servlets/trace/SummaryTest.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.server.monitor.servlets.trace;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class SummaryTest {
+
+  private Summary summary;
+
+  @Before
+  public void setup() {
+    summary = new Summary();
+  }
+
+  @Test
+  public void testRangeValues() {
+    summary.getRangeForTrace(10);
+    summary.getRangeForTrace(100);
+    summary.getRangeForTrace(4990000);
+    summary.getRangeForTrace(Long.MAX_VALUE);
+  }
+
+}


Mime
View raw message