goiri commented on code in PR #4375:
URL: https://github.com/apache/hadoop/pull/4375#discussion_r921680900


##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/PeriodicService.java:
##########
@@ -167,21 +167,18 @@ protected synchronized void startPeriodic() {
     stopPeriodic();
 
     // Create the runnable service
-    Runnable updateRunnable = new Runnable() {
-      @Override
-      public void run() {
-        LOG.debug("Running {} update task", serviceName);
-        try {
-          if (!isRunning) {
-            return;
-          }
-          periodicInvoke();
-          runCount++;
-          lastRun = Time.now();
-        } catch (Exception ex) {
-          errorCount++;
-          LOG.warn(serviceName + " service threw an exception", ex);
+    Runnable updateRunnable = () -> {
+      LOG.debug("Running {} update task", serviceName);
+      try {
+        if (!isRunning) {
+          return;
         }
+        periodicInvoke();
+        runCount++;
+        lastRun = Time.now();
+      } catch (Exception ex) {
+        errorCount++;
+        LOG.warn(serviceName + " service threw an exception", ex);

Review Comment:
   Use {}



##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterClientRejectOverload.java:
##########
@@ -206,33 +206,30 @@ private void testOverloaded(int expOverloadMin, int 
expOverloadMax,
     for (int i = 0; i < numOps; i++) {
       // Stagger the operations a little (50ms)
       final int sleepTime = i * 50;
-      Future<?> future = exec.submit(new Runnable() {
-        @Override
-        public void run() {
-          DFSClient routerClient = null;
-          try {
-            Thread.sleep(sleepTime);
-            routerClient = new DFSClient(address, conf);
-            String clientName = routerClient.getClientName();
-            ClientProtocol routerProto = routerClient.getNamenode();
-            routerProto.renewLease(clientName, null);
-          } catch (RemoteException re) {
-            IOException ioe = re.unwrapRemoteException();
-            assertTrue("Wrong exception: " + ioe,
-                ioe instanceof StandbyException);
-            assertExceptionContains("is overloaded", ioe);
-            overloadException.incrementAndGet();
-          } catch (IOException e) {
-            fail("Unexpected exception: " + e);
-          } catch (InterruptedException e) {
-            fail("Cannot sleep: " + e);
-          } finally {
-            if (routerClient != null) {
-              try {
-                routerClient.close();
-              } catch (IOException e) {
-                LOG.error("Cannot close the client");
-              }
+      Future<?> future = exec.submit(() -> {
+        DFSClient routerClient = null;
+        try {
+          Thread.sleep(sleepTime);
+          routerClient = new DFSClient(address, conf);
+          String clientName = routerClient.getClientName();
+          ClientProtocol routerProto = routerClient.getNamenode();
+          routerProto.renewLease(clientName, null);
+        } catch (RemoteException re) {
+          IOException ioe = re.unwrapRemoteException();
+          assertTrue("Wrong exception: " + ioe,

Review Comment:
   Single line



##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterFaultTolerant.java:
##########
@@ -168,7 +169,7 @@ public void cleanup() throws Exception {
     }
     namenodes.clear();
 
-    routers.forEach(router ->  router.stop());
+    routers.forEach(AbstractService::stop);

Review Comment:
   Can we do `Router::stop`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to