jvmargs 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/jvmargs/args.rb CHANGED
@@ -83,7 +83,7 @@ module JVMArgs
83
83
  if boolean
84
84
  [
85
85
  "-Djava.rmi.server.hostname=127.0.0.1",
86
- "-Dcom.sun.management.jmxremote",
86
+ "-Djava.net.preferIPv4Stack=true",
87
87
  "-Dcom.sun.management.jmxremote",
88
88
  "-Dcom.sun.management.jmxremote.port=9000",
89
89
  "-Dcom.sun.management.jmxremote.authenticate=false",
@@ -95,18 +95,36 @@ module JVMArgs
95
95
  end
96
96
  end
97
97
 
98
- def heap_size(percentage)
99
- percentage =~ /([0-9]+)%/
100
- percent = $1.to_i * 0.01
101
- if percent > 1
102
- raise ArgumentError, "heap_size percentage must be less than 100%, you provided #{$1}%"
103
- elsif percent < 0.01
104
- raise ArgumentError, "heap_size percentage must be between 100% - 1%, you provided #{$1}%"
98
+ def heap_size(size)
99
+ if (size =~ /([0-9]+)%/)
100
+ percent = $1.to_i * 0.01
101
+ if percent > 1
102
+ raise ArgumentError, "heap_size percentage must be less than 100%, you provided #{$1}%"
103
+ elsif percent < 0.01
104
+ raise ArgumentError, "heap_size percentage must be between 100% - 1%, you provided #{$1}%"
105
+ end
106
+ system_ram = JVMArgs::Util.get_system_ram_m.sub(/M/,'').to_i
107
+ size_ram = "#{(system_ram * percent).to_i}M"
108
+ else
109
+ begin
110
+ size_ram = JVMArgs::Util.convert_to_m(size)
111
+ rescue ArgumentError
112
+ raise ArgumentError, "heap_size percentage must be a percentage or a fixed size in KiloBytes(K), MegaBytes (M), or Gigabytes(G)"
113
+ end
105
114
  end
106
- percent_int = JVMArgs::Util.get_system_ram_m.sub(/M/,'').to_i
107
- percentage_ram = (percent_int * percent).to_i
108
- @args[:nonstandard]["Xmx"] = JVMArgs::NonStandard.new("-Xmx#{percentage_ram}M")
109
- @args[:nonstandard]["Xms"] = JVMArgs::NonStandard.new("-Xms#{percentage_ram}M")
115
+ @args[:nonstandard]["Xmx"] = JVMArgs::NonStandard.new("-Xmx#{size_ram}")
116
+ @args[:nonstandard]["Xms"] = JVMArgs::NonStandard.new("-Xms#{size_ram}")
117
+ end
118
+
119
+ def permgen(size)
120
+ size_ram = JVMArgs::Util.convert_to_m(size)
121
+ @args[:unstable]["MaxPermSize"] = JVMArgs::Unstable.new("-XX:MaxPermSize=#{size_ram}")
122
+ end
123
+
124
+ def newgen(size)
125
+ size_ram = JVMArgs::Util.convert_to_m(size)
126
+ # @args[:unstable]["NewSize"] = JVMArgs::Unstable.new("-XX:NewSize=#{size_ram}")
127
+ @args[:unstable]["MaxNewSize"] = JVMArgs::Unstable.new("-XX:MaxNewSize=#{size_ram}")
110
128
  end
111
129
 
112
130
  def add_rule(rule_name, &block)
data/lib/jvmargs/rules.rb CHANGED
@@ -13,7 +13,7 @@ module JVMArgs
13
13
 
14
14
  def add(rule_name, block)
15
15
  new_rule_name = "rule_#{rule_name.to_s}".to_sym
16
- JVMArgs::Rules.define_method(new_rule_name) {|args| block.call(args) }
16
+ self.class.send(:define_method, new_rule_name) {|args| block.call(args) }
17
17
  end
18
18
 
19
19
  def rules
@@ -1,4 +1,4 @@
1
1
  module JVMArgs
2
2
  # The gem version
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jvmargs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
12
+ date: 2013-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -115,6 +115,6 @@ rubyforge_project:
115
115
  rubygems_version: 1.8.24
116
116
  signing_key:
117
117
  specification_version: 3
118
- summary: jvmargs-0.0.2
118
+ summary: jvmargs-0.0.3
119
119
  test_files: []
120
120
  has_rdoc: