repeatedly/hadoop-metrics — pull request #2 by wyukawa (2014-08-01 04:02:50+00:00)
Title: fix the problem that gc value is overwritten with nil if LastGcInfo is null.

Hi

If LastGcInfo is null, gc value is overwritten with nil. so hadoop_metrics returns always nil.

example code
```
require 'hadoop_metrics/name_node'

nn = HadoopMetrics::NameNode.new('localhost', 50070)
puts nn.gc # nil
```

If there is the following JMX JSON value, ParNew is overwritten with nil because LastGcInfo of ConcurrentMarkSweep is null

URL:http://.../jmx?qry=java.lang:type=GarbageCollector,name=*

```
{
"beans" : [ {
"name" : "java.lang:type=GarbageCollector,name=ParNew",
"modelerType" : "sun.management.GarbageCollectorImpl",
"LastGcInfo" : {
"GcThreadCount" : 11,
"duration" : 10,
"endTime" : 2728959786,
"id" : 9411,
"memoryUsageAfterGc" : [ {
"key" : "CMS Perm Gen",
"value" : {
"committed" : 44564480,
"init" : 21757952,
"max" : 85983232,
"used" : 44474176
}
}, {
"key" : "Par Eden Space",
"value" : {
"committed" : 167772160,
"init" : 167772160,
"max" : 167772160,
"used" : 0
}
}, {
"key" : "Code Cache",
"value" : {
"committed" : 10813440,
"init" : 2555904,
"max" : 50331648,
"used" : 10616128
}
}, {
"key" : "Par Survivor Space",
"value" : {
"committed" : 20971520,
"init" : 20971520,
"max" : 20971520,
"used" : 5174184
}
}, {
"key" : "CMS Old Gen",
"value" : {
"committed" : 8380219392,
"init" : 8380219392,
"max" : 8380219392,
"used" : 3845674656
}
} ],
"memoryUsageBeforeGc" : [ {
"key" : "CMS Perm Gen",
"value" : {
"committed" : 44564480,
"init" : 21757952,
"max" : 85983232,
"used" : 44474176
}
}, {
"key" : "Par Eden Space",
"value" : {
"committed" : 167772160,
"init" : 167772160,
"max" : 167772160,
"used" : 167772160
}
}, {
"key" : "Code Cache",
"value" : {
"committed" : 10813440,
"init" : 2555904,
"max" : 50331648,
"used" : 10616128
}
}, {
"key" : "Par Survivor Space",
"value" : {
"committed" : 20971520,
"init" : 20971520,
"max" : 20971520,
"used" : 4853536
}
}, {
"key" : "CMS Old Gen",
"value" : {
"committed" : 8380219392,
"init" : 8380219392,
"max" : 8380219392,
"used" : 3845674656
}
} ],
"startTime" : 2728959776
},
"CollectionCount" : 9411,
"CollectionTime" : 118743,
"MemoryPoolNames" : [ "Par Eden Space", "Par Survivor Space" ],
"Name" : "ParNew",
"Valid" : true,
"ObjectName" : "java.lang:type=GarbageCollector,name=ParNew"
}, {
"name" : "java.lang:type=GarbageCollector,name=ConcurrentMarkSweep",
"modelerType" : "sun.management.GarbageCollectorImpl",
"LastGcInfo" : null,
"CollectionCount" : 0,
"CollectionTime" : 0,
"MemoryPoolNames" : [ "Par Eden Space", "Par Survivor Space", "CMS Old Gen", "CMS Perm Gen" ],
"Name" : "ConcurrentMarkSweep",
"Valid" : true,
"ObjectName" : "java.lang:type=GarbageCollector,name=ConcurrentMarkSweep"
} ]
}
```

In this case, ConcurrentMarkSweep is not executed. So, I think that it's rare case.