Skip to content

Commit

Permalink
Merge pull request #115 from realityforge/payara5191
Browse files Browse the repository at this point in the history
Add support for Payara 5.184 and 5.191
  • Loading branch information
Aketzu authored May 15, 2019
2 parents 335bc58 + 21749f4 commit ce80530
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v.1.1.0:
* Enhance : Add support for Payara 5.184 and 5.191

## v.1.0.2:
* Enhance : Improve systemd restarting on failure
* Enhance : Wait for Glassfish admin to be ready before adding a library
Expand Down
32 changes: 32 additions & 0 deletions libraries/asadmin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,38 @@ def escape_property(string)
string.to_s.gsub(/([#{Regexp.escape('\/,=:.!$%^&*|{}[]"`~;')}])/) { |match| "\\#{match}" }
end

# asadmin (and REST API) returns JDK version restrictions for JVM options in different format than it requires as input
# This function converts between the return-format and input-format (or optionally without any version)
#
# For example:
# From: "-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.6.jar --> JDK versions: min(1.8.0), max(1.8.0.120) (Inactive on this JDK)"
# To: "[1.8.0|1.8.0u120]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.6.jar"
#
def transform_jvm_options(options, withoutversions = false)
options.map do |line|
min = ''
max = ''
unless withoutversions
capture = line.match(/min\(([\d\.]+)\)/)
min = capture.captures.first unless capture.nil?

capture = line.match(/max\(([\d\.]+)\)/)
max = capture.captures.first unless capture.nil?

min = min.gsub(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, '\1.\2.\3u\4')
max = max.gsub(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, '\1.\2.\3u\4')
end

base = line.gsub(/ --> JDK versions: [A-Za-z\(\d\.\), ]+/, '')

if min != '' || max != ''
"[#{min}|#{max}]#{base}"
else
base
end
end
end

def self.pipe_filter(node, pattern, regexp: true, line: false)
case node['os']
when 'linux'
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache-2.0'
description 'Installs/Configures GlassFish Application Server'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.0.2'
version '1.1.0'

chef_version '>= 13.0' if respond_to?(:chef_version)

Expand Down
5 changes: 3 additions & 2 deletions providers/jvm_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ def service_name
existing = output.split("\n") if node.linux?
existing = output.split("\r\n") if node.windows?

existing_option_string = encode_options(existing)
existing_option_string = encode_options(transform_jvm_options(existing))
new_option_string = encode_options(new_resource.options)

if existing_option_string != new_option_string
existing_option_string = encode_options(transform_jvm_options(existing, true))
execute "asadmin_delete-jvm-options #{new_resource.name}" do
delete_command = []
delete_command << 'delete-jvm-options'
delete_command << existing_option_string
delete_command << existing_option_string # This needs to be sent without the JDK version number restrictions
delete_command << asadmin_target_flag

timeout node['glassfish']['asadmin']['timeout'] + 5
Expand Down
17 changes: 16 additions & 1 deletion resources/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,29 @@ def security_jvm_options
]
end

def grizzly_options
if node['glassfish']['variant'] == 'payara' && node['glassfish']['version'].split('.')[0].to_i >= 5 && node['glassfish']['version'].split('.')[1].to_i >= 184
[
'[1.8.0|1.8.0u120]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.6.jar',
'[1.8.0u121|1.8.0u160]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.7.jar',
'[1.8.0u161|1.8.0u190]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.8.jar',
'[1.8.0u191|1.8.0u500]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.8.1.jar',
'[9|]-Xbootclasspath/a:${com.sun.aas.installRoot}/lib/grizzly-npn-api.jar',
]
else
[]
end
end

def development_jvm_options
[
'-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver',
]
end

def default_jvm_options
runtime_jvm_options +
grizzly_options +
runtime_jvm_options +
development_jvm_options +
common_jvm_options +
installation_jvm_options +
Expand Down

0 comments on commit ce80530

Please sign in to comment.