You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by jo...@apache.org on 2019/11/27 19:47:26 UTC

[incubator-druid] branch 0.16.1-incubating updated: Startup scripts: verify Java 8 (exactly), improve port/java verification messages. (#8794) (#8951)

This is an automated email from the ASF dual-hosted git repository.

jonwei pushed a commit to branch 0.16.1-incubating
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git


The following commit(s) were added to refs/heads/0.16.1-incubating by this push:
     new cd28850  Startup scripts: verify Java 8 (exactly), improve port/java verification messages. (#8794) (#8951)
cd28850 is described below

commit cd288503aaba593e958449bbe7288578d2f49631
Author: Jonathan Wei <jo...@users.noreply.github.com>
AuthorDate: Wed Nov 27 11:47:11 2019 -0800

    Startup scripts: verify Java 8 (exactly), improve port/java verification messages. (#8794) (#8951)
    
    * Startup scripts: verify Java 8 (exactly), improve port/java verification messages.
    
    Java 11 compatibility isn't fully baked yet (users have reported various
    issues on Java 11), so block startup with an error message unless Java 8
    is found. Allow overriding this decision with an environment variable.
    
    * Message adjustments.
---
 examples/bin/verify-default-ports | 26 +++++++++++++++++++++++---
 examples/bin/verify-java          | 32 +++++++++++++++++++++++++++-----
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/examples/bin/verify-default-ports b/examples/bin/verify-default-ports
index b8167fc..2558292 100755
--- a/examples/bin/verify-default-ports
+++ b/examples/bin/verify-default-ports
@@ -21,12 +21,32 @@ use strict;
 use warnings;
 use Socket;
 
-my @ports = (1527, 2181, 8081, 8082, 8083, 8090, 8091, 8200, 9095);
+my $skip_var = $ENV{'DRUID_SKIP_PORT_CHECK'};
+if ($skip_var && $skip_var ne "0" && $skip_var ne "false" && $skip_var ne "f") {
+  exit 0;
+}
+
+my @ports = (1527, 2181, 8081, 8082, 8083, 8090, 8091, 8200, 8888);
 
 my $tcp = getprotobyname("tcp");
 for my $port (@ports) {
   socket(my $sock, PF_INET, SOCK_STREAM, $tcp) or die "socket: $!";
   setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die "setsockopt: $!";
-  bind($sock, sockaddr_in($port, INADDR_ANY)) or die "Cannot start up because port[$port] is already in use.\n";
-  close $sock;
+  if (!bind($sock, sockaddr_in($port, INADDR_ANY))) {
+    print STDERR <<"EOT";
+Cannot start up because port $port is already in use.
+
+If you need to change your ports away from the defaults, check out the
+configuration documentation:
+
+  https://druid.apache.org/docs/latest/configuration/index.html
+
+If you believe this check is in error, or if you have changed your ports away
+from the defaults, you can skip the check using an environment variable:
+
+  export DRUID_SKIP_PORT_CHECK=1
+
+EOT
+    exit 1;
+  }
 }
diff --git a/examples/bin/verify-java b/examples/bin/verify-java
index 7b5eb63..5e41cb2 100755
--- a/examples/bin/verify-java
+++ b/examples/bin/verify-java
@@ -20,14 +20,36 @@
 use strict;
 use warnings;
 
+sub fail_check {
+  my ($current_version) = @_;
+  my $current_version_text = $current_version
+    ? "Your current version is: $current_version."
+    : "Make sure that "java" is installed and on your PATH.";
+
+  print STDERR <<"EOT";
+Druid requires Java 8. $current_version_text
+
+If you believe this check is in error, you can skip it using an
+environment variable:
+
+  export DRUID_SKIP_JAVA_CHECK=1
+
+Otherwise, install Java 8 and try again.
+EOT
+  exit 1;
+}
+
+my $skip_var = $ENV{'DRUID_SKIP_JAVA_CHECK'};
+if ($skip_var && $skip_var ne "0" && $skip_var ne "false" && $skip_var ne "f") {
+  exit 0;
+}
+
 my $java_version = qx[java -version 2>&1];
 if ($?) {
-  die "Please install Java 8 or better!\n";
+  fail_check();
 }
 
 # If we know it won't work, die. Otherwise hope for the best.
-if ($java_version =~ /java version \"((\d+)\.(\d+).*?)\"/ && ($2 < 1 || $3 < 8)) {
-  die "Please upgrade to Java 8 or better! Your current version is: $1\n";
+if ($java_version =~ /version \"((\d+)\.(\d+).*?)\"/ && ($2 != 1 || $3 != 8)) {
+  fail_check($1);
 }
-
-exit 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org