mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
13341b66cc
commit
396fc14a6c
3 changed files with 9 additions and 5 deletions
|
@ -11,7 +11,11 @@ import java.util.Map;
|
|||
/**
|
||||
* Based on code created by purbon on 13/12/15.
|
||||
*/
|
||||
public class MemoryMonitor {
|
||||
public final class MemoryMonitor {
|
||||
|
||||
private MemoryMonitor() {
|
||||
//Utility Class
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
All, Heap, NonHeap
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MemoryReport {
|
|||
}
|
||||
|
||||
private static MemoryMonitor.Report generateReport(MemoryMonitor.Type type) {
|
||||
return new MemoryMonitor().detect(type);
|
||||
return MemoryMonitor.detect(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,19 +15,19 @@ public class MemoryMonitorTest {
|
|||
|
||||
@Test
|
||||
public void testEachHeapSpaceRepresented() {
|
||||
Map<String, Map<String, Object>> heap = new MemoryMonitor().detect(MemoryMonitor.Type.All).getHeap();
|
||||
Map<String, Map<String, Object>> heap = MemoryMonitor.detect(MemoryMonitor.Type.All).getHeap();
|
||||
assertThat(heap, notNullValue());
|
||||
assertThat(heap.keySet(), hasItems("PS Survivor Space", "PS Old Gen", "PS Eden Space"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllStatsAreAvailableForHeap(){
|
||||
testAllStatsAreAvailable(new MemoryMonitor().detect(MemoryMonitor.Type.All).getHeap());
|
||||
testAllStatsAreAvailable(MemoryMonitor.detect(MemoryMonitor.Type.All).getHeap());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllStatsAreAvailableForNonHeap(){
|
||||
testAllStatsAreAvailable(new MemoryMonitor().detect(MemoryMonitor.Type.All).getNonHeap());
|
||||
testAllStatsAreAvailable(MemoryMonitor.detect(MemoryMonitor.Type.All).getNonHeap());
|
||||
}
|
||||
|
||||
private void testAllStatsAreAvailable(Map<String, Map<String, Object>> stats){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue