Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cassandra metrics workaround: translate ipv4 to ipv6 #1853

Merged
merged 5 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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