Skip to content

Commit

Permalink
RANGER-4168: added unit tests for Metrics and TagDBStore the missing …
Browse files Browse the repository at this point in the history
…classes

Signed-off-by: Madhan Neethiraj <[email protected]>
  • Loading branch information
ramackri authored and mneethiraj committed May 30, 2023
1 parent e3137b2 commit ce3c3b8
Show file tree
Hide file tree
Showing 5 changed files with 1,329 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public RangerMetrics getStatus() {
jvm.put("jvm",vmDetails);

if (LOG.isDebugEnabled()) {
LOG.debug("<== MetricsREST.getStatus() " + jvm);
LOG.debug("<== MetricsREST.getStatus(): jvm=" + jvm);
}

return new RangerMetrics(jvm);
Expand All @@ -88,7 +88,7 @@ public RangerMetrics getStatus() {
@Produces(MediaType.TEXT_PLAIN)
public String getMetricsPrometheus() {
if (LOG.isDebugEnabled()) {
LOG.debug("MetricsREST.getMetricsPrometheus() ===>>");
LOG.debug("==> MetricsREST.getMetricsPrometheus()");
}
String ret = "";
try {
Expand All @@ -98,7 +98,7 @@ public String getMetricsPrometheus() {
}

if (LOG.isDebugEnabled()) {
LOG.debug("MetricsREST.getMetricsPrometheus() <<=== {}", ret);
LOG.debug("<== MetricsREST.getMetricsPrometheus(): ret=" + ret);
}
return ret;
}
Expand All @@ -108,7 +108,7 @@ public String getMetricsPrometheus() {
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Map<String, Object>> getMetricsJson() {
if (LOG.isDebugEnabled()) {
LOG.debug("MetricsREST.getMetricsJson() ===>>");
LOG.debug("==> MetricsREST.getMetricsJson()");
}

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

if (LOG.isDebugEnabled()) {
LOG.debug("MetricsREST.getMetricsJson() <<=== {}", ret);
LOG.debug("<== MetricsREST.getMetricsJson(): ret=" + ret);
}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class RangerMetricsUtil {
private static final Logger LOG = LoggerFactory.getLogger(RangerMetricsUtil.class);
private static final OperatingSystemMXBean OS;
private static final MemoryMXBean MEM_BEAN;
public static final String NL = System.getProperty("line.separator");

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

public Map<String, Object> getValues() {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerJVMMetricUtil.getValues()");
LOG.debug("==> RangerMetricsUtil.getValues()");
}

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

if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerJVMMetricUtil.getValues()" + values);
LOG.debug("<== RangerMetricsUtil.getValues()" + values);
}

return values;
Expand All @@ -73,7 +72,7 @@ public Map<String, Object> getValues() {
*/
protected Map<String, Object> getPoolDivision() {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerJVMMetricUtil.getPoolDivision()");
LOG.debug("==> RangerMetricsUtil.getPoolDivision()");
}

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

if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerJVMMetricUtil.getPoolDivision()" + poolDivisionValues);
LOG.debug("<== RangerMetricsUtil.getPoolDivision()" + poolDivisionValues);
}

return poolDivisionValues;
Expand All @@ -95,7 +94,7 @@ protected Map<String, Object> getPoolDivision() {
*/
protected Map<String, Object> addMemoryDetails() {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerJVMMetricUtil.addMemoryDetails()");
LOG.debug("==> RangerMetricsUtil.addMemoryDetails()");
}

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

if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerJVMMetricUtil.addMemoryDetails()" + memory);
LOG.debug("<== RangerMetricsUtil.addMemoryDetails()" + memory);
}

return memory;
Expand All @@ -123,12 +122,12 @@ protected Map<String, Object> addMemoryDetails() {
*/
protected String[] addSystemInfo() {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerJVMMetricUtil.addSystemInfo()");
LOG.debug("==> RangerMetricsUtil.addSystemInfo()");
}

String[] osInfo = { OS.getName(), OS.getArch(), OS.getVersion() };
if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerJVMMetricUtil.addSystemInfo()" + osInfo);
LOG.debug("<== RangerMetricsUtil.addSystemInfo()" + osInfo);
}

return osInfo;
Expand Down
Loading

0 comments on commit ce3c3b8

Please sign in to comment.