You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by "kezhuw (via GitHub)" <gi...@apache.org> on 2024/12/31 05:13:43 UTC

[PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

kezhuw opened a new pull request, #517:
URL: https://github.com/apache/curator/pull/517

   Currently, the `CuratorFrameworkImpl` hierarchy is neither simple nor composable.
   
   Ideally, there should be only one instance of `CuratorFrameworkImpl`. Additional functionalities should be added by intercepting methods on purpose, but not by cloning through `CuratorFrameworkImpl(CuratorFrameworkImpl parent)`.
   
   We could take CURATOR-626 and CURATOR-710 as lessons to know how brittle the currently hierarchy.


-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1929462027


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {

Review Comment:
   Also can be package private.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1899924690


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/InternalCuratorFramework.java:
##########
@@ -0,0 +1,253 @@
+/*
+ * 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.curator.framework.imps;
+
+import com.google.common.base.Preconditions;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.WatcherRemoveCuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CreateBuilder;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.DeleteBuilder;
+import org.apache.curator.framework.api.ExistsBuilder;
+import org.apache.curator.framework.api.GetACLBuilder;
+import org.apache.curator.framework.api.GetChildrenBuilder;
+import org.apache.curator.framework.api.GetConfigBuilder;
+import org.apache.curator.framework.api.GetDataBuilder;
+import org.apache.curator.framework.api.ReconfigBuilder;
+import org.apache.curator.framework.api.RemoveWatchesBuilder;
+import org.apache.curator.framework.api.SetACLBuilder;
+import org.apache.curator.framework.api.SetDataBuilder;
+import org.apache.curator.framework.api.SyncBuilder;
+import org.apache.curator.framework.api.WatchesBuilder;
+import org.apache.curator.framework.api.transaction.CuratorMultiTransaction;
+import org.apache.curator.framework.api.transaction.CuratorTransaction;
+import org.apache.curator.framework.api.transaction.TransactionOp;
+import org.apache.curator.utils.EnsurePath;
+import org.apache.curator.utils.ZKPaths;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+
+/**
+ * This is the internal version of {@link CuratorFramework}.
+ *
+ * <p>Most internal codes should use {@link InternalCuratorFramework} instead of {@link CuratorFrameworkImpl}, so
+ * functionalities could be added additively by overriding methods in {@link DelegatingCuratorFramework}.
+ *
+ * <p>An instance of {@link CuratorFramework} MUST BE an instance of {@link InternalCuratorFramework}.
+ */
+public abstract class InternalCuratorFramework implements CuratorFramework {

Review Comment:
   This is the most notable change.
   
   `NamespaceFacade` and `WatcherRemovalFacade` are now subclasses of `DelegatingCuratorFramework` and `InternalCuratorFramework` but not `CuratorFrameworkImpl`.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1946071681


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {
+    protected final InternalCuratorFramework client;
+
+    public DelegatingCuratorFramework(InternalCuratorFramework client) {
+        this.client = client;
+    }
+
+    @Override
+    public void start() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void close() {
+        throw new UnsupportedOperationException();
+    }

Review Comment:
   Hmm, I don't think `NamespaceFacade::close` should close curator.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1929457668


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {
+    protected final InternalCuratorFramework client;
+
+    public DelegatingCuratorFramework(InternalCuratorFramework client) {
+        this.client = client;
+    }
+
+    @Override
+    public void start() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void close() {
+        throw new UnsupportedOperationException();
+    }

Review Comment:
   Or somewhat delegate to `client.start/close` also?



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun merged PR #517:
URL: https://github.com/apache/curator/pull/517


-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on PR #517:
URL: https://github.com/apache/curator/pull/517#issuecomment-2566142916

   I leave CURATOR-710 to #508.
   
   To resolve CURATOR-710, I think we need to decide whether `CuratorFramework::usingNamespace` should inherit functionalities of `this` ? If it is yes, then we probably could fix CURATOR-710 in a straightfoward way (comparing to trick fix in #508).


-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1945969754


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {

Review Comment:
   Done.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1929455173


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {
+    protected final InternalCuratorFramework client;
+
+    public DelegatingCuratorFramework(InternalCuratorFramework client) {
+        this.client = client;
+    }
+
+    @Override
+    public void start() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void close() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public CuratorFrameworkState getState() {
+        return client.getState();
+    }
+
+    @Override
+    @Deprecated
+    public boolean isStarted() {
+        return client.isStarted();
+    }
+
+    @Override
+    public Listenable<ConnectionStateListener> getConnectionStateListenable() {
+        return client.getConnectionStateListenable();
+    }
+
+    @Override
+    public Listenable<CuratorListener> getCuratorListenable() {
+        return client.getCuratorListenable();
+    }
+
+    @Override
+    public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
+        return client.getUnhandledErrorListenable();
+    }
+
+    @Override
+    public CuratorFramework usingNamespace(String newNamespace) {
+        return client.usingNamespace(newNamespace);
+    }
+
+    @Override
+    public CuratorZookeeperClient getZookeeperClient() {
+        return client.getZookeeperClient();
+    }
+
+    @Override
+    public ZookeeperCompatibility getZookeeperCompatibility() {
+        return client.getZookeeperCompatibility();
+    }
+
+    @Override
+    @Deprecated
+    public void clearWatcherReferences(Watcher watcher) {
+        client.clearWatcherReferences(watcher);
+    }
+
+    @Override
+    public boolean blockUntilConnected(int maxWaitTime, TimeUnit units) throws InterruptedException {
+        return client.blockUntilConnected(maxWaitTime, units);
+    }
+
+    @Override
+    public void blockUntilConnected() throws InterruptedException {
+        client.blockUntilConnected();
+    }
+
+    @Override
+    public ConnectionStateErrorPolicy getConnectionStateErrorPolicy() {
+        return client.getConnectionStateErrorPolicy();
+    }
+
+    @Override
+    public QuorumVerifier getCurrentConfig() {
+        return client.getCurrentConfig();
+    }
+
+    @Override
+    public SchemaSet getSchemaSet() {
+        return client.getSchemaSet();
+    }
+
+    @Override
+    public CompletableFuture<Void> postSafeNotify(Object monitorHolder) {
+        return client.postSafeNotify(monitorHolder);
+    }
+
+    @Override
+    public CompletableFuture<Void> runSafe(Runnable runnable) {
+        return client.runSafe(runnable);
+    }
+
+    @Override
+    NamespaceImpl getNamespaceImpl() {
+        return client.getNamespaceImpl();
+    }
+
+    @Override
+    void validateConnection(Watcher.Event.KeeperState state) {
+        client.validateConnection(state);
+    }
+
+    @Override
+    WatcherRemovalManager getWatcherRemovalManager() {
+        return client.getWatcherRemovalManager();
+    }
+
+    @Override
+    FailedDeleteManager getFailedDeleteManager() {
+        return client.getFailedDeleteManager();
+    }
+
+    @Override
+    FailedRemoveWatchManager getFailedRemoveWatcherManager() {
+        return client.getFailedRemoveWatcherManager();
+    }
+
+    @Override
+    public void logError(String reason, Throwable e) {
+        client.logError(reason, e);
+    }
+
+    @Override
+    byte[] getDefaultData() {
+        return client.getDefaultData();
+    }
+
+    @Override
+    CompressionProvider getCompressionProvider() {
+        return client.getCompressionProvider();
+    }
+
+    @Override
+    public boolean compressionEnabled() {
+        return client.compressionEnabled();
+    }
+
+    @Override
+    ACLProvider getAclProvider() {
+        return client.getAclProvider();
+    }
+
+    @Override
+    boolean useContainerParentsIfAvailable() {
+        return client.useContainerParentsIfAvailable();
+    }
+
+    @Override
+    EnsembleTracker getEnsembleTracker() {
+        return client.getEnsembleTracker();
+    }
+
+    @Override
+    NamespaceFacadeCache getNamespaceFacadeCache() {
+        return client.getNamespaceFacadeCache();
+    }
+
+    @Override
+    public <DATA_TYPE> void processBackgroundOperation(

Review Comment:
   ```suggestion
       <DATA_TYPE> void processBackgroundOperation(
   ```
   
   .. and may need a re-format



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1945957440


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {
+    protected final InternalCuratorFramework client;
+
+    public DelegatingCuratorFramework(InternalCuratorFramework client) {
+        this.client = client;
+    }
+
+    @Override
+    public void start() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void close() {
+        throw new UnsupportedOperationException();
+    }

Review Comment:
   Currently, only `CuratorFrameworkImpl::start`/`CuratorFrameworkImpl::close` take effects, `start`/`close` in other facades throw. I think we should keep this behavior unchanged in an refactor.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1946038545


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {
+    protected final InternalCuratorFramework client;
+
+    public DelegatingCuratorFramework(InternalCuratorFramework client) {
+        this.client = client;
+    }
+
+    @Override
+    public void start() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void close() {
+        throw new UnsupportedOperationException();
+    }

Review Comment:
   Yeah I noticed that this is the original manner. Then it's fine. (Although I think it's by accident, cc @Randgalt do you remember the reason why we don't delegate here?



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1929455311


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/InternalCuratorFramework.java:
##########
@@ -0,0 +1,263 @@
+/*
+ * 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.curator.framework.imps;
+
+import com.google.common.base.Preconditions;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.WatcherRemoveCuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CreateBuilder;
+import org.apache.curator.framework.api.CuratorClosedException;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.DeleteBuilder;
+import org.apache.curator.framework.api.ExistsBuilder;
+import org.apache.curator.framework.api.GetACLBuilder;
+import org.apache.curator.framework.api.GetChildrenBuilder;
+import org.apache.curator.framework.api.GetConfigBuilder;
+import org.apache.curator.framework.api.GetDataBuilder;
+import org.apache.curator.framework.api.ReconfigBuilder;
+import org.apache.curator.framework.api.RemoveWatchesBuilder;
+import org.apache.curator.framework.api.SetACLBuilder;
+import org.apache.curator.framework.api.SetDataBuilder;
+import org.apache.curator.framework.api.SyncBuilder;
+import org.apache.curator.framework.api.WatchesBuilder;
+import org.apache.curator.framework.api.transaction.CuratorMultiTransaction;
+import org.apache.curator.framework.api.transaction.CuratorTransaction;
+import org.apache.curator.framework.api.transaction.TransactionOp;
+import org.apache.curator.utils.EnsurePath;
+import org.apache.curator.utils.ZKPaths;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+
+/**
+ * This is the internal version of {@link CuratorFramework}.
+ *
+ * <p>Most internal codes should use {@link InternalCuratorFramework} instead of {@link CuratorFrameworkImpl}, so
+ * functionalities could be added additively by overriding methods in {@link DelegatingCuratorFramework}.
+ *
+ * <p>An instance of {@link CuratorFramework} MUST BE an instance of {@link InternalCuratorFramework}.
+ */
+public abstract class InternalCuratorFramework implements CuratorFramework {

Review Comment:
   Personally, I'd prefer to name it `CuratorFrameworkBase` since it's used outside (as method parameter) rather than internal.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on PR #517:
URL: https://github.com/apache/curator/pull/517#issuecomment-2596178499

   > would you consider this is a release blocker? 
   
   No. It is not a even a bug.


-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1899929334


##########
curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorEdges.java:
##########
@@ -98,15 +97,13 @@ public void flappingTest() throws Exception {
         } finally {
             try {
                 leaderSelector1.close();
-            } catch (IllegalStateException e) {
-                fail(e.getMessage());

Review Comment:
   This shadow the real cause.
   
   See https://ge.apache.org/s/rcubepxch5ibu/tests/goal/org.apache.curator:curator-recipes:surefire:test@default-test/details/org.apache.curator.framework.recipes.leader.TestLeaderSelectorEdges/flappingTest?top-execution=1



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #517:
URL: https://github.com/apache/curator/pull/517#issuecomment-2596153036

   @kezhuw would you consider this is a release blocker? I may expect to call a release by the end of Feb. and now try to collaborate to converge the ongoing PRs.


-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1945972625


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/InternalCuratorFramework.java:
##########
@@ -0,0 +1,263 @@
+/*
+ * 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.curator.framework.imps;
+
+import com.google.common.base.Preconditions;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.WatcherRemoveCuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CreateBuilder;
+import org.apache.curator.framework.api.CuratorClosedException;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.DeleteBuilder;
+import org.apache.curator.framework.api.ExistsBuilder;
+import org.apache.curator.framework.api.GetACLBuilder;
+import org.apache.curator.framework.api.GetChildrenBuilder;
+import org.apache.curator.framework.api.GetConfigBuilder;
+import org.apache.curator.framework.api.GetDataBuilder;
+import org.apache.curator.framework.api.ReconfigBuilder;
+import org.apache.curator.framework.api.RemoveWatchesBuilder;
+import org.apache.curator.framework.api.SetACLBuilder;
+import org.apache.curator.framework.api.SetDataBuilder;
+import org.apache.curator.framework.api.SyncBuilder;
+import org.apache.curator.framework.api.WatchesBuilder;
+import org.apache.curator.framework.api.transaction.CuratorMultiTransaction;
+import org.apache.curator.framework.api.transaction.CuratorTransaction;
+import org.apache.curator.framework.api.transaction.TransactionOp;
+import org.apache.curator.utils.EnsurePath;
+import org.apache.curator.utils.ZKPaths;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+
+/**
+ * This is the internal version of {@link CuratorFramework}.
+ *
+ * <p>Most internal codes should use {@link InternalCuratorFramework} instead of {@link CuratorFrameworkImpl}, so
+ * functionalities could be added additively by overriding methods in {@link DelegatingCuratorFramework}.
+ *
+ * <p>An instance of {@link CuratorFramework} MUST BE an instance of {@link InternalCuratorFramework}.
+ */
+public abstract class InternalCuratorFramework implements CuratorFramework {

Review Comment:
   Renamed.
   
   By `internal`, I mean it should not be used outside of `curator`. Currently, only `impls`/`details` packages use it. Add `it is public for private usages` for caution.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1945970427


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {

Review Comment:
   `DelegatingCuratorFramework` is now `abstract` and `start`/`close` has been moved to subclasses.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on PR #517:
URL: https://github.com/apache/curator/pull/517#issuecomment-2641979564

   @tisonkun Sorry for being so late! I have pushed a fixup commit to solve the review comments.


-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CURATOR-718: Refactor CuratorFramework inheritance hierarchy by composing functionalities [curator]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #517:
URL: https://github.com/apache/curator/pull/517#discussion_r1929455408


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/DelegatingCuratorFramework.java:
##########
@@ -0,0 +1,213 @@
+/*
+ * 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.curator.framework.imps;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.ACLProvider;
+import org.apache.curator.framework.api.CompressionProvider;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ZookeeperCompatibility;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class DelegatingCuratorFramework extends InternalCuratorFramework {

Review Comment:
   Add some class comment for its purpose?
   
   Also this seems another abstract class rather than an instantiable one. And we don't need impl `start` and `close` in such a bias.



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org