[CURATOR-314] Listenable support for GroupMember recipe
The GroupMember recipe currently doesn't provide any membership change events. I wanted this feature in my project and I've implemented it by making a copy of GroupMember in my project and adding the necessary classes and interfaces. I wanted to contribute this back to curator
Originally reported by [email protected], imported from: Listenable support for GroupMember recipe
- status: Open
- priority: Major
- resolution: Unresolved
- imported: 2025-01-21
GitHub user shivramk opened a pull request:
https://github.com/apache/curator/pull/141
CURATOR-314 Listenable support for GroupMember recipe
I've added support for listenable events to the GroupMember recipe. Its built on the event support provided by the underlying PathChildenCache object being used by GroupMember
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/shivramk/curator CURATOR-314
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/curator/pull/141.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #141
commit 840afd3158e825ccf038ab4cc272fbc357b8c7a1
Author: Shivram Khandeparker
Date: 2016-04-05T16:32:34Z
Added support for listenable events in GroupMember
commit debad0ab1cbbfd754f80d51ce6b24bca0b0e4034
Author: Shivram Khandeparker
Date: 2016-04-05T16:49:41Z
Added test case for GroupMemberListener
Github user Randgalt commented on a diff in the pull request:
https://github.com/apache/curator/pull/141#discussion_r62436637
— Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupData.java —
@@ -0,0 +1,94 @@
+/**
— End diff –
Can't ChildData be re-used here? The only difference is the stat object which doesn't hurt for GroupMember.
Github user Randgalt commented on a diff in the pull request:
https://github.com/apache/curator/pull/141#discussion_r62436654
— Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java —
@@ -75,6 +119,7 @@ public void start()
try
{
cache.start();
+ cache.getListenable().addListener(childrenCacheListener);
— End diff –
Why not add a proxy listener getListenable()? I need to think about this. Does this single listener correctly proxy all behaviors from getListenable()?
Github user Randgalt commented on a diff in the pull request:
https://github.com/apache/curator/pull/141#discussion_r62436669
— Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMemberEvent.java —
@@ -0,0 +1,75 @@
+/**
+ * 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.recipes.nodes;
+
+/**
+ * POJO that abstracts a change to a group membership
+ */
+public class GroupMemberEvent
— End diff –
PathChildrenCacheEvent or TreeCacheEvent can be used, right? I'm leery expanded the number of event objects.