Skip to content

Commit

Permalink
Merge branch 'checkstyle-task' of https://github.com/seagle-yuan/incu…
Browse files Browse the repository at this point in the history
…bator-hugegraph into checkstyle-task
  • Loading branch information
seagle-yuan committed May 3, 2022
2 parents f98936a + 8dc2f6f commit ae24953
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.io.IOException;
import java.lang.management.MemoryUsage;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -297,7 +299,18 @@ private Map<String, Object> executeAllHosts(Function<String, Object> func) {
Map<String, Object> hostsResults = InsertionOrderUtil.newMap();
for (Host host : hosts) {
InetAddress address = host.getAddress();
String hostAddress = address.getHostAddress();
String hostAddress;
if (address instanceof Inet4Address) {
hostAddress = host.getAddress().getHostAddress();
/*
* Translate IPv4 to IPv6 to fix issue #1843
* TODO: delete this workaround code after fixed CASSANDRA-17581
*/
hostAddress = "::FFFF:" + hostAddress;
} else {
assert address instanceof Inet6Address;
hostAddress = host.getAddress().getHostAddress();
}
hostsResults.put(hostAddress, func.apply(hostAddress));
}
results.put(SERVERS, hostsResults);
Expand Down
222 changes: 111 additions & 111 deletions hugegraph-test/src/main/java/com/baidu/hugegraph/api/MetricsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,124 +100,124 @@ public void testMetricsBackend() {
servers = (Map<?, ?>) graph.get("servers");
Assert.assertGte(1, servers.size());
// TODO: Uncomment after fixed #1843
// for (Map.Entry<?, ?> e : servers.entrySet()) {
// String key = (String) e.getKey();
// value = e.getValue();
// Assert.assertTrue(String.format(
// "Expect map value for key %s but got %s",
// key, value),
// value instanceof Map);
// host = (Map<?, ?>) value;
// assertMapContains(host, "mem_max");
// assertMapContains(host, "mem_committed");
// assertMapContains(host, "mem_used");
// assertMapContains(host, "mem_used_readable");
// assertMapContains(host, "mem_unit");
//
// assertMapContains(host, "disk_usage");
// assertMapContains(host, "disk_usage_readable");
// assertMapContains(host, "disk_usage_details");
// assertMapContains(host, "disk_unit");
//
// assertMapContains(host, "uptime");
// assertMapContains(host, "uptime_readable");
// assertMapContains(host, "time_unit");
//
// assertMapContains(host, "estimated_partition_count");
// assertMapContains(host, "dropped_mutations");
// assertMapContains(host, "pending_flushes");
// assertMapContains(host, "key_cache_hit_rate");
// assertMapContains(host, "bloom_filter_false_ratio");
//
// assertMapContains(host, "write_latency_hugegraph");
// assertMapContains(host, "read_latency_hugegraph");
// assertMapContains(host, "write_latency_*");
// assertMapContains(host, "read_latency_*");
//
// assertMapContains(host, "key_cache_size");
// assertMapContains(host, "key_cache_entries");
// assertMapContains(host, "row_cache_size");
// assertMapContains(host, "row_cache_entries");
// assertMapContains(host, "counter_cache_size");
// assertMapContains(host, "counter_cache_entries");
//
// assertMapContains(host, "compaction_completed_tasks");
// assertMapContains(host, "compaction_pending_tasks");
// assertMapContains(host, "compaction_bytes_compacted");
//
// assertMapContains(host, "live_nodes");
// assertMapContains(host, "joining_nodes");
// assertMapContains(host, "moving_nodes");
// assertMapContains(host, "leaving_nodes");
// assertMapContains(host, "unreachable_nodes");
//
// assertMapContains(host, "keyspaces");
// assertMapContains(host, "num_tables");
// assertMapContains(host, "exception_count");
// }
for (Map.Entry<?, ?> e : servers.entrySet()) {
String key = (String) e.getKey();
value = e.getValue();
Assert.assertTrue(String.format(
"Expect map value for key %s but got %s",
key, value),
value instanceof Map);
host = (Map<?, ?>) value;
assertMapContains(host, "mem_max");
assertMapContains(host, "mem_committed");
assertMapContains(host, "mem_used");
assertMapContains(host, "mem_used_readable");
assertMapContains(host, "mem_unit");

assertMapContains(host, "disk_usage");
assertMapContains(host, "disk_usage_readable");
assertMapContains(host, "disk_usage_details");
assertMapContains(host, "disk_unit");

assertMapContains(host, "uptime");
assertMapContains(host, "uptime_readable");
assertMapContains(host, "time_unit");

assertMapContains(host, "estimated_partition_count");
assertMapContains(host, "dropped_mutations");
assertMapContains(host, "pending_flushes");
assertMapContains(host, "key_cache_hit_rate");
assertMapContains(host, "bloom_filter_false_ratio");

assertMapContains(host, "write_latency_hugegraph");
assertMapContains(host, "read_latency_hugegraph");
assertMapContains(host, "write_latency_*");
assertMapContains(host, "read_latency_*");

assertMapContains(host, "key_cache_size");
assertMapContains(host, "key_cache_entries");
assertMapContains(host, "row_cache_size");
assertMapContains(host, "row_cache_entries");
assertMapContains(host, "counter_cache_size");
assertMapContains(host, "counter_cache_entries");

assertMapContains(host, "compaction_completed_tasks");
assertMapContains(host, "compaction_pending_tasks");
assertMapContains(host, "compaction_bytes_compacted");

assertMapContains(host, "live_nodes");
assertMapContains(host, "joining_nodes");
assertMapContains(host, "moving_nodes");
assertMapContains(host, "leaving_nodes");
assertMapContains(host, "unreachable_nodes");

assertMapContains(host, "keyspaces");
assertMapContains(host, "num_tables");
assertMapContains(host, "exception_count");
}
break;
case "scylladb":
assertMapContains(graph, "cluster_id");
assertMapContains(graph, "servers");

servers = (Map<?, ?>) graph.get("servers");
Assert.assertGte(1, servers.size());
// TODO: Uncomment after fixed #1843
// for (Map.Entry<?, ?> e : servers.entrySet()) {
// String key = (String) e.getKey();
// value = e.getValue();
// Assert.assertTrue(String.format(
// "Expect map value for key %s but got %s",
// key, value),
// value instanceof Map);
// host = (Map<?, ?>) value;
// assertMapContains(host, "mem_max");
// assertMapContains(host, "mem_committed");
// assertMapContains(host, "mem_used");
// assertMapContains(host, "mem_used_readable");
// assertMapContains(host, "mem_unit");
//
// assertMapContains(host, "disk_usage");
// assertMapContains(host, "disk_usage_readable");
// assertMapContains(host, "disk_usage_details");
// assertMapContains(host, "disk_unit");
//
// assertMapContains(host, "uptime");
// assertMapContains(host, "uptime_readable");
// assertMapContains(host, "time_unit");
//
// assertMapContains(host, "estimated_partition_count");
// assertMapContains(host, "dropped_mutations");
// assertMapContains(host, "pending_flushes");
// //assertMapContains(host, "key_cache_hit_rate");
// assertMapContains(host, "bloom_filter_false_ratio");
//
// //assertMapContains(host, "write_latency_hugegraph");
// //assertMapContains(host, "read_latency_hugegraph");
// //assertMapContains(host, "write_latency_*");
// //assertMapContains(host, "read_latency_*");
//
// assertMapContains(host, "key_cache_size");
// assertMapContains(host, "key_cache_entries");
// assertMapContains(host, "row_cache_size");
// assertMapContains(host, "row_cache_entries");
// assertMapContains(host, "counter_cache_size");
// assertMapContains(host, "counter_cache_entries");
//
// assertMapContains(host, "compaction_completed_tasks");
// assertMapContains(host, "compaction_pending_tasks");
// //assertMapContains(host, "compaction_bytes_compacted");
//
// assertMapContains(host, "live_nodes");
// assertMapContains(host, "joining_nodes");
// assertMapContains(host, "moving_nodes");
// assertMapContains(host, "leaving_nodes");
// assertMapContains(host, "unreachable_nodes");
//
// assertMapContains(host, "keyspaces");
// assertMapContains(host, "num_tables");
// assertMapContains(host, "exception_count");
// }

for (Map.Entry<?, ?> e : servers.entrySet()) {
String key = (String) e.getKey();
value = e.getValue();
Assert.assertTrue(String.format(
"Expect map value for key %s but got %s",
key, value),
value instanceof Map);
host = (Map<?, ?>) value;
assertMapContains(host, "mem_max");
assertMapContains(host, "mem_committed");
assertMapContains(host, "mem_used");
assertMapContains(host, "mem_used_readable");
assertMapContains(host, "mem_unit");

assertMapContains(host, "disk_usage");
assertMapContains(host, "disk_usage_readable");
assertMapContains(host, "disk_usage_details");
assertMapContains(host, "disk_unit");

assertMapContains(host, "uptime");
assertMapContains(host, "uptime_readable");
assertMapContains(host, "time_unit");

assertMapContains(host, "estimated_partition_count");
assertMapContains(host, "dropped_mutations");
assertMapContains(host, "pending_flushes");
//assertMapContains(host, "key_cache_hit_rate");
assertMapContains(host, "bloom_filter_false_ratio");

//assertMapContains(host, "write_latency_hugegraph");
//assertMapContains(host, "read_latency_hugegraph");
//assertMapContains(host, "write_latency_*");
//assertMapContains(host, "read_latency_*");

assertMapContains(host, "key_cache_size");
assertMapContains(host, "key_cache_entries");
assertMapContains(host, "row_cache_size");
assertMapContains(host, "row_cache_entries");
assertMapContains(host, "counter_cache_size");
assertMapContains(host, "counter_cache_entries");

assertMapContains(host, "compaction_completed_tasks");
assertMapContains(host, "compaction_pending_tasks");
//assertMapContains(host, "compaction_bytes_compacted");

assertMapContains(host, "live_nodes");
assertMapContains(host, "joining_nodes");
assertMapContains(host, "moving_nodes");
assertMapContains(host, "leaving_nodes");
assertMapContains(host, "unreachable_nodes");

assertMapContains(host, "keyspaces");
assertMapContains(host, "num_tables");
assertMapContains(host, "exception_count");
}
break;
case "hbase":
assertMapContains(graph, "cluster_id");
Expand Down

0 comments on commit ae24953

Please sign in to comment.