tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keiichi Fujino <kfuj...@apache.org>
Subject Re: svn commit: r1843886 - in /tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud: CloudMembershipService.java KubernetesMembershipProvider.java
Date Tue, 16 Oct 2018 05:37:13 GMT
2018年10月15日(月) 17:39 <remm@apache.org>:

> Author: remm
> Date: Mon Oct 15 08:39:26 2018
> New Revision: 1843886
>
> URL: http://svn.apache.org/viewvc?rev=1843886&view=rev
> Log:
> Try to get the member uid from the cloud, it seems more appropriate
> overall.
>
> Modified:
>
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipService.java
>
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
>
> Modified:
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipService.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipService.java?rev=1843886&r1=1843885&r2=1843886&view=diff
>
> ==============================================================================
> ---
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipService.java
> (original)
> +++
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipService.java
> Mon Oct 15 08:39:26 2018
> @@ -18,9 +18,6 @@
>  package org.apache.catalina.tribes.membership.cloud;
>
>  import java.io.IOException;
> -import java.net.InetAddress;
> -import java.security.MessageDigest;
> -import java.security.NoSuchAlgorithmException;
>
>  import javax.management.ObjectName;
>
> @@ -42,6 +39,7 @@ public class CloudMembershipService exte
>      public static final String MEMBERSHIP_PROVIDER_CLASS_NAME =
> "membershipProviderClassName";
>      private static final String KUBE = "kubernetes";
>      private static final String KUBE_PROVIDER_CLASS =
> "org.apache.catalina.tribes.membership.cloud.KubernetesMembershipProvider";
> +    static final byte[] INITIAL_ID = new byte[16];
>
>      private MembershipProvider membershipProvider;
>      private MemberImpl localMember;
> @@ -173,13 +171,7 @@ public class CloudMembershipService exte
>
>          if (localMember == null) {
>              localMember = new MemberImpl();
> -            try {
> -                // Set localMember unique ID to md5 hash of hostname
> -                localMember.setUniqueId(MessageDigest.getInstance("md5")
> -
> .digest(InetAddress.getLocalHost().getHostName().getBytes()));
> -            } catch (NoSuchAlgorithmException e) {
> -                throw new IOException(e);
> -            }
> +            localMember.setUniqueId(INITIAL_ID);
>              localMember.setLocal(true);
>          }
>          localMember.setHostname(host);
>
> Modified:
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java?rev=1843886&r1=1843885&r2=1843886&view=diff
>
> ==============================================================================
> ---
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
> (original)
> +++
> tomcat/trunk/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
> Mon Oct 15 08:39:26 2018
> @@ -203,10 +203,15 @@ public class KubernetesMembershipProvide
>
>                  // We found ourselves, ignore
>                  if (name.equals(hostName)) {
> +                    // Update the UID on initial lookup
> +                    Member localMember = service.getLocalMember(false);
> +                    if (localMember.getUniqueId() ==
> CloudMembershipService.INITIAL_ID && localMember instanceof MemberImpl) {
> +                        byte[] id =
> md5.digest(uid.getBytes(StandardCharsets.US_ASCII));
> +                        ((MemberImpl) localMember).setUniqueId(id);
> +                    }
>                      continue;
>                  }
>
> -                byte[] id =
> md5.digest(uid.getBytes(StandardCharsets.US_ASCII));
>                  long aliveTime =
> Duration.between(Instant.parse(creationTimestamp), startTime).getSeconds()
> * 1000; // aliveTime is in ms
>
>                  MemberImpl member = null;
> @@ -218,6 +223,7 @@ public class KubernetesMembershipProvide
>
>  log.error(sm.getString("kubernetesMembershipProvider.memberError"), e);
>                      continue;
>                  }
> +                byte[] id =
> md5.digest(uid.getBytes(StandardCharsets.US_ASCII));
>                  member.setUniqueId(id);
>                  members.add(member);
>              }
>
>
>
>
Thanks for the fix.

Is this uniqueId 16 bytes?
The uniqueId should be 16 bytes in channel Specs.



> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
> --
> Keiichi.Fujino
> <dev-help@tomcat.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message