You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2020/01/03 00:31:08 UTC

[geode] 01/01: GEODE-7553: Review membership interfaces/classes and add javadocs where needed

This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-7553
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 9815ca1fc94711a1ffb978085ec08423bb67f215
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Thu Jan 2 16:30:20 2020 -0800

    GEODE-7553: Review membership interfaces/classes and add javadocs where needed
---
 .../distributed/internal/DistributionImpl.java     |  2 +-
 .../internal/membership/api/Authenticator.java     | 12 +++--
 .../internal/membership/api/LifecycleListener.java | 44 +++++++++++++----
 .../internal/membership/api/Membership.java        | 13 +++++
 .../internal/membership/api/MembershipConfig.java  |  5 ++
 .../internal/membership/api/QuorumChecker.java     |  5 +-
 .../internal/membership/gms/GMSMembership.java     |  2 +-
 .../membership/gms/LifecycleListenerNoOp.java      |  2 +-
 .../internal/membership/gms/package.html           | 57 ----------------------
 9 files changed, 67 insertions(+), 75 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
index d8947d4..26afc68 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
@@ -906,7 +906,7 @@ public class DistributionImpl implements Distribution {
     }
 
     @Override
-    public void setLocalAddress(final InternalDistributedMember address) {
+    public void joinCompleted(final InternalDistributedMember address) {
       distribution.setDirectChannelLocalAddress(address);
     }
 
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Authenticator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Authenticator.java
index 8c84a71..95d967f 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Authenticator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Authenticator.java
@@ -16,6 +16,12 @@ package org.apache.geode.distributed.internal.membership.api;
 
 import java.util.Properties;
 
+/**
+ * You may provide an Authenticator when building a Membership. Your Authenticator
+ * will be asked for credentials when joining the cluster. If this node is acting
+ * as membership coordinator the Authenticator will be asked to authenticate new members
+ * that are attempting to join the cluster.
+ */
 public interface Authenticator<ID extends MemberIdentifier> {
 
   /**
@@ -29,10 +35,10 @@ public interface Authenticator<ID extends MemberIdentifier> {
   String authenticate(ID member, Properties credentials);
 
   /**
-   * Get credential object for the given GemFire distributed member.
+   * Get the credentials for this member
    *
-   * @param member the target distributed member
+   * @param localIdentifier the address of the member hosting this Authenticator
    * @return the credentials
    */
-  Properties getCredentials(ID member);
+  Properties getCredentials(ID localIdentifier);
 }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/LifecycleListener.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/LifecycleListener.java
index dbb77da..32f5c49 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/LifecycleListener.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/LifecycleListener.java
@@ -15,25 +15,51 @@
 package org.apache.geode.distributed.internal.membership.api;
 
 
+/**
+ * You may supply a LifecycleListener when building a Membership. Your listener
+ * will be invoked at various points in the lifecycle of the Membership.
+ *
+ * @param <ID>
+ */
 public interface LifecycleListener<ID extends MemberIdentifier> {
 
+  /**
+   * Invoked when the Membership is starting. All membership services will have been
+   * initialized and had their "start" methods invoked but we will not yet have joined the cluster.
+   *
+   * @param memberID the initial membership identifier, which will not yet have a view ID
+   */
   void start(
       final ID memberID);
 
-  boolean disconnect(Exception exception);
+  /**
+   * Invoked when the Membership is starting. All membership services will have been
+   * initialized and had their "started" methods invoked but we will not yet have joined
+   * the cluster.
+   */
+  void started();
 
   /**
-   * TODO - (GEODE-7464) it seems like this could really just happen during
-   * {@link #start(ID)}
-   * The member ID passed to this method is exactly the same id as the one passed to start. However,
-   * this method has side affects in DirectChannel which may or may not need to happen at the point
-   * in time this method is called?
+   * Invoked when the Membership has successfully joined the cluster. At this point the
+   * membership address is stable.
    */
-  void setLocalAddress(ID address);
+  void joinCompleted(ID address);
 
-  void destroyMember(ID member, String reason);
+  /**
+   * Invoked when Membership is shutting down
+   *
+   * @param exception if not null, this is the reason for Membership shutdown
+   */
+  boolean disconnect(Exception exception);
 
-  void started();
+  /**
+   * Invoked when a member of the cluster has left and resources associated with that member
+   * should be released.
+   */
+  void destroyMember(ID member, String reason);
 
+  /**
+   * Invoked if Membership has been forced out of the cluster.
+   */
   void forcedDisconnect();
 }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Membership.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Membership.java
index 5b3c462..fa74eab 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Membership.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/Membership.java
@@ -23,6 +23,19 @@ import java.util.function.Supplier;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave;
 
+/**
+ * Membership encapsulates membership services. Use MembershipBuilder to create a
+ * Membership instance. Create and install a MembershipListener implementation using
+ * the builder if you want to receive notification of membership events. Create and install
+ * a LifecycleListener using the builder if you want to receive notification of lifecycle
+ * events (start/disconnect/etc.). Create and install a MessageListener to receive messages
+ * sent by other members over UDP communications.
+ * <p>
+ * Once you've created a Membership instance use the start() method to boot it up and
+ * join the cluster.
+ *
+ * @param <ID>
+ */
 public interface Membership<ID extends MemberIdentifier> {
   /**
    * Fetch the current view of memberships in th distributed system, as an ordered list.
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipConfig.java
index 9d2e2f0..901f6bf 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipConfig.java
@@ -18,6 +18,11 @@ package org.apache.geode.distributed.internal.membership.api;
 import org.apache.geode.annotations.internal.MakeImmutable;
 import org.apache.geode.util.internal.GeodeGlossary;
 
+/**
+ * MembershipConfig is used to set parameters for a new Membership instance created with
+ * a MembershipBuilder. Most of the settings are configured in Geode with DistributedSystem
+ * properties (that is, gemfire.properties).
+ */
 public interface MembershipConfig {
   /** stall time to wait for concurrent join/leave/remove requests to be received */
   long MEMBER_REQUEST_COLLECTION_INTERVAL =
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/QuorumChecker.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/QuorumChecker.java
index f17dbf0..d345aac 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/QuorumChecker.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/api/QuorumChecker.java
@@ -17,9 +17,8 @@ package org.apache.geode.distributed.internal.membership.api;
 
 /**
  * A QuorumChecker is created after a forced-disconnect in order to probe the network to see if
- * there is a quorum of members that can be contacted.
- *
- *
+ * there is a quorum of members that can be contacted. It is currently used in geode-core's
+ * InternalDistributedSystem auto-reconnect code.
  */
 public interface QuorumChecker {
 
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java
index 0076318..689c262 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java
@@ -1977,7 +1977,7 @@ public class GMSMembership<ID extends MemberIdentifier> implements Membership<ID
       GMSMembership.this.address =
           services.getMessenger().getMemberID();
 
-      lifecycleListener.setLocalAddress(address);
+      lifecycleListener.joinCompleted(address);
 
       GMSMembership.this.hasJoined = true;
 
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/LifecycleListenerNoOp.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/LifecycleListenerNoOp.java
index e944000..3864046 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/LifecycleListenerNoOp.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/LifecycleListenerNoOp.java
@@ -29,7 +29,7 @@ public class LifecycleListenerNoOp<ID extends MemberIdentifier> implements Lifec
   }
 
   @Override
-  public void setLocalAddress(final ID address) {
+  public void joinCompleted(final ID address) {
 
   }
 
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/package.html b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/package.html
deleted file mode 100755
index 6686b80..0000000
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/package.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<HTML>
-<BODY>
-
-<p>The membership and communication services have been abstracted
-via a set of classes and a factory.  This document is an introduction
-to the organization of these classes.</p>
-
-<p>At the lowest level is a <em>NetMember</em>.  A <em>NetMember</em> is a
-low-level system-independent notion of a network member.  At this writing,
-there is only one implementation, <em>GMSMember</em>.
-
-<p><em>NetMember</em> is intended to be implemented in the service
-provider interface but not necessarily exported to the rest of the system.
-In the current design, <em>DistributedMember</em> is the type used to
-identify peers in the network.
-
-<p>The starting point for accessing membership services is via
-<em>MemberFactory</em>.  This class allows one to create a
-<em>NetMember</em> using various arguments or a
-<em>MembershipManager</em>, which handles most membership services.</p>
-
-<p><em>MemberFactory</em> uses pluggable instances that implement
-the service provider interface <em>MemberServices</em>.  At this
-writing, there is only one implementation, <em>GMSMemberFactory</em>.</p>
-
-<p>A <em>MembershipManager</em> is the central focus for membership
-activity.  It includes startup and shutdown methods, requests for the
-current view of members, and a method to send messages.</p>
-
-<p>The current membership view in the system is via <em>NetView</em>,
-which also includes a <em>NetViewId</em>, a sequential identifier
-that abstracts the <em>ViewId</em> notion from JavaGroups.</p>
-
-<p>One of the arguments to the constructor for a <em>MembershipManager</em>
-is a <em>DistributedMembershipListener</em>.  This listener interface
-handles membership events, such as new member arrival, member departure,
-and message receipt.</p>
-
-
-</BODY>
-</HTML>