From 05939af7c771da05664eb12dcac24e5b27dc764f Mon Sep 17 00:00:00 2001 From: Asias He Date: Mon, 1 Jun 2015 11:33:11 +0800 Subject: [PATCH] token_metadata: Move update_host_id to source file --- locator/token_metadata.cc | 23 +++++++++++++++++++++++ locator/token_metadata.hh | 23 +---------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/locator/token_metadata.cc b/locator/token_metadata.cc index 35e9f64d00..3331283a0c 100644 --- a/locator/token_metadata.cc +++ b/locator/token_metadata.cc @@ -138,4 +138,27 @@ void token_metadata::debug_show() { reporter->arm_periodic(std::chrono::seconds(1)); } +void token_metadata::update_host_id(const UUID& host_id, inet_address endpoint) { +#if 0 + assert host_id != null; + assert endpoint != null; + + InetAddress storedEp = _endpoint_to_host_id_map.inverse().get(host_id); + if (storedEp != null) { + if (!storedEp.equals(endpoint) && (FailureDetector.instance.isAlive(storedEp))) { + throw new RuntimeException(String.format("Host ID collision between active endpoint %s and %s (id=%s)", + storedEp, + endpoint, + host_id)); + } + } + + UUID storedId = _endpoint_to_host_id_map.get(endpoint); + // if ((storedId != null) && (!storedId.equals(host_id))) + logger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, host_id); +#endif + _endpoint_to_host_id_map[endpoint] = host_id; +} + + } diff --git a/locator/token_metadata.hh b/locator/token_metadata.hh index 821b0a7c0a..a1df113809 100644 --- a/locator/token_metadata.hh +++ b/locator/token_metadata.hh @@ -251,28 +251,7 @@ public: * @param hostId * @param endpoint */ - void update_host_id(const UUID& host_id, inet_address endpoint) { -#if 0 - assert host_id != null; - assert endpoint != null; - - InetAddress storedEp = _endpoint_to_host_id_map.inverse().get(host_id); - if (storedEp != null) { - if (!storedEp.equals(endpoint) && (FailureDetector.instance.isAlive(storedEp))) { - throw new RuntimeException(String.format("Host ID collision between active endpoint %s and %s (id=%s)", - storedEp, - endpoint, - host_id)); - } - } - - UUID storedId = _endpoint_to_host_id_map.get(endpoint); - // if ((storedId != null) && (!storedId.equals(host_id))) - logger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, host_id); -#endif - _endpoint_to_host_id_map[endpoint] = host_id; - } - + void update_host_id(const UUID& host_id, inet_address endpoint); #if 0 /** Return the unique host ID for an end-point. */ public UUID getHostId(InetAddress endpoint)