joseluisll commented on code in PR #8717:
URL: https://github.com/apache/hadoop/pull/8717#discussion_r4093301870


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderServer.java:
##########
@@ -147,10 +147,16 @@ private void join() {
 
   @Override
   protected void serviceStop() throws Exception {
-    if (readerWebServer != null) {
-      readerWebServer.stop();
+    try {
+      if (readerWebServer != null) {
+        readerWebServer.stop();
+      }
+    } finally {
+      // super.serviceStop() is what stops the reader and, with it, the
+      // storage monitor's polling executor.  A web server that fails to
+      // stop must not leave those behind.
+      super.serviceStop();

Review Comment:
   Added, in 
`TestTimelineReaderServer.testChildServicesStoppedWhenWebAppStopFails`.
   
   It needed a seam, since `readerWebServer` is private and built inside 
`startTimelineReaderWebApp()`. `serviceStop()` now stops it through a 
package-private `@VisibleForTesting stopTimelineReaderWebApp()`, which the test 
overrides in an anonymous subclass to call `super` and then throw. The test 
asserts `stop()` surfaces the `ServiceStateException` and that every child 
service is still `STOPPED`, `FileSystemTimelineReaderImpl` standing in for the 
HBase reader that owns the storage monitor.
   
   Confirmed it is a regression test and not just a passing one: reverting 
`serviceStop()` to the sequential form gives
   
   ```
   AssertionFailedError: 
org.apache.hadoop.yarn.server.timelineservice.storage.FileSystemTimelineReaderImpl
     was left running by the failed stop ==> expected: <STOPPED> but was: 
<STARTED>
   ```
   
   and it passes with the `finally` restored. Full class: 4/4.



-- 
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