kotman12 commented on code in PR #4577:
URL: https://github.com/apache/solr/pull/4577#discussion_r3559245887


##########
solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SolrCuratorEvent.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package org.apache.solr.common.cloud;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.state.ConnectionState;
+import org.apache.curator.framework.state.ConnectionStateListener;
+
+public enum SolrCuratorEvent {
+  // Only triggered after resume from expiration
+  EXPIRED_RECONNECTION {
+    @Override
+    public ConnectionStateListener of(EventAction action) {
+      return new ConnectionStateListener() {
+        private final AtomicBoolean isExpired = new AtomicBoolean(false);
+
+        @Override
+        public void stateChanged(CuratorFramework client, ConnectionState 
newState) {
+          if (newState == ConnectionState.LOST) {
+            isExpired.set(true);
+          } else if (newState == ConnectionState.RECONNECTED) {
+            if (isExpired.compareAndSet(true, false)) {
+              action.respond();
+            }
+          }
+        }
+      };
+    }
+  },
+
+  SESSION_EXPIRATION {

Review Comment:
   Yea though there is a subtle difference that when you get EXPIRED event you 
are guaranteed that eventually this session will expire since that is the 
server telling you the session is expired. I believe Curator's LOST can be 
determined on the client by curator itself based on a timer in which case you 
don't have the guarantee that the server will decide to expire the session at 
all.
   
   An example of how to handle this is to defensively pause activities as a 
leader when you get a disconnect and then completely abdicate leadership on 
LOST. Because you've paused leadership activities during this period, it is 
safer for another node to claim leadership in this time as the 
disconnection-to-session-loss gap becomes the coordinated handover period. That 
being said Solr doesn't do this at all and relies on other mechanisms to 
prevent split-brain, etc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to