Skip to content

Commit c5f30c8

Browse files
committed
Address jetcd deprecation warnings
1 parent fdb8708 commit c5f30c8

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

uniqueid-etcd/src/main/java/org/lable/oss/uniqueid/etcd/EtcdHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void onCompleted() {
100100
}
101101

102102
@FunctionalInterface
103-
interface OnRelease {
103+
public interface OnRelease {
104104
void cleanUp();
105105
}
106106
}

uniqueid-etcd/src/main/java/org/lable/oss/uniqueid/etcd/RegistryBasedResourceClaim.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.etcd.jetcd.op.CmpTarget;
2828
import io.etcd.jetcd.op.Op;
2929
import io.etcd.jetcd.options.GetOption;
30+
import io.etcd.jetcd.options.OptionsUtil;
3031
import io.etcd.jetcd.options.PutOption;
3132
import io.etcd.jetcd.options.WatchOption;
3233
import org.slf4j.Logger;
@@ -177,9 +178,9 @@ ResourcePair claimResource(Client etcd,
177178

178179
int registrySize = maxGeneratorCount * clusterIds.size();
179180

180-
GetOption getOptions = GetOption.newBuilder()
181+
GetOption getOptions = GetOption.builder()
181182
.withKeysOnly(true)
182-
.withPrefix(REGISTRY_KEY)
183+
.withRange(OptionsUtil.prefixEndOf(REGISTRY_KEY))
183184
.build();
184185
GetResponse get = etcd.getKVClient().get(REGISTRY_KEY, getOptions).get();
185186

@@ -198,7 +199,9 @@ ResourcePair claimResource(Client etcd,
198199
final CountDownLatch latch = new CountDownLatch(1);
199200
Watch.Watcher watcher = etcd.getWatchClient().watch(
200201
REGISTRY_KEY,
201-
WatchOption.newBuilder().withPrefix(REGISTRY_KEY).build(),
202+
WatchOption.builder()
203+
.withRange(OptionsUtil.prefixEndOf(REGISTRY_KEY))
204+
.build(),
202205
watchResponse -> latch.countDown()
203206
);
204207
awaitLatchUnlessItTakesTooLong(latch, giveUpAfter);
@@ -221,7 +224,7 @@ ResourcePair claimResource(Client etcd,
221224
Op.put(
222225
resourcePath,
223226
ByteSequence.from(registryEntry, StandardCharsets.UTF_8),
224-
PutOption.newBuilder().build()
227+
PutOption.builder().build()
225228
)
226229
).commit().get();
227230

uniqueid-etcd/src/main/java/org/lable/oss/uniqueid/etcd/ResourceClaim.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.etcd.jetcd.op.CmpTarget;
2828
import io.etcd.jetcd.op.Op;
2929
import io.etcd.jetcd.options.GetOption;
30+
import io.etcd.jetcd.options.OptionsUtil;
3031
import io.etcd.jetcd.options.PutOption;
3132
import io.etcd.jetcd.options.WatchOption;
3233
import io.etcd.jetcd.support.CloseableClient;
@@ -242,9 +243,9 @@ ResourcePair claimResource(Client etcd, int maxGeneratorCount, List<Integer> clu
242243

243244
int poolSize = maxGeneratorCount * clusterIds.size();
244245

245-
GetOption getOptions = GetOption.newBuilder()
246+
GetOption getOptions = GetOption.builder()
246247
.withKeysOnly(true)
247-
.withPrefix(POOL_KEY)
248+
.withRange(OptionsUtil.prefixEndOf(POOL_KEY))
248249
.build();
249250
GetResponse get = etcd.getKVClient().get(POOL_KEY, getOptions).get();
250251

@@ -258,7 +259,10 @@ ResourcePair claimResource(Client etcd, int maxGeneratorCount, List<Integer> clu
258259
final CountDownLatch latch = new CountDownLatch(1);
259260
Watch.Watcher watcher = etcd.getWatchClient().watch(
260261
POOL_KEY,
261-
WatchOption.newBuilder().withPrefix(POOL_KEY).build(),
262+
WatchOption
263+
.builder()
264+
.withRange(OptionsUtil.prefixEndOf(POOL_KEY))
265+
.build(),
262266
watchResponse -> latch.countDown()
263267
);
264268
awaitLatchUnlessItTakesTooLong(latch, giveUpAfter);
@@ -281,7 +285,7 @@ ResourcePair claimResource(Client etcd, int maxGeneratorCount, List<Integer> clu
281285
Op.put(
282286
resourcePath,
283287
ByteSequence.EMPTY,
284-
PutOption.newBuilder().withLeaseId(leaseId).build()
288+
PutOption.builder().withLeaseId(leaseId).build()
285289
)
286290
).commit().get();
287291

uniqueid-etcd/src/test/java/org/lable/oss/uniqueid/etcd/EtcdTestCluster.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void evaluate() throws Throwable {
6969
.withClusterName(clusterName)
7070
.withNodes(nodes)
7171
.withSsl(ssl)
72+
.withMountedDataDirectory(false)
7273
.build();
7374

7475
cluster.start();

0 commit comments

Comments
 (0)