diff --git a/data-prepper-core/src/main/java/org/opensearch/dataprepper/pipeline/server/ShutdownHandler.java b/data-prepper-core/src/main/java/org/opensearch/dataprepper/pipeline/server/ShutdownHandler.java index d83ce1898a..c204310035 100644 --- a/data-prepper-core/src/main/java/org/opensearch/dataprepper/pipeline/server/ShutdownHandler.java +++ b/data-prepper-core/src/main/java/org/opensearch/dataprepper/pipeline/server/ShutdownHandler.java @@ -5,20 +5,20 @@ package org.opensearch.dataprepper.pipeline.server; -import org.opensearch.dataprepper.DataPrepper; -import javax.ws.rs.HttpMethod; -import java.io.IOException; -import java.net.HttpURLConnection; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; +import org.opensearch.dataprepper.DataPrepper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.ws.rs.HttpMethod; +import java.io.IOException; +import java.net.HttpURLConnection; + /** * HttpHandler to handle requests to shut down the data prepper instance */ public class ShutdownHandler implements HttpHandler { - private final DataPrepper dataPrepper; private static final Logger LOG = LoggerFactory.getLogger(ShutdownHandler.class); @@ -27,8 +27,8 @@ public ShutdownHandler(final DataPrepper dataPrepper) { } @Override - public void handle(HttpExchange exchange) throws IOException { - String requestMethod = exchange.getRequestMethod(); + public void handle(final HttpExchange exchange) throws IOException { + final String requestMethod = exchange.getRequestMethod(); if (!requestMethod.equals(HttpMethod.POST)) { exchange.sendResponseHeaders(HttpURLConnection.HTTP_BAD_METHOD, 0); exchange.getResponseBody().close(); @@ -36,9 +36,10 @@ public void handle(HttpExchange exchange) throws IOException { } try { + LOG.info("Received HTTP shutdown request to shutdown Data Prepper. Shutdown pipelines and server."); dataPrepper.shutdownPipelines(); exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0); - } catch (Exception e) { + } catch (final Exception e) { LOG.error("Caught exception shutting down data prepper", e); exchange.sendResponseHeaders(HttpURLConnection.HTTP_INTERNAL_ERROR, 0); } finally {