hadoop-metrics 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'net/http'
2
3
  require 'json'
3
4
 
@@ -22,16 +23,27 @@ module HadoopMetrics
22
23
  @metrics_cache
23
24
  end
24
25
 
26
+ GCNameMap = {
27
+ 'PS Scavenge' => 'minor', # for backward compatibility
28
+ 'PS MarkSweep' => 'major', # for backward compatibility
29
+ 'ConcurrentMarkSweep' => 'c_mark_sweep',
30
+ 'ParNew' => 'par_new'
31
+ }
32
+
25
33
  def gc
26
34
  disable_snake_case {
27
35
  result = query_jmx('java.lang:type=GarbageCollector,name=*').map { |jmx_gc_info|
28
36
  return nil if jmx_gc_info['LastGcInfo'].nil?
29
37
 
30
- gc_info = {'type' => (/PS Scavenge/.match(jmx_gc_info['name']) ? 'minor' : 'major')}
38
+ gc_info = {'type' => GCNameMap[jmx_gc_info['Name']]}
31
39
  gc_info['estimated_time'] = jmx_gc_info['CollectionTime']
32
40
  gc_info['count'] = jmx_gc_info['CollectionCount']
33
- gc_info['last_start'] = jmx_gc_info['LastGcInfo']['startTime']
34
- gc_info['last_duration'] = jmx_gc_info['LastGcInfo']['duration']
41
+
42
+ last_gc_info = jmx_gc_info['LastGcInfo']
43
+ gc_info['last_start'] = last_gc_info['startTime']
44
+ gc_info['last_duration'] = last_gc_info['duration']
45
+ gc_info['after_gc'] = calc_memory_usage(last_gc_info)
46
+
35
47
  gc_info
36
48
  }
37
49
  }
@@ -49,6 +61,7 @@ module HadoopMetrics
49
61
  result['used'] = (heap['used'] + non_heap['used']) / MegaByte
50
62
  result['max'] = (heap['max'] + non_heap['max']) / MegaByte
51
63
 
64
+ # Can we use 'max' attribute instead of -Xmx option?
52
65
  arguments = get_jmx('java.lang:type=Runtime::InputArguments').first['InputArguments']
53
66
  result['mx_option'] = arguments.select { |arg| arg =~ /-Xmx(.*)m/ }.last["-Xmx".size..-2].to_i
54
67
 
@@ -83,6 +96,19 @@ module HadoopMetrics
83
96
  opts.has_key?(:force) ? opts[:force] : true
84
97
  end
85
98
 
99
+ def calc_memory_usage(gc_info)
100
+ after_gc = {'committed' => 0, 'used' => 0, 'max' => 0}
101
+ gc_info['memoryUsageAfterGc'].each { |area|
102
+ usage = area['value']
103
+ after_gc['committed'] += usage['committed']
104
+ after_gc['used'] += usage['used']
105
+ after_gc['max'] += usage['max']
106
+ }
107
+ after_gc
108
+
109
+ # TODO: Add memoryUsageBeforeGc if needed
110
+ end
111
+
86
112
  def group_by(category, target, column, force)
87
113
  categories = metrics(force)[category]
88
114
  return nil if categories.nil?
@@ -1,3 +1,3 @@
1
1
  module HadoopMetrics
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hadoop-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
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-05-14 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -60,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  segments:
62
62
  - 0
63
- hash: -1295362877936506892
63
+ hash: 2573932514971304811
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  segments:
71
71
  - 0
72
- hash: -1295362877936506892
72
+ hash: 2573932514971304811
73
73
  requirements: []
74
74
  rubyforge_project:
75
75
  rubygems_version: 1.8.23