You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2020/08/24 20:56:13 UTC
[hbase] branch branch-1 updated: Revert "HBASE-24898 Use
EnvironmentEdge.currentTime() instead of System.currentTimeMillis() in
CurrentHourProvider"
This is an automated email from the ASF dual-hosted git repository.
apurtell pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-1 by this push:
new cbfbdd9 Revert "HBASE-24898 Use EnvironmentEdge.currentTime() instead of System.currentTimeMillis() in CurrentHourProvider"
cbfbdd9 is described below
commit cbfbdd9635e87d4747f9ba9a1e57685e964ef130
Author: Andrew Purtell <ap...@apache.org>
AuthorDate: Mon Aug 24 13:55:40 2020 -0700
Revert "HBASE-24898 Use EnvironmentEdge.currentTime() instead of System.currentTimeMillis() in CurrentHourProvider"
This reverts commit e7fdf58b3df5f68f5a7cf11ca3bafa1a3532b4e3.
---
.../compactions/CurrentHourProvider.java | 4 +-
.../compactions/TestCurrentHourProvider.java | 66 ----------------------
2 files changed, 1 insertion(+), 69 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CurrentHourProvider.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CurrentHourProvider.java
index 2d621cb..37bb1f2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CurrentHourProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CurrentHourProvider.java
@@ -21,7 +21,6 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@InterfaceAudience.Private
public class CurrentHourProvider {
@@ -39,7 +38,6 @@ public class CurrentHourProvider {
private static Tick nextTick() {
Calendar calendar = new GregorianCalendar();
- calendar.setTimeInMillis(EnvironmentEdgeManager.currentTime());
int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
moveToNextHour(calendar);
return new Tick(currentHour, calendar.getTimeInMillis());
@@ -56,7 +54,7 @@ public class CurrentHourProvider {
public static int getCurrentHour() {
Tick tick = CurrentHourProvider.tick;
- if (EnvironmentEdgeManager.currentTime() < tick.expirationTimeInMillis) {
+ if(System.currentTimeMillis() < tick.expirationTimeInMillis) {
return tick.currentHour;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java
deleted file mode 100644
index 88a9e4c..0000000
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java
+++ /dev/null
@@ -1,66 +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.hadoop.hbase.regionserver.compactions;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.TimeZone;
-import org.apache.hadoop.hbase.testclassification.RegionServerTests;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.apache.hadoop.hbase.util.EnvironmentEdge;
-import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Category({RegionServerTests.class, SmallTests.class})
-public class TestCurrentHourProvider {
- private static final Logger LOG = LoggerFactory.getLogger(TestCurrentHourProvider.class);
-
- /**
- * In timezone GMT+08:00, the unix time of 2020-08-20 11:52:41 is 1597895561000
- * and the unix time of 2020-08-20 15:04:00 is 1597907081000,
- * by calculating the delta time to get expected time in current timezone,
- * then we can get special hour no matter which timezone it runs.
- */
- @Test
- public void testWithEnvironmentEdge() {
- // set a time represent hour 11
- long deltaFor11 = TimeZone.getDefault().getRawOffset() - 28800000;
- final long timeFor11 = 1597895561000L - deltaFor11;
- EnvironmentEdgeManager.injectEdge(new EnvironmentEdge() {
- @Override
- public long currentTime() {
- return timeFor11;
- }
- });
- assertEquals(11, CurrentHourProvider.getCurrentHour());
-
- // set a time represent hour 15
- long deltaFor15 = TimeZone.getDefault().getRawOffset() - 28800000;
- final long timeFor15 = 1597907081000L - deltaFor15;
- EnvironmentEdgeManager.injectEdge(new EnvironmentEdge() {
- @Override
- public long currentTime() {
- return timeFor15;
- }
- });
- assertEquals(15, CurrentHourProvider.getCurrentHour());
- }
-}