Search in sources :

Example 1 with AtomicCounterMap

use of io.atomix.core.map.AtomicCounterMap in project atomix by atomix.

the class AtomicCounterMapProxyBuilder method buildAsync.

@Override
@SuppressWarnings("unchecked")
public CompletableFuture<AtomicCounterMap<K>> buildAsync() {
    PrimitiveProtocol protocol = protocol();
    return managementService.getPartitionService().getPartitionGroup(protocol).getPartition(name()).getPrimitiveClient().newProxy(name(), primitiveType(), protocol).connect().thenApply(proxy -> {
        AtomicCounterMapProxy rawMap = new AtomicCounterMapProxy(proxy);
        Serializer serializer = serializer();
        return new TranscodingAsyncAtomicCounterMap<K, String>(rawMap, key -> BaseEncoding.base16().encode(serializer.encode(key)), string -> serializer.decode(BaseEncoding.base16().decode(string))).sync();
    });
}
Also used : BaseEncoding(com.google.common.io.BaseEncoding) PrimitiveManagementService(io.atomix.primitive.PrimitiveManagementService) PrimitiveProtocol(io.atomix.primitive.PrimitiveProtocol) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) CompletableFuture(java.util.concurrent.CompletableFuture) Serializer(io.atomix.utils.serializer.Serializer) AtomicCounterMap(io.atomix.core.map.AtomicCounterMap) AtomicCounterMapBuilder(io.atomix.core.map.AtomicCounterMapBuilder) PrimitiveProtocol(io.atomix.primitive.PrimitiveProtocol) Serializer(io.atomix.utils.serializer.Serializer)

Aggregations

Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 BaseEncoding (com.google.common.io.BaseEncoding)1 AtomicCounterMap (io.atomix.core.map.AtomicCounterMap)1 AtomicCounterMapBuilder (io.atomix.core.map.AtomicCounterMapBuilder)1 PrimitiveManagementService (io.atomix.primitive.PrimitiveManagementService)1 PrimitiveProtocol (io.atomix.primitive.PrimitiveProtocol)1 Serializer (io.atomix.utils.serializer.Serializer)1 CompletableFuture (java.util.concurrent.CompletableFuture)1