From cc7f426c5fb6d95affe5da8524e6bb3ab55fb842 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Fri, 9 Jul 2021 13:28:38 +0200 Subject: Use Curator instead of ConfigCurator, part 4 --- .../java/com/yahoo/vespa/curator/recipes/CuratorCounter.java | 10 +++++----- .../test/java/com/yahoo/vespa/curator/CuratorCounterTest.java | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'zkfacade') diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/recipes/CuratorCounter.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/recipes/CuratorCounter.java index dd49b2595a4..2167b45bc02 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/recipes/CuratorCounter.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/recipes/CuratorCounter.java @@ -1,6 +1,7 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.curator.recipes; +import com.yahoo.path.Path; import com.yahoo.vespa.curator.Curator; import org.apache.curator.framework.recipes.atomic.AtomicValue; import org.apache.curator.framework.recipes.atomic.DistributedAtomicLong; @@ -9,15 +10,14 @@ import org.apache.curator.framework.recipes.atomic.DistributedAtomicLong; * A distributed atomic counter. * * @author Ulf Lilleengen - * @since 5.1 */ public class CuratorCounter { private final DistributedAtomicLong counter; - private final String counterPath; + private final Path counterPath; - public CuratorCounter(Curator curator, String counterPath) { - this.counter = curator.createAtomicCounter(counterPath); + public CuratorCounter(Curator curator, Path counterPath) { + this.counter = curator.createAtomicCounter(counterPath.getAbsolute()); this.counterPath = counterPath; } diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorCounterTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorCounterTest.java index 6b85953a1ff..3d465c6b71f 100644 --- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorCounterTest.java +++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorCounterTest.java @@ -1,9 +1,10 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.curator; import com.yahoo.vespa.curator.mock.MockCurator; import org.apache.curator.framework.recipes.atomic.DistributedAtomicLong; import org.junit.Test; + import static org.junit.Assert.assertEquals; /** @@ -14,9 +15,9 @@ public class CuratorCounterTest { @Test public void testCounter() throws Exception { DistributedAtomicLong counter = new MockCurator().createAtomicCounter("/mycounter"); - counter.initialize(4l); - assertEquals(4l, counter.get().postValue().longValue()); - assertEquals(5l, counter.increment().postValue().longValue()); + counter.initialize(4L); + assertEquals(4L, counter.get().postValue().longValue()); + assertEquals(5L, counter.increment().postValue().longValue()); } } -- cgit v1.2.3