Skip to content

Commit 838cb6e

Browse files
committed
Merge 93606820-integrate-memory-calculator to master
[Completes #93606820]
2 parents f2286ab + 9393dc1 commit 838cb6e

43 files changed

Lines changed: 545 additions & 2065 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/dictionaries/bhale.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ GEM
1212
diff-lcs (1.2.5)
1313
docile (1.1.5)
1414
json (1.8.2)
15-
parser (2.2.2.1)
15+
parser (2.2.2.2)
1616
ast (>= 1.1, < 3.0)
17-
powerpack (0.1.0)
17+
powerpack (0.1.1)
1818
rainbow (2.0.0)
1919
rake (10.4.2)
2020
redcarpet (3.2.3)
@@ -31,7 +31,7 @@ GEM
3131
diff-lcs (>= 1.2.0, < 2.0)
3232
rspec-support (~> 3.2.0)
3333
rspec-support (3.2.2)
34-
rubocop (0.30.1)
34+
rubocop (0.31.0)
3535
astrolabe (~> 1.3)
3636
parser (>= 2.2.2.1, < 3.0)
3737
powerpack (~> 0.1)

config/open_jdk_jre.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
# Configuration for JRE repositories keyed by vendor
1717
# If Java 7 is required, permgen will be used instead of metaspace. Please see the documentation for more detail.
1818
---
19-
repository_root: "{default.repository.root}/openjdk/{platform}/{architecture}"
20-
version: 1.8.0_+
21-
memory_sizes:
22-
metaspace: 64m..
23-
permgen: 64m..
24-
memory_heuristics:
25-
heap: 75
26-
metaspace: 10
27-
permgen: 10
28-
stack: 5
29-
native: 10
19+
jre:
20+
version: 1.8.0_+
21+
repository_root: "{default.repository.root}/openjdk/{platform}/{architecture}"
22+
memory_calculator:
23+
version: 1.+
24+
repository_root: "{default.repository.root}/memory-calculator/{platform}/{architecture}"
25+
memory_sizes:
26+
metaspace: 64m..
27+
permgen: 64m..
28+
memory_heuristics:
29+
heap: 75
30+
metaspace: 10
31+
permgen: 10
32+
stack: 5
33+
native: 10

config/oracle_jre.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919
# You must specify a the repository root of an Oracle JRE repository. Please see the documentation for more detail.
2020
# e.g. repository_root: "http://example.com/oracle-jre/{platform}/{architecture}"
2121

22-
repository_root: ""
23-
version: 1.8.0_+
24-
memory_sizes:
25-
metaspace: 64m..
26-
# permgen: 64m..
27-
memory_heuristics:
28-
heap: 75
29-
metaspace: 10
30-
# permgen: 10
31-
stack: 5
32-
native: 10
22+
jre:
23+
version: 1.8.0_+
24+
repository_root: ""
25+
memory_calculator:
26+
version: 1.+
27+
repository_root: "{default.repository.root}/memory-calculator/{platform}/{architecture}"
28+
memory_sizes:
29+
metaspace: 64m..
30+
permgen: 64m..
31+
memory_heuristics:
32+
heap: 75
33+
metaspace: 10
34+
permgen: 10
35+
stack: 5
36+
native: 10

java-buildpack.iml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@
271271
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.8, rbenv: 1.9.3-p551) [gem]" level="application" />
272272
<orderEntry type="library" scope="PROVIDED" name="ast (v2.0.0, rbenv: 1.9.3-p551) [gem]" level="application" />
273273
<orderEntry type="library" scope="PROVIDED" name="astrolabe (v1.3.0, rbenv: 1.9.3-p551) [gem]" level="application" />
274-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.9.4, rbenv: 1.9.3-p551) [gem]" level="application" />
274+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.9.5, rbenv: 1.9.3-p551) [gem]" level="application" />
275275
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.4.7, rbenv: 1.9.3-p551) [gem]" level="application" />
276276
<orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, rbenv: 1.9.3-p551) [gem]" level="application" />
277277
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 1.9.3-p551) [gem]" level="application" />
278278
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, rbenv: 1.9.3-p551) [gem]" level="application" />
279279
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.2, rbenv: 1.9.3-p551) [gem]" level="application" />
280-
<orderEntry type="library" scope="PROVIDED" name="parser (v2.2.2.1, rbenv: 1.9.3-p551) [gem]" level="application" />
281-
<orderEntry type="library" scope="PROVIDED" name="powerpack (v0.1.0, rbenv: 1.9.3-p551) [gem]" level="application" />
280+
<orderEntry type="library" scope="PROVIDED" name="parser (v2.2.2.2, rbenv: 1.9.3-p551) [gem]" level="application" />
281+
<orderEntry type="library" scope="PROVIDED" name="powerpack (v0.1.1, rbenv: 1.9.3-p551) [gem]" level="application" />
282282
<orderEntry type="library" scope="PROVIDED" name="rainbow (v2.0.0, rbenv: 1.9.3-p551) [gem]" level="application" />
283283
<orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, rbenv: 1.9.3-p551) [gem]" level="application" />
284284
<orderEntry type="library" scope="PROVIDED" name="redcarpet (v3.2.3, rbenv: 1.9.3-p551) [gem]" level="application" />
@@ -287,7 +287,7 @@
287287
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.2.1, rbenv: 1.9.3-p551) [gem]" level="application" />
288288
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.2.1, rbenv: 1.9.3-p551) [gem]" level="application" />
289289
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.2.2, rbenv: 1.9.3-p551) [gem]" level="application" />
290-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.30.1, rbenv: 1.9.3-p551) [gem]" level="application" />
290+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.31.0, rbenv: 1.9.3-p551) [gem]" level="application" />
291291
<orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v1.3.0, rbenv: 1.9.3-p551) [gem]" level="application" />
292292
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.7.5, rbenv: 1.9.3-p551) [gem]" level="application" />
293293
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v1.1.7, rbenv: 1.9.3-p551) [gem]" level="application" />

lib/java_buildpack/buildpack.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ def release
7272
container = component_detection('container', @containers, true).first
7373
fail 'No container can run this application' unless container
7474

75-
component_detection('JRE', @jres, true).first.release
76-
component_detection('framework', @frameworks, false).each(&:release)
77-
command = container.release
75+
commands = []
76+
commands << component_detection('JRE', @jres, true).first.release
77+
component_detection('framework', @frameworks, false).map(&:release)
78+
commands << container.release
7879

7980
payload = {
8081
'addons' => [],
8182
'config_vars' => {},
82-
'default_process_types' => { 'web' => command }
83+
'default_process_types' => { 'web' => commands.flatten.compact.join(' && ') }
8384
}.to_yaml
8485

8586
@logger.debug { "Release Payload:\n#{payload}" }

lib/java_buildpack/component/base_component.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def compile
6969
# Container components are also expected to create the command required to run the application. These components
7070
# are expected to read the +context+ values and take them into account when creating the command.
7171
#
72-
# @return [void, String] components other than containers are not expected to return any value. Container
73-
# components are expected to return the command required to run the application.
72+
# @return [void, String] components other than containers and JREs are not expected to return any value.
73+
# Container and JRE components are expected to return a command required to run the
74+
# application.
7475
def release
7576
fail "Method 'release' must be defined"
7677
end

lib/java_buildpack/component/immutable_java_home.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,19 @@ def as_env_var
4242
"JAVA_HOME=#{root}"
4343
end
4444

45+
# Whether or not the version of Java is 8 or later
46+
#
47+
# @return [Boolean] +true+ iff the version is 1.8.0 or later
48+
def java_8_or_later?
49+
@delegate.java_8_or_later?
50+
end
51+
4552
# @return [String] the root of the droplet's +JAVA_HOME+ formatted as +$PWD/<value>+
4653
def root
4754
qualify_path @delegate.root
4855
end
4956

50-
# @return [String] the version of Java being used by the droplet
57+
# @return # @return [JavaBuildpack::Util::TokenizedVersion] the tokenized droplet's +VERSION+
5158
def version
5259
@delegate.version
5360
end

lib/java_buildpack/component/java_opts.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def initialize(droplet_root)
3939
# @param [Pathname] path the path to the +javaagent+ JAR
4040
# @return [JavaOpts] +self+ for chaining
4141
def add_javaagent(path)
42-
self << "-javaagent:#{qualify_path path}"
43-
self
42+
add_preformatted_options "-javaagent:#{qualify_path path}"
4443
end
4544

4645
# Adds an +agentpath+ entry to the +JAVA_OPTS+. Prepends +$PWD+ to the path (relative to the droplet root) to
@@ -49,8 +48,7 @@ def add_javaagent(path)
4948
# @param [Pathname] path the path to the +native+ +agent+
5049
# @return [JavaOpts] +self+ for chaining
5150
def add_agentpath(path)
52-
self << "-agentpath:#{qualify_path path}"
53-
self
51+
add_preformatted_options "-agentpath:#{qualify_path path}"
5452
end
5553

5654
# Adds a +bootclasspath/p+ entry to the +JAVA_OPTS+. Prepends +$PWD+ to the path (relative to the droplet root) to
@@ -59,8 +57,7 @@ def add_agentpath(path)
5957
# @param [Pathname] path the path to the +javaagent+ JAR
6058
# @return [JavaOpts] +self+ for chaining
6159
def add_bootclasspath_p(path)
62-
self << "-Xbootclasspath/p:#{qualify_path path}"
63-
self
60+
add_preformatted_options "-Xbootclasspath/p:#{qualify_path path}"
6461
end
6562

6663
# Adds a system property to the +JAVA_OPTS+. Ensures that the key is prepended with +-D+. If the value is a
@@ -71,19 +68,26 @@ def add_bootclasspath_p(path)
7168
# @param [Pathname, String] value the value of the system property
7269
# @return [JavaOpts] +self+ for chaining
7370
def add_system_property(key, value)
74-
self << "-D#{key}=#{qualify_value(value)}"
75-
self
71+
add_preformatted_options "-D#{key}=#{qualify_value(value)}"
7672
end
7773

7874
# Adds an option to the +JAVA_OPTS+. Nothing is prepended to the key. If the value is a +Pathname+, then
7975
# prepends +$PWD+ to the path (relative to the droplet root) to ensure that the path is always accurate.
8076
# Otherwise, uses the value as-is.
8177
#
8278
# @param [String] key the key of the option
83-
# @param [Pathname, String] value the value of the system property
79+
# @param [Pathname, String] value the value of the option
8480
# @return [JavaOpts] +self+ for chaining
8581
def add_option(key, value)
86-
self << "#{key}=#{qualify_value(value)}"
82+
add_preformatted_options "#{key}=#{qualify_value(value)}"
83+
end
84+
85+
# Adds a preformatted option to the +JAVA_OPTS+
86+
#
87+
# @param [String] value the value of options
88+
# @return [JavaOpts] +self+ for chaining
89+
def add_preformatted_options(value)
90+
self << value
8791
self
8892
end
8993

lib/java_buildpack/component/mutable_java_home.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616

1717
require 'java_buildpack/component'
18+
require 'java_buildpack/util/tokenized_version'
1819

1920
module JavaBuildpack
2021
module Component
@@ -30,9 +31,21 @@ class MutableJavaHome
3031
attr_accessor :root
3132

3233
# @!attribute [rw] version
33-
# @return [Array] the major, minor, micro and qualifier of the droplet's +VERSION+
34+
# @return [JavaBuildpack::Util::TokenizedVersion] the tokenized droplet's +VERSION+
3435
attr_accessor :version
3536

37+
# Whether or not the version of Java is 8 or later
38+
# @return [Boolean] +true+ iff the version is 1.8.0 or later
39+
def java_8_or_later?
40+
@version >= VERSION_8
41+
end
42+
43+
private
44+
45+
VERSION_8 = JavaBuildpack::Util::TokenizedVersion.new('1.8.0').freeze
46+
47+
private_constant :VERSION_8
48+
3649
end
3750

3851
end

0 commit comments

Comments
 (0)