use of io.atomix.core.multiset.AsyncDistributedMultiset in project atomix by atomix.
the class DefaultDistributedMultisetBuilder method buildAsync.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<DistributedMultiset<E>> buildAsync() {
return newProxy(DistributedMultisetService.class, new ServiceConfig()).thenCompose(proxy -> new DistributedMultisetProxy(proxy, managementService.getPrimitiveRegistry()).connect()).thenApply(rawList -> {
Serializer serializer = serializer();
AsyncDistributedMultiset<E> list = new TranscodingAsyncDistributedMultiset<>(rawList, element -> BaseEncoding.base16().encode(serializer.encode(element)), string -> serializer.decode(BaseEncoding.base16().decode(string)));
if (config.getCacheConfig().isEnabled()) {
list = new CachingAsyncDistributedMultiset<>(list, config.getCacheConfig());
}
if (config.isReadOnly()) {
list = new UnmodifiableAsyncDistributedMultiset<>(list);
}
return list.sync();
});
}
Aggregations