Skip to content

Commit ce3c3b8

Browse files
ramackrimneethiraj
authored andcommitted
RANGER-4168: added unit tests for Metrics and TagDBStore the missing classes
Signed-off-by: Madhan Neethiraj <[email protected]>
1 parent e3137b2 commit ce3c3b8

File tree

5 files changed

+1329
-14
lines changed

5 files changed

+1329
-14
lines changed

security-admin/src/main/java/org/apache/ranger/rest/MetricsREST.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public RangerMetrics getStatus() {
7777
jvm.put("jvm",vmDetails);
7878

7979
if (LOG.isDebugEnabled()) {
80-
LOG.debug("<== MetricsREST.getStatus() " + jvm);
80+
LOG.debug("<== MetricsREST.getStatus(): jvm=" + jvm);
8181
}
8282

8383
return new RangerMetrics(jvm);
@@ -88,7 +88,7 @@ public RangerMetrics getStatus() {
8888
@Produces(MediaType.TEXT_PLAIN)
8989
public String getMetricsPrometheus() {
9090
if (LOG.isDebugEnabled()) {
91-
LOG.debug("MetricsREST.getMetricsPrometheus() ===>>");
91+
LOG.debug("==> MetricsREST.getMetricsPrometheus()");
9292
}
9393
String ret = "";
9494
try {
@@ -98,7 +98,7 @@ public String getMetricsPrometheus() {
9898
}
9999

100100
if (LOG.isDebugEnabled()) {
101-
LOG.debug("MetricsREST.getMetricsPrometheus() <<=== {}", ret);
101+
LOG.debug("<== MetricsREST.getMetricsPrometheus(): ret=" + ret);
102102
}
103103
return ret;
104104
}
@@ -108,7 +108,7 @@ public String getMetricsPrometheus() {
108108
@Produces(MediaType.APPLICATION_JSON)
109109
public Map<String, Map<String, Object>> getMetricsJson() {
110110
if (LOG.isDebugEnabled()) {
111-
LOG.debug("MetricsREST.getMetricsJson() ===>>");
111+
LOG.debug("==> MetricsREST.getMetricsJson()");
112112
}
113113

114114
Map<String, Map<String, Object>> ret = null;
@@ -119,7 +119,7 @@ public Map<String, Map<String, Object>> getMetricsJson() {
119119
}
120120

121121
if (LOG.isDebugEnabled()) {
122-
LOG.debug("MetricsREST.getMetricsJson() <<=== {}", ret);
122+
LOG.debug("<== MetricsREST.getMetricsJson(): ret=" + ret);
123123
}
124124
return ret;
125125
}

security-admin/src/main/java/org/apache/ranger/util/RangerMetricsUtil.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class RangerMetricsUtil {
4444
private static final Logger LOG = LoggerFactory.getLogger(RangerMetricsUtil.class);
4545
private static final OperatingSystemMXBean OS;
4646
private static final MemoryMXBean MEM_BEAN;
47-
public static final String NL = System.getProperty("line.separator");
4847

4948
static {
5049
OS = ManagementFactory.getOperatingSystemMXBean();
@@ -53,7 +52,7 @@ public class RangerMetricsUtil {
5352

5453
public Map<String, Object> getValues() {
5554
if (LOG.isDebugEnabled()) {
56-
LOG.debug("==> RangerJVMMetricUtil.getValues()");
55+
LOG.debug("==> RangerMetricsUtil.getValues()");
5756
}
5857

5958
Map<String, Object> values = new LinkedHashMap<>();
@@ -62,7 +61,7 @@ public Map<String, Object> getValues() {
6261
values.put("memory", addMemoryDetails());
6362

6463
if (LOG.isDebugEnabled()) {
65-
LOG.debug("<== RangerJVMMetricUtil.getValues()" + values);
64+
LOG.debug("<== RangerMetricsUtil.getValues()" + values);
6665
}
6766

6867
return values;
@@ -73,7 +72,7 @@ public Map<String, Object> getValues() {
7372
*/
7473
protected Map<String, Object> getPoolDivision() {
7574
if (LOG.isDebugEnabled()) {
76-
LOG.debug("==> RangerJVMMetricUtil.getPoolDivision()");
75+
LOG.debug("==> RangerMetricsUtil.getPoolDivision()");
7776
}
7877

7978
Map<String, Object> poolDivisionValues = new LinkedHashMap<>();
@@ -84,7 +83,7 @@ protected Map<String, Object> getPoolDivision() {
8483
}
8584

8685
if (LOG.isDebugEnabled()) {
87-
LOG.debug("<== RangerJVMMetricUtil.getPoolDivision()" + poolDivisionValues);
86+
LOG.debug("<== RangerMetricsUtil.getPoolDivision()" + poolDivisionValues);
8887
}
8988

9089
return poolDivisionValues;
@@ -95,7 +94,7 @@ protected Map<String, Object> getPoolDivision() {
9594
*/
9695
protected Map<String, Object> addMemoryDetails() {
9796
if (LOG.isDebugEnabled()) {
98-
LOG.debug("==> RangerJVMMetricUtil.addMemoryDetails()");
97+
LOG.debug("==> RangerMetricsUtil.addMemoryDetails()");
9998
}
10099

101100
Map<String, Object> memory = new LinkedHashMap<>();
@@ -112,7 +111,7 @@ protected Map<String, Object> addMemoryDetails() {
112111
memory.put("memory_pool_usages", getPoolDivision());
113112

114113
if (LOG.isDebugEnabled()) {
115-
LOG.debug("<== RangerJVMMetricUtil.addMemoryDetails()" + memory);
114+
LOG.debug("<== RangerMetricsUtil.addMemoryDetails()" + memory);
116115
}
117116

118117
return memory;
@@ -123,12 +122,12 @@ protected Map<String, Object> addMemoryDetails() {
123122
*/
124123
protected String[] addSystemInfo() {
125124
if (LOG.isDebugEnabled()) {
126-
LOG.debug("==> RangerJVMMetricUtil.addSystemInfo()");
125+
LOG.debug("==> RangerMetricsUtil.addSystemInfo()");
127126
}
128127

129128
String[] osInfo = { OS.getName(), OS.getArch(), OS.getVersion() };
130129
if (LOG.isDebugEnabled()) {
131-
LOG.debug("<== RangerJVMMetricUtil.addSystemInfo()" + osInfo);
130+
LOG.debug("<== RangerMetricsUtil.addSystemInfo()" + osInfo);
132131
}
133132

134133
return osInfo;

0 commit comments

Comments
 (0)