GitBox
2018-12-10 14:04:48 UTC
asfgit closed pull request #1560: DRILL-6877: NPE when starting Drillbit
URL: https://github.com/apache/drill/pull/1560
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/distribution/src/resources/drillbit.sh b/distribution/src/resources/drillbit.sh
index 5ad87b15cdb..404c6f86d48 100755
--- a/distribution/src/resources/drillbit.sh
+++ b/distribution/src/resources/drillbit.sh
@@ -87,7 +87,7 @@ export args
# Set default scheduling priority
DRILL_NICENESS=${DRILL_NICENESS:-0}
-GRACEFUL_FILE=$DRILL_PID_DIR/$GRACEFUL_SIGFILE
+GRACEFUL_FILE=$DRILL_HOME/$GRACEFUL_SIGFILE
waitForProcessEnd()
{
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
index 3e78f0325d0..58eceae5324 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
@@ -18,8 +18,9 @@
package org.apache.drill.exec.server;
import java.io.IOException;
-import java.nio.file.FileSystems;
+import java.nio.file.InvalidPathException;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
@@ -373,18 +374,33 @@ public void run () {
}
}
+ /*
+ * Poll for the graceful file, if the file is found cloase the drillbit. Incase if the DRILL_HOME path is not
+ * set, graceful shutdown will not be supported from the command line.
+ */
private void pollShutdown(Drillbit drillbit) throws IOException, InterruptedException {
- final Path drillPidDirPath = FileSystems.getDefault().getPath(System.getenv("DRILL_PID_DIR"));
- final String gracefulFileName = System.getenv("GRACEFUL_SIGFILE");
+ final String drillHome = System.getenv("DRILL_HOME");
+ final String gracefulFile = System.getenv("GRACEFUL_SIGFILE");
+ final Path drillHomePath;
+ if (drillHome == null || gracefulFile == null) {
+ logger.warn("Cannot access graceful file. Graceful shutdown from command line will not be supported.");
+ return;
+ }
+ try {
+ drillHomePath = Paths.get(drillHome);
+ } catch (InvalidPathException e) {
+ logger.warn("Cannot access graceful file. Graceful shutdown from command line will not be supported.");
+ return;
+ }
boolean triggered_shutdown = false;
WatchKey wk = null;
- try (final WatchService watchService = FileSystems.getDefault().newWatchService()) {
- drillPidDirPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
+ try (final WatchService watchService = drillHomePath.getFileSystem().newWatchService()) {
+ drillHomePath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
while (!triggered_shutdown) {
wk = watchService.take();
for (WatchEvent<?> event : wk.pollEvents()) {
final Path changed = (Path) event.context();
- if (changed != null && changed.endsWith(gracefulFileName)) {
+ if (changed != null && changed.endsWith(gracefulFile)) {
drillbit.interruptPollShutdown = false;
triggered_shutdown = true;
drillbit.close();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
***@infra.apache.org
With regards,
Apache Git Services
URL: https://github.com/apache/drill/pull/1560
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/distribution/src/resources/drillbit.sh b/distribution/src/resources/drillbit.sh
index 5ad87b15cdb..404c6f86d48 100755
--- a/distribution/src/resources/drillbit.sh
+++ b/distribution/src/resources/drillbit.sh
@@ -87,7 +87,7 @@ export args
# Set default scheduling priority
DRILL_NICENESS=${DRILL_NICENESS:-0}
-GRACEFUL_FILE=$DRILL_PID_DIR/$GRACEFUL_SIGFILE
+GRACEFUL_FILE=$DRILL_HOME/$GRACEFUL_SIGFILE
waitForProcessEnd()
{
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
index 3e78f0325d0..58eceae5324 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
@@ -18,8 +18,9 @@
package org.apache.drill.exec.server;
import java.io.IOException;
-import java.nio.file.FileSystems;
+import java.nio.file.InvalidPathException;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
@@ -373,18 +374,33 @@ public void run () {
}
}
+ /*
+ * Poll for the graceful file, if the file is found cloase the drillbit. Incase if the DRILL_HOME path is not
+ * set, graceful shutdown will not be supported from the command line.
+ */
private void pollShutdown(Drillbit drillbit) throws IOException, InterruptedException {
- final Path drillPidDirPath = FileSystems.getDefault().getPath(System.getenv("DRILL_PID_DIR"));
- final String gracefulFileName = System.getenv("GRACEFUL_SIGFILE");
+ final String drillHome = System.getenv("DRILL_HOME");
+ final String gracefulFile = System.getenv("GRACEFUL_SIGFILE");
+ final Path drillHomePath;
+ if (drillHome == null || gracefulFile == null) {
+ logger.warn("Cannot access graceful file. Graceful shutdown from command line will not be supported.");
+ return;
+ }
+ try {
+ drillHomePath = Paths.get(drillHome);
+ } catch (InvalidPathException e) {
+ logger.warn("Cannot access graceful file. Graceful shutdown from command line will not be supported.");
+ return;
+ }
boolean triggered_shutdown = false;
WatchKey wk = null;
- try (final WatchService watchService = FileSystems.getDefault().newWatchService()) {
- drillPidDirPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
+ try (final WatchService watchService = drillHomePath.getFileSystem().newWatchService()) {
+ drillHomePath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
while (!triggered_shutdown) {
wk = watchService.take();
for (WatchEvent<?> event : wk.pollEvents()) {
final Path changed = (Path) event.context();
- if (changed != null && changed.endsWith(gracefulFileName)) {
+ if (changed != null && changed.endsWith(gracefulFile)) {
drillbit.interruptPollShutdown = false;
triggered_shutdown = true;
drillbit.close();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
***@infra.apache.org
With regards,
Apache Git Services