[
https://issues.apache.org/jira/browse/CURATOR-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932159#comment-15932159
]
ASF GitHub Bot commented on CURATOR-386:
----------------------------------------
Github user akira commented on a diff in the pull request:
https://github.com/apache/curator/pull/198#discussion_r106834514
--- Diff:
curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
---
@@ -117,6 +120,7 @@ public void processResult(CuratorFramework client,
CuratorEvent event)
{
//Update is ok, mark initialisation as complete if
required.
initialisationComplete();
+ notifyListeners();
--- End diff --
@lvfangmin I looked at this - and it looks to me like this is the callback
where the result of node creation comes back (telling us whether it was
successful, node already exists, etc). This is in the
`processBackgroundCallback` method, and where we know that the result code
comes back as `false` for `KeeperException.Code.NODEEXISTS` and `true` for
`KeeperException.Code.OK`. This means that we just created the node, and
seemingly the place to notify listeners.
The callback for updating the node value seems to be `setDataCallback`,
which I did not put any code for notifying listeners.
To me this looked like the place to put this, but definitely let me know if
you thought of a better place and I can investigate that.
> Allow listener to be passed in to PersistentNode to notify for node creation
> events
> -----------------------------------------------------------------------------------
>
> Key: CURATOR-386
> URL: https://issues.apache.org/jira/browse/CURATOR-386
> Project: Apache Curator
> Issue Type: Improvement
> Components: Recipes
> Affects Versions: 3.2.1
> Reporter: Alex Kira
> Priority: Minor
>
> I think it would be useful to allow a listener to be passed in to the
> PersistentNode that would notify when the new node is created. This is useful
> as some cases such as disconnect / reconnect or when an ephemeral node is
> deleted and recreated by PersistentNode. In this case, I would like to be
> able to listen to these even so I can do something like issue a watch on the
> node.
> For example:
> ```
> public interface PersistentNodeListener {
> /**
> * Called on a persistentNode event when node is created
> *
> * @param path Path of the znode
> * @throws Exception errors
> */
> void nodeCreated(String path) throws Exception;
> }
> ```
> I have a code change implementing this and can issue a pull request for this.
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)