Skip to content

Commit

Permalink
added check to validate jdk >= 1.8 when C* >= 3.0 and fail with usefu…
Browse files Browse the repository at this point in the history
…l message on startup
  • Loading branch information
nutbunnies committed Oct 15, 2015
1 parent 8056987 commit f43d8b5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())]

Expand Down
4 changes: 4 additions & 0 deletions ccmlib/cmds/cluster_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
6 changes: 6 additions & 0 deletions ccmlib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 5 additions & 0 deletions ccmlib/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f43d8b5

Please sign in to comment.