You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by gu...@apache.org on 2022/04/29 06:53:33 UTC
[incubator-hugegraph] branch master updated: cassandra metrics workaround: translate ipv4 to ipv6 (#1853)
This is an automated email from the ASF dual-hosted git repository.
guoshoujing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
The following commit(s) were added to refs/heads/master by this push:
new 044a15e56 cassandra metrics workaround: translate ipv4 to ipv6 (#1853)
044a15e56 is described below
commit 044a15e569fe674bad0f8190aa31e2c4905c8887
Author: Jermy Li <je...@apache.org>
AuthorDate: Fri Apr 29 14:53:28 2022 +0800
cassandra metrics workaround: translate ipv4 to ipv6 (#1853)
* log cassandra probe host
* Translate IPv4 to IPv6 to fix issue #1843
* enable cassandra/scylladb metrics test case
* resume debug log
---
.../backend/store/cassandra/CassandraMetrics.java | 15 +-
.../com/baidu/hugegraph/api/MetricsApiTest.java | 222 ++++++++++-----------
2 files changed, 125 insertions(+), 112 deletions(-)
diff --git a/hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraMetrics.java b/hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraMetrics.java
index 15adc8ecd..bc17e207d 100644
--- a/hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraMetrics.java
+++ b/hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraMetrics.java
@@ -21,6 +21,8 @@ package com.baidu.hugegraph.backend.store.cassandra;
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;
@@ -297,7 +299,18 @@ public class CassandraMetrics implements BackendMetrics {
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);
diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/MetricsApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/MetricsApiTest.java
index 6b9a4cad1..aee8d3cce 100644
--- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/MetricsApiTest.java
+++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/MetricsApiTest.java
@@ -100,61 +100,61 @@ public class MetricsApiTest extends BaseApiTest {
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");
@@ -162,62 +162,62 @@ public class MetricsApiTest extends BaseApiTest {
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");