Search in sources :

Example 1 with AsyncDistributedMultiset

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();
    });
}
Also used : DistributedMultisetConfig(io.atomix.core.multiset.DistributedMultisetConfig) DistributedMultisetBuilder(io.atomix.core.multiset.DistributedMultisetBuilder) BaseEncoding(com.google.common.io.BaseEncoding) PrimitiveManagementService(io.atomix.primitive.PrimitiveManagementService) ServiceConfig(io.atomix.primitive.service.ServiceConfig) DistributedMultiset(io.atomix.core.multiset.DistributedMultiset) AsyncDistributedMultiset(io.atomix.core.multiset.AsyncDistributedMultiset) CompletableFuture(java.util.concurrent.CompletableFuture) Serializer(io.atomix.utils.serializer.Serializer) ServiceConfig(io.atomix.primitive.service.ServiceConfig) Serializer(io.atomix.utils.serializer.Serializer)

Aggregations

BaseEncoding (com.google.common.io.BaseEncoding)1 AsyncDistributedMultiset (io.atomix.core.multiset.AsyncDistributedMultiset)1 DistributedMultiset (io.atomix.core.multiset.DistributedMultiset)1 DistributedMultisetBuilder (io.atomix.core.multiset.DistributedMultisetBuilder)1 DistributedMultisetConfig (io.atomix.core.multiset.DistributedMultisetConfig)1 PrimitiveManagementService (io.atomix.primitive.PrimitiveManagementService)1 ServiceConfig (io.atomix.primitive.service.ServiceConfig)1 Serializer (io.atomix.utils.serializer.Serializer)1 CompletableFuture (java.util.concurrent.CompletableFuture)1