Search in sources :

Example 1 with ConsistentTreeMap

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

the class ConsistentTreeMapProxyBuilder method buildAsync.

@Override
@SuppressWarnings("unchecked")
public CompletableFuture<ConsistentTreeMap<V>> buildAsync() {
    PrimitiveProtocol protocol = protocol();
    return managementService.getPartitionService().getPartitionGroup(protocol).getPartition(name()).getPrimitiveClient().newProxy(name(), primitiveType(), protocol).connect().thenApply(proxy -> {
        ConsistentTreeMapProxy rawMap = new ConsistentTreeMapProxy(proxy);
        Serializer serializer = serializer();
        return new TranscodingAsyncConsistentTreeMap<V, byte[]>(rawMap, value -> value == null ? null : serializer.encode(value), bytes -> serializer.decode(bytes)).sync();
    });
}
Also used : PrimitiveManagementService(io.atomix.primitive.PrimitiveManagementService) PrimitiveProtocol(io.atomix.primitive.PrimitiveProtocol) ConsistentTreeMapBuilder(io.atomix.core.map.ConsistentTreeMapBuilder) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) CompletableFuture(java.util.concurrent.CompletableFuture) Serializer(io.atomix.utils.serializer.Serializer) AsyncConsistentTreeMap(io.atomix.core.map.AsyncConsistentTreeMap) ConsistentTreeMap(io.atomix.core.map.ConsistentTreeMap) PrimitiveProtocol(io.atomix.primitive.PrimitiveProtocol) Serializer(io.atomix.utils.serializer.Serializer)

Aggregations

Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 AsyncConsistentTreeMap (io.atomix.core.map.AsyncConsistentTreeMap)1 ConsistentTreeMap (io.atomix.core.map.ConsistentTreeMap)1 ConsistentTreeMapBuilder (io.atomix.core.map.ConsistentTreeMapBuilder)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