def get_jvm_option(self, java_bin):
cmd = '%s -version 2>&1 | grep \' version \' | awk -F"[\\"_]" \'{print $2}\'' %java_bin
popen = subprocess.Popen(cmd, shell=True, close_fds=True, stdout=subprocess.PIPE)
excute_data = popen.stdout.readlines()
try:
version = excute_data[0].strip('\n')
major, minor, security = [int(x) for x in version.split('.')]
if major > 1 or minor >= 8:
self.logger.info("using jdk version: {0}, "
"set JVM option with MetaSpace parameter".format(excute_data))
return JSTATUS['new_jvm_option']
else:
self.logger.info("using jdk version: {0}, "
"set JVM option with PermSpace parameter".format(excute_data))
return JSTATUS['old_jvm_option']
except Exception as msg:
self.logger.error("failed to decide the java version from excute_data: {0}, "
"exception msg: {1}".format(excute_data, msg))
self.logger.error(traceback.format_exc())
raise JvmCollectorExcept('receive java version error')
评论列表
文章目录