From 6ab7b1db17999d3661d3b4b0177e88c37da20489 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Tue, 1 Apr 2025 10:12:29 +0200
Subject: [PATCH 01/10] ISSUE 1258
---
.../recipes/nodes/PersistentTtlNode.java | 18 +++++-----
.../recipes/nodes/TestPersistentTtlNode.java | 34 +++++++++++++++++--
2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index 2b2ba561a..93c2bd403 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -159,12 +159,14 @@ public PersistentTtlNode(
this.client = Objects.requireNonNull(client, "client cannot be null");
this.ttlMs = ttlMs;
this.touchScheduleFactor = touchScheduleFactor;
- node = new PersistentNode(client, CreateMode.CONTAINER, false, path, initData, useParentCreation) {
- @Override
- protected void deleteNode() {
- // NOP
- }
- };
+ node =
+ new PersistentNode(
+ client, CreateMode.PERSISTENT_WITH_TTL, false, path, initData, ttlMs, useParentCreation) {
+ @Override
+ protected void deleteNode() {
+ // NOP
+ }
+ };
this.executorService = Objects.requireNonNull(executorService, "executorService cannot be null");
childPath = ZKPaths.makePath(Objects.requireNonNull(path, "path cannot be null"), childNodeName);
}
@@ -239,8 +241,8 @@ public byte[] getData() {
/**
* Call when you are done with the PersistentTtlNode. Note: the ZNode is not immediately
- * deleted. However, if no other PersistentTtlNode with the same path is running the node will get deleted
- * based on the ttl.
+ * deleted. However, if no other PersistentTtlNode with the same path is running the node will get
+ * deleted based on the ttl.
*/
@Override
public void close() {
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index ddc9f3975..9da68f058 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -134,8 +134,8 @@ public void testRecreationOfParentNodeWithParentCreationOff() throws Exception {
client.delete().deletingChildrenIfNeeded().forPath("/test/one");
timing.sleepABit();
- // The underlying persistent node should not be able to recreate itself as the lazy parent creation is
- // disabled
+ // The underlying persistent node should not be able to recreate itself as the lazy parent
+ // creation is disabled
assertNull(client.checkExists().forPath(containerPath));
assertNull(client.checkExists().forPath(childPath));
@@ -187,4 +187,34 @@ public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) th
assertNull(client.checkExists().forPath("/test"));
}
}
+
+ @Test
+ public void testTouchNodeNotCreated() throws Exception {
+ try (CuratorFramework client =
+ CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1))) {
+ client.start();
+ final long ttlMs = 1_000L;
+ try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0])) {
+ node.start();
+ assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
+ // Give some minor time for touch node to be created. Will worked after patch
+ for (int i = 1; i <= 5; i++) {
+ if (client.checkExists().forPath("/test") != null) {
+ break;
+ }
+ Thread.sleep(10L);
+ }
+ }
+ }
+ try (CuratorFramework client1 =
+ CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1))) {
+ client1.start();
+ assertTrue(client1.blockUntilConnected(2, TimeUnit.SECONDS));
+ Thread.sleep(3_000L);
+ assertNull(client1.checkExists().forPath("/test/touch"));
+ assertNull(
+ client1.checkExists().forPath("/test"),
+ "Persistent TTL node NOT removed. The reason is that '/test/touch' was NOT create on time to make PerssistentTTLNode recipe to work");
+ }
+ }
}
From 6996085febe336291f501a02bccc0317e04a2209 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Wed, 2 Apr 2025 17:27:00 +0200
Subject: [PATCH 02/10] ISSUE-1258
---
.../recipes/nodes/PersistentTtlNode.java | 4 +-
.../recipes/nodes/TestPersistentTtlNode.java | 53 ++++++++++++-------
2 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index 93c2bd403..c0b3b87b6 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -241,8 +241,8 @@ public byte[] getData() {
/**
* Call when you are done with the PersistentTtlNode. Note: the ZNode is not immediately
- * deleted. However, if no other PersistentTtlNode with the same path is running the node will get
- * deleted based on the ttl.
+ * deleted. However, if no other PersistentTtlNode with the same path is running the node will get deleted
+ * based on the ttl.
*/
@Override
public void close() {
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index 9da68f058..26ac136fc 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -22,22 +22,28 @@
import static org.apache.curator.framework.recipes.cache.PathChildrenCache.StartMode.BUILD_INITIAL_CACHE;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
+import org.apache.curator.framework.recipes.watch.PersistentWatcher;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.ZKPaths;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.Watcher.Event.EventType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -190,31 +196,40 @@ public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) th
@Test
public void testTouchNodeNotCreated() throws Exception {
+ final String mainPath = "/parent/main";
+ final String touchPath = mainPath + "/touch";
+ final long ttlMs = 500L;
+ final CountDownLatch mainCreatedLatch = new CountDownLatch(1);
+ final CountDownLatch mainDeletedLatch = new CountDownLatch(1);
+ final AtomicBoolean touchCreated = new AtomicBoolean();
try (CuratorFramework client =
CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1))) {
client.start();
- final long ttlMs = 1_000L;
- try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0])) {
- node.start();
- assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
- // Give some minor time for touch node to be created. Will worked after patch
- for (int i = 1; i <= 5; i++) {
- if (client.checkExists().forPath("/test") != null) {
- break;
+ assertTrue(client.blockUntilConnected(1, TimeUnit.SECONDS));
+ try (PersistentWatcher watcher = new PersistentWatcher(client, mainPath, true)) {
+ final Watcher listener = event -> {
+ final String path = event.getPath();
+ if (mainPath.equals(path)) {
+ final EventType type = event.getType();
+ if (EventType.NodeCreated.equals(type)) {
+ mainCreatedLatch.countDown();
+ } else if (EventType.NodeDeleted.equals(type)) {
+ mainDeletedLatch.countDown();
+ }
+ } else if (touchPath.equals(path)) {
+ touchCreated.set(true);
}
- Thread.sleep(10L);
+ };
+ watcher.getListenable().addListener(listener);
+ watcher.start();
+ try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, ttlMs, new byte[0]); ) {
+ node.start();
+ assertTrue(mainCreatedLatch.await(1L, TimeUnit.SECONDS));
+ assertNull(client.checkExists().forPath(touchPath));
}
+ assertTrue(mainDeletedLatch.await(3L * ttlMs, TimeUnit.MILLISECONDS));
+ assertFalse(touchCreated.get()); // Just to control that touch ZNode never created
}
}
- try (CuratorFramework client1 =
- CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1))) {
- client1.start();
- assertTrue(client1.blockUntilConnected(2, TimeUnit.SECONDS));
- Thread.sleep(3_000L);
- assertNull(client1.checkExists().forPath("/test/touch"));
- assertNull(
- client1.checkExists().forPath("/test"),
- "Persistent TTL node NOT removed. The reason is that '/test/touch' was NOT create on time to make PerssistentTTLNode recipe to work");
- }
}
}
From 81bc36885d63f2e8a5ec32e50c213a7432d804b8 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Wed, 2 Apr 2025 17:56:04 +0200
Subject: [PATCH 03/10] ISSUE 1258
---
.../curator/framework/recipes/nodes/PersistentTtlNode.java | 4 ++--
.../framework/recipes/nodes/TestPersistentTtlNode.java | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index c0b3b87b6..8184a4a17 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -37,7 +37,7 @@
/**
*
- * Manages a {@link PersistentNode} that uses {@link CreateMode#CONTAINER}. Asynchronously
+ * Manages a {@link PersistentNode} that uses {@link CreateMode#PERSISTENT_WITH_TTL}. Asynchronously
* it creates or updates a child on the persistent node that is marked with a provided TTL.
*
*
@@ -46,7 +46,7 @@
* a method of having the parent node deleted if the TTL expires. i.e. if the process
* that is running the PersistentTtlNode crashes and the TTL elapses, first the child node
* will be deleted due to the TTL expiration and then the parent node will be deleted as it's
- * a container node with no children.
+ * a TTL node with no children.
*
*
*
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index 26ac136fc..77819f0c7 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -140,8 +140,8 @@ public void testRecreationOfParentNodeWithParentCreationOff() throws Exception {
client.delete().deletingChildrenIfNeeded().forPath("/test/one");
timing.sleepABit();
- // The underlying persistent node should not be able to recreate itself as the lazy parent
- // creation is disabled
+ // The underlying persistent node should not be able to recreate itself as the lazy parent creation is
+ // disabled
assertNull(client.checkExists().forPath(containerPath));
assertNull(client.checkExists().forPath(childPath));
@@ -225,8 +225,8 @@ public void testTouchNodeNotCreated() throws Exception {
try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, ttlMs, new byte[0]); ) {
node.start();
assertTrue(mainCreatedLatch.await(1L, TimeUnit.SECONDS));
- assertNull(client.checkExists().forPath(touchPath));
}
+ assertNull(client.checkExists().forPath(touchPath));
assertTrue(mainDeletedLatch.await(3L * ttlMs, TimeUnit.MILLISECONDS));
assertFalse(touchCreated.get()); // Just to control that touch ZNode never created
}
From f96ef759092491970251f26c30d92b00693baf32 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Wed, 2 Apr 2025 20:09:11 +0200
Subject: [PATCH 04/10] ISSUE 1258
---
.../framework/recipes/nodes/TestPersistentTtlNode.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index 77819f0c7..d0a9378fc 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -197,8 +197,8 @@ public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) th
@Test
public void testTouchNodeNotCreated() throws Exception {
final String mainPath = "/parent/main";
- final String touchPath = mainPath + "/touch";
- final long ttlMs = 500L;
+ final String touchPath = ZKPaths.makePath(mainPath, PersistentTtlNode.DEFAULT_CHILD_NODE_NAME);
+ final long testTtlMs = 500L;
final CountDownLatch mainCreatedLatch = new CountDownLatch(1);
final CountDownLatch mainDeletedLatch = new CountDownLatch(1);
final AtomicBoolean touchCreated = new AtomicBoolean();
@@ -222,12 +222,12 @@ public void testTouchNodeNotCreated() throws Exception {
};
watcher.getListenable().addListener(listener);
watcher.start();
- try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, ttlMs, new byte[0]); ) {
+ try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, testTtlMs, new byte[0]); ) {
node.start();
assertTrue(mainCreatedLatch.await(1L, TimeUnit.SECONDS));
}
assertNull(client.checkExists().forPath(touchPath));
- assertTrue(mainDeletedLatch.await(3L * ttlMs, TimeUnit.MILLISECONDS));
+ assertTrue(mainDeletedLatch.await(3L * testTtlMs, TimeUnit.MILLISECONDS));
assertFalse(touchCreated.get()); // Just to control that touch ZNode never created
}
}
From 1ae61d73dc0b53cf15febf422d6fd9ebe63f5d71 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Thu, 3 Apr 2025 10:47:15 +0200
Subject: [PATCH 05/10] ISSUE 1258
---
.../framework/recipes/nodes/PersistentTtlNode.java | 14 ++++++++++++++
.../recipes/nodes/TestPersistentTtlNode.java | 3 ++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index 8184a4a17..ee7e29b0f 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -19,6 +19,7 @@
package org.apache.curator.framework.recipes.nodes;
+import com.google.common.annotations.VisibleForTesting;
import java.io.Closeable;
import java.io.IOException;
import java.util.Objects;
@@ -68,6 +69,7 @@ public class PersistentTtlNode implements Closeable {
private final ScheduledExecutorService executorService;
private final AtomicReference> futureRef = new AtomicReference<>();
private final String childPath;
+ private volatile boolean skipTouch; // Just for testing
/**
* @param client the client
@@ -171,6 +173,14 @@ protected void deleteNode() {
childPath = ZKPaths.makePath(Objects.requireNonNull(path, "path cannot be null"), childNodeName);
}
+ /**
+ * Allows to control if subsequent touch scheduled activities needs to be skipped
+ */
+ @VisibleForTesting
+ void skipTouch(boolean skip) {
+ skipTouch = skip;
+ }
+
/**
* You must call start() to initiate the persistent ttl node
*/
@@ -180,6 +190,10 @@ public void start() {
Runnable touchTask = new Runnable() {
@Override
public void run() {
+ if (skipTouch) {
+ log.debug("Skipping touch child node");
+ return;
+ }
try {
try {
client.setData().forPath(childPath);
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index d0a9378fc..4cccae779 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -222,7 +222,8 @@ public void testTouchNodeNotCreated() throws Exception {
};
watcher.getListenable().addListener(listener);
watcher.start();
- try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, testTtlMs, new byte[0]); ) {
+ try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, testTtlMs, new byte[0])) {
+ node.skipTouch(true);
node.start();
assertTrue(mainCreatedLatch.await(1L, TimeUnit.SECONDS));
}
From 2cd04605ab04847b4774eaa424328fbce55571b1 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Fri, 4 Apr 2025 09:28:09 +0200
Subject: [PATCH 06/10] ISSUE 1258
---
.../recipes/nodes/PersistentTtlNode.java | 54 +++++++------------
.../recipes/nodes/TestPersistentTtlNode.java | 8 ++-
2 files changed, 26 insertions(+), 36 deletions(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index ee7e29b0f..ef7b4df18 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -69,7 +69,6 @@ public class PersistentTtlNode implements Closeable {
private final ScheduledExecutorService executorService;
private final AtomicReference> futureRef = new AtomicReference<>();
private final String childPath;
- private volatile boolean skipTouch; // Just for testing
/**
* @param client the client
@@ -173,12 +172,25 @@ protected void deleteNode() {
childPath = ZKPaths.makePath(Objects.requireNonNull(path, "path cannot be null"), childNodeName);
}
- /**
- * Allows to control if subsequent touch scheduled activities needs to be skipped
- */
@VisibleForTesting
- void skipTouch(boolean skip) {
- skipTouch = skip;
+ void touch() {
+ try {
+ try {
+ client.setData().forPath(childPath);
+ } catch (KeeperException.NoNodeException e) {
+ client.create()
+ .orSetData()
+ .withTtl(ttlMs)
+ .withMode(CreateMode.PERSISTENT_WITH_TTL)
+ .forPath(childPath);
+ }
+ } catch (KeeperException.NoNodeException ignore) {
+ // ignore
+ } catch (Exception e) {
+ if (!ThreadUtils.checkInterrupted(e)) {
+ log.debug("Could not touch child node", e);
+ }
+ }
}
/**
@@ -186,35 +198,9 @@ void skipTouch(boolean skip) {
*/
public void start() {
node.start();
-
- Runnable touchTask = new Runnable() {
- @Override
- public void run() {
- if (skipTouch) {
- log.debug("Skipping touch child node");
- return;
- }
- try {
- try {
- client.setData().forPath(childPath);
- } catch (KeeperException.NoNodeException e) {
- client.create()
- .orSetData()
- .withTtl(ttlMs)
- .withMode(CreateMode.PERSISTENT_WITH_TTL)
- .forPath(childPath);
- }
- } catch (KeeperException.NoNodeException ignore) {
- // ignore
- } catch (Exception e) {
- if (!ThreadUtils.checkInterrupted(e)) {
- log.debug("Could not touch child node", e);
- }
- }
- }
- };
+ final Runnable runnable = () -> touch();
Future> future = executorService.scheduleAtFixedRate(
- touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
+ runnable, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
futureRef.set(future);
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index 4cccae779..b98ada445 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -222,8 +222,12 @@ public void testTouchNodeNotCreated() throws Exception {
};
watcher.getListenable().addListener(listener);
watcher.start();
- try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, testTtlMs, new byte[0])) {
- node.skipTouch(true);
+ try (PersistentTtlNode node = new PersistentTtlNode(client, mainPath, testTtlMs, new byte[0]) {
+ @Override
+ void touch() {
+ // NOP
+ }
+ }) {
node.start();
assertTrue(mainCreatedLatch.await(1L, TimeUnit.SECONDS));
}
From bba2f2883cdab2f58d07de8ba1360df14479c022 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Fri, 4 Apr 2025 09:32:32 +0200
Subject: [PATCH 07/10] ISSUE 1258
---
.../curator/framework/recipes/nodes/PersistentTtlNode.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index ef7b4df18..ff6585a14 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -198,9 +198,9 @@ void touch() {
*/
public void start() {
node.start();
- final Runnable runnable = () -> touch();
+ final Runnable touchTask = () -> touch();
Future> future = executorService.scheduleAtFixedRate(
- runnable, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
+ touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
futureRef.set(future);
}
From 110cf446138dbb630e7e17e9cf3278adec7cad24 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Fri, 4 Apr 2025 09:34:47 +0200
Subject: [PATCH 08/10] ISSUE 1258
---
.../curator/framework/recipes/nodes/PersistentTtlNode.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index ff6585a14..cb6e985b3 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -200,7 +200,7 @@ public void start() {
node.start();
final Runnable touchTask = () -> touch();
Future> future = executorService.scheduleAtFixedRate(
- touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
+ touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
futureRef.set(future);
}
From e7e140c51c9e40f7f8730325bc19099c522ba955 Mon Sep 17 00:00:00 2001
From: Chevaris
Date: Fri, 4 Apr 2025 09:37:39 +0200
Subject: [PATCH 09/10] ISSUE 1258
---
.../curator/framework/recipes/nodes/PersistentTtlNode.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index cb6e985b3..db9380708 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -200,7 +200,7 @@ public void start() {
node.start();
final Runnable touchTask = () -> touch();
Future> future = executorService.scheduleAtFixedRate(
- touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
+ touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
futureRef.set(future);
}
From 6a96dba6c7dffd32113e66d6882f068481a7fc68 Mon Sep 17 00:00:00 2001
From: chevaris
Date: Mon, 7 Apr 2025 15:24:18 +0200
Subject: [PATCH 10/10] ISSUE 1258
Co-authored-by: Kezhu Wang
---
.../curator/framework/recipes/nodes/PersistentTtlNode.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
index db9380708..33e1608a2 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentTtlNode.java
@@ -198,9 +198,8 @@ void touch() {
*/
public void start() {
node.start();
- final Runnable touchTask = () -> touch();
Future> future = executorService.scheduleAtFixedRate(
- touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
+ this::touch, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
futureRef.set(future);
}