This is an automated email from the ASF dual-hosted git repository.

bbeaudreault pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new cc62da2944c HBASE-27205 Fix tests that rely on EnvironmentEdgeManager 
in branch-2.4 (#4625)
cc62da2944c is described below

commit cc62da2944c708e77761e0d09dfdefee2d565911
Author: Bryan Beaudreault <[email protected]>
AuthorDate: Thu Jul 14 16:08:29 2022 -0400

    HBASE-27205 Fix tests that rely on EnvironmentEdgeManager in branch-2.4 
(#4625)
    
    Signed-off-by: Andrew Purtell <[email protected]>
---
 .../main/java/org/apache/hadoop/hbase/ipc/CallRunner.java  |  3 ++-
 .../java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java   |  5 +++--
 .../apache/hadoop/hbase/ipc/NettyServerRpcConnection.java  |  3 ++-
 .../main/java/org/apache/hadoop/hbase/ipc/RpcServer.java   |  3 ++-
 .../main/java/org/apache/hadoop/hbase/ipc/ServerCall.java  |  3 ++-
 .../java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java  | 14 ++++++++------
 .../apache/hadoop/hbase/ipc/SimpleRpcServerResponder.java  |  5 +++--
 .../apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java |  5 +++--
 .../apache/hadoop/hbase/regionserver/RSRpcServices.java    |  1 +
 .../apache/hadoop/hbase/regionserver/ScannerContext.java   |  3 ++-
 10 files changed, 28 insertions(+), 17 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java
index e9a57cb3054..d3b568c8068 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
 import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.trace.TraceUtil;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.htrace.core.TraceScope;
@@ -99,7 +100,7 @@ public class CallRunner {
         }
         return;
       }
-      call.setStartTime(System.currentTimeMillis());
+      call.setStartTime(EnvironmentEdgeManager.currentTime());
       if (call.getStartTime() > call.getDeadline()) {
         RpcServer.LOG.warn("Dropping timed out call: " + call);
         return;
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java
index 7bb9901d58b..002c5a2d488 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java
@@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.security.HBasePolicyProvider;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.NettyEventLoopGroupConfig;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
@@ -191,8 +192,8 @@ public class NettyRpcServer extends RpcServer {
   public Pair<Message, CellScanner> call(BlockingService service, 
MethodDescriptor md,
     Message param, CellScanner cellScanner, long receiveTime, 
MonitoredRPCHandler status)
     throws IOException {
-    return call(service, md, param, cellScanner, receiveTime, status, 
System.currentTimeMillis(),
-      0);
+    return call(service, md, param, cellScanner, receiveTime, status,
+      EnvironmentEdgeManager.currentTime(), 0);
   }
 
   @Override
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
index 6b30bfad7ca..58be1376953 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.CellScanner;
 import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
 import org.apache.hadoop.hbase.nio.ByteBuff;
 import org.apache.hadoop.hbase.nio.SingleByteBuff;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.yetus.audience.InterfaceAudience;
 
 import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService;
@@ -118,7 +119,7 @@ class NettyServerRpcConnection extends ServerRpcConnection {
     final MethodDescriptor md, RequestHeader header, Message param, 
CellScanner cellScanner,
     long size, final InetAddress remoteAddress, int timeout, CallCleanup 
reqCleanup) {
     return new NettyServerCall(id, service, md, header, param, cellScanner, 
this, size,
-      remoteAddress, System.currentTimeMillis(), timeout, 
this.rpcServer.bbAllocator,
+      remoteAddress, EnvironmentEdgeManager.currentTime(), timeout, 
this.rpcServer.bbAllocator,
       this.rpcServer.cellBlockBuilder, reqCleanup);
   }
 
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
index 1c408449177..fa3bc2cc63a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
@@ -52,6 +52,7 @@ import 
org.apache.hadoop.hbase.security.SaslUtil.QualityOfProtection;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.security.UserProvider;
 import org.apache.hadoop.hbase.security.token.AuthenticationTokenSecretManager;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.GsonUtil;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -384,7 +385,7 @@ public abstract class RpcServer implements 
RpcServerInterface, ConfigurationObse
       Message result = call.getService().callBlockingMethod(md, controller, 
param);
       long receiveTime = call.getReceiveTime();
       long startTime = call.getStartTime();
-      long endTime = System.currentTimeMillis();
+      long endTime = EnvironmentEdgeManager.currentTime();
       int processingTime = (int) (endTime - startTime);
       int qTime = (int) (startTime - receiveTime);
       int totalTime = (int) (endTime - receiveTime);
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
index 36b10a633da..a3d417fce06 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.ByteBufferUtils;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.yetus.audience.InterfaceAudience;
 
@@ -416,7 +417,7 @@ public abstract class ServerCall<T extends 
ServerRpcConnection> implements RpcCa
   @Override
   public long disconnectSince() {
     if (!this.connection.isConnectionOpen()) {
-      return System.currentTimeMillis() - receiveTime;
+      return EnvironmentEdgeManager.currentTime() - receiveTime;
     } else {
       return -1L;
     }
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java
index 5091896776b..34b17197afb 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java
@@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
 import org.apache.hadoop.hbase.security.HBasePolicyProvider;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.io.IOUtils;
@@ -313,7 +314,7 @@ public class SimpleRpcServer extends RpcServer {
       if (c == null) {
         return;
       }
-      c.setLastContact(System.currentTimeMillis());
+      c.setLastContact(EnvironmentEdgeManager.currentTime());
       try {
         count = c.readAndProcess();
       } catch (InterruptedException ieo) {
@@ -330,7 +331,7 @@ public class SimpleRpcServer extends RpcServer {
         closeConnection(c);
         c = null;
       } else {
-        c.setLastContact(System.currentTimeMillis());
+        c.setLastContact(EnvironmentEdgeManager.currentTime());
       }
     }
 
@@ -474,8 +475,8 @@ public class SimpleRpcServer extends RpcServer {
   public Pair<Message, CellScanner> call(BlockingService service, 
MethodDescriptor md,
     Message param, CellScanner cellScanner, long receiveTime, 
MonitoredRPCHandler status)
     throws IOException {
-    return call(service, md, param, cellScanner, receiveTime, status, 
System.currentTimeMillis(),
-      0);
+    return call(service, md, param, cellScanner, receiveTime, status,
+      EnvironmentEdgeManager.currentTime(), 0);
   }
 
   @Override
@@ -587,7 +588,8 @@ public class SimpleRpcServer extends RpcServer {
     }
 
     SimpleServerRpcConnection register(SocketChannel channel) {
-      SimpleServerRpcConnection connection = getConnection(channel, 
System.currentTimeMillis());
+      SimpleServerRpcConnection connection =
+        getConnection(channel, EnvironmentEdgeManager.currentTime());
       add(connection);
       if (LOG.isTraceEnabled()) {
         LOG.trace("Connection from " + connection + "; connections=" + size()
@@ -616,7 +618,7 @@ public class SimpleRpcServer extends RpcServer {
     // synch'ed to avoid explicit invocation upon OOM from colliding with
     // timer task firing
     synchronized void closeIdle(boolean scanAll) {
-      long minLastContact = System.currentTimeMillis() - maxIdleTime;
+      long minLastContact = EnvironmentEdgeManager.currentTime() - maxIdleTime;
       // concurrent iterator might miss new connections added
       // during the iteration, but that's ok because they won't
       // be idle yet anyway and will be caught on next scan
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServerResponder.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServerResponder.java
index f2a7d605faf..b9d8d3dffc4 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServerResponder.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServerResponder.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.hadoop.hbase.HBaseIOException;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.yetus.audience.InterfaceAudience;
@@ -162,7 +163,7 @@ class SimpleRpcServerResponder extends Thread {
    * @return the time of the purge.
    */
   private long purge(long lastPurgeTime) {
-    long now = System.currentTimeMillis();
+    long now = EnvironmentEdgeManager.currentTime();
     if (now < lastPurgeTime + this.simpleRpcServer.purgeTimeout) {
       return lastPurgeTime;
     }
@@ -247,7 +248,7 @@ class SimpleRpcServerResponder extends Thread {
       return true;
     } else {
       // set the serve time when the response has to be sent later
-      conn.lastSentTime = System.currentTimeMillis();
+      conn.lastSentTime = EnvironmentEdgeManager.currentTime();
       return false; // Socket can't take more, we will have to come back.
     }
   }
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
index 4b1c57af5d9..51e1bedba57 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.client.VersionInfoUtil;
 import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
 import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
 import org.apache.hadoop.hbase.nio.ByteBuff;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.yetus.audience.InterfaceAudience;
 
 import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService;
@@ -209,7 +210,7 @@ class SimpleServerRpcConnection extends ServerRpcConnection 
{
 
           // Notify the client about the offending request
           SimpleServerCall reqTooBig = new 
SimpleServerCall(header.getCallId(), this.service, null,
-            null, null, null, this, 0, this.addr, System.currentTimeMillis(), 
0,
+            null, null, null, this, 0, this.addr, 
EnvironmentEdgeManager.currentTime(), 0,
             this.rpcServer.bbAllocator, this.rpcServer.cellBlockBuilder, null, 
responder);
           RequestTooBigException reqTooBigEx = new RequestTooBigException(msg);
           this.rpcServer.metrics.exception(reqTooBigEx);
@@ -334,7 +335,7 @@ class SimpleServerRpcConnection extends ServerRpcConnection 
{
     RequestHeader header, Message param, CellScanner cellScanner, long size,
     InetAddress remoteAddress, int timeout, CallCleanup reqCleanup) {
     return new SimpleServerCall(id, service, md, header, param, cellScanner, 
this, size,
-      remoteAddress, System.currentTimeMillis(), timeout, 
this.rpcServer.bbAllocator,
+      remoteAddress, EnvironmentEdgeManager.currentTime(), timeout, 
this.rpcServer.bbAllocator,
       this.rpcServer.cellBlockBuilder, reqCleanup, this.responder);
   }
 
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 4a3c84f5dbb..c965f383d1f 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -3231,6 +3231,7 @@ public class RSRpcServices implements 
HBaseRPCErrorHandler, AdminService.Blockin
         // the time limit to be less than the allowable minimum (could cause an
         // immediate timeout before scanning any data).
         timeLimitDelta = Math.max(timeLimitDelta / 2, 
minimumScanTimeLimitDelta);
+        LOG.info("Final timeLimitDelta of {}", timeLimitDelta);
         return now + timeLimitDelta;
       }
     }
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScannerContext.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScannerContext.java
index 6768e987f6b..96fe603d223 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScannerContext.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScannerContext.java
@@ -21,6 +21,7 @@ import java.util.List;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
 import org.apache.hadoop.hbase.client.metrics.ServerSideScanMetrics;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
 
@@ -346,7 +347,7 @@ public class ScannerContext {
    */
   boolean checkTimeLimit(LimitScope checkerScope) {
     return hasTimeLimit(checkerScope)
-      && (returnImmediately || System.currentTimeMillis() >= limits.getTime());
+      && (returnImmediately || EnvironmentEdgeManager.currentTime() >= 
limits.getTime());
   }
 
   /**

Reply via email to