[NO ISSUE] Minor active refactoring
- Remove unused ActiveRuntimeManager
- Rename StatsRequestMessage -> ActiveStatsRequestMessage
- Add ActiveManager API to return all active runtimes
- Interrupt running HTTP requests after 5s upon shutdown
- Log thread dump when HTTP requests do not complete after interruption
Change-Id: I79249f7cd42496d6679eb9b0acbe8cda1892f9d3
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2021
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-http/pom.xml b/hyracks-fullstack/hyracks/hyracks-http/pom.xml
index ed0e8c8..09bf513 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/pom.xml
+++ b/hyracks-fullstack/hyracks/hyracks-http/pom.xml
@@ -66,5 +66,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.hyracks</groupId>
+ <artifactId>hyracks-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java
index 44d4dfe..645bc01 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java
@@ -31,6 +31,7 @@
import java.util.logging.Logger;
import org.apache.hyracks.http.api.IServlet;
+import org.apache.hyracks.util.ThreadDumpUtil;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.PooledByteBufAllocator;
@@ -218,11 +219,22 @@
}
protected void doStop() throws InterruptedException {
+ // stop taking new requests
executor.shutdown();
try {
- executor.awaitTermination(1, TimeUnit.MINUTES);
+ // wait 5s before interrupting existing requests
+ executor.awaitTermination(5, TimeUnit.SECONDS);
+ // interrupt
+ executor.shutdownNow();
+ // wait 30s for interrupted requests to unwind
+ executor.awaitTermination(30, TimeUnit.SECONDS);
if (!executor.isTerminated()) {
- LOGGER.log(Level.SEVERE, "Failed to shutdown http server executor");
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.log(Level.SEVERE, "Failed to shutdown http server executor; thread dump: " +
+ ThreadDumpUtil.takeDumpString());
+ } else {
+ LOGGER.log(Level.SEVERE, "Failed to shutdown http server executor");
+ }
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error while shutting down http server executor", e);