From f43d8b55db74bc4512ed0917e95ec1292b514947 Mon Sep 17 00:00:00 2001 From: Andrew Hust Date: Thu, 15 Oct 2015 11:31:50 -0600 Subject: [PATCH] added check to validate jdk >= 1.8 when C* >= 3.0 and fail with useful message on startup --- ccmlib/cluster.py | 4 ++++ ccmlib/cmds/cluster_cmds.py | 4 ++++ ccmlib/common.py | 6 ++++++ ccmlib/repository.py | 5 +++++ 4 files changed, 19 insertions(+) diff --git a/ccmlib/cluster.py b/ccmlib/cluster.py index 5d098d95..f78b24a8 100644 --- a/ccmlib/cluster.py +++ b/ccmlib/cluster.py @@ -264,6 +264,10 @@ def show(self, verbose): node.show(only_status=True) def start(self, no_wait=False, verbose=False, wait_for_binary_proto=False, wait_other_notice=False, jvm_args=[], profile_options=None): + if self.cassandra_version() >= '3.0' and common.get_jdk_version() < '1.8': + print_('Cassandra 3.0+ requires Java >= 1.8, found Java {}'.format(common.get_jdk_version())) + exit(1) + if wait_other_notice: marks = [(node, node.mark_log()) for node in list(self.nodes.values())] diff --git a/ccmlib/cmds/cluster_cmds.py b/ccmlib/cmds/cluster_cmds.py index 1ae983fb..c2bba326 100644 --- a/ccmlib/cmds/cluster_cmds.py +++ b/ccmlib/cmds/cluster_cmds.py @@ -129,6 +129,10 @@ def validate(self, parser, options, args): parser.print_help() parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir) + if common.get_version_from_build(options.install_dir) >= '3.0' and common.get_jdk_version() < '1.8': + print_('Cassandra 3.0+ requires Java >= 1.8, found Java {}'.format(common.get_jdk_version())) + exit(1) + def run(self): try: if self.options.dse or (not self.options.version and common.isDse(self.options.install_dir)): diff --git a/ccmlib/common.py b/ccmlib/common.py index 4390d161..cd07dbf0 100644 --- a/ccmlib/common.py +++ b/ccmlib/common.py @@ -569,3 +569,9 @@ def is_dse_cluster(path): def invalidate_cache(): rmdirs(os.path.join(get_default_path(), 'repository')) + + +def get_jdk_version(): + version = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT) + ver_pattern = '\"(\d+\.\d+).*\"' + return re.search(ver_pattern, version).groups()[0] diff --git a/ccmlib/repository.py b/ccmlib/repository.py index 20171b1b..bf67f8da 100644 --- a/ccmlib/repository.py +++ b/ccmlib/repository.py @@ -15,6 +15,7 @@ from six import print_ +from common import get_jdk_version, get_version_from_build from ccmlib.common import (ArgumentError, CCMError, get_default_path, platform_binary, rmdirs, validate_install_dir) from six.moves import urllib @@ -262,6 +263,10 @@ def download_version(version, url=None, verbose=False, binary=False): def compile_version(version, target_dir, verbose=False): + if get_version_from_build(target_dir) >= '3.0' and get_jdk_version() < '1.8': + print_('ERROR: Cassandra 3.0+ requires Java >= 1.8, found Java {}'.format(get_jdk_version())) + exit(1) + # compiling cassandra and the stress tool logfile = lastlogfilename() if verbose: