Search in sources :

Example 11 with ServiceConfig

use of io.atomix.primitive.service.ServiceConfig in project atomix by atomix.

the class DefaultAtomicDocumentTreeBuilder method buildAsync.

@Override
@SuppressWarnings("unchecked")
public CompletableFuture<AtomicDocumentTree<V>> buildAsync() {
    return newProxy(DocumentTreeService.class, new ServiceConfig()).thenCompose(proxy -> new AtomicDocumentTreeProxy(proxy, managementService.getPrimitiveRegistry()).connect()).thenApply(treeProxy -> {
        Serializer serializer = serializer();
        AsyncAtomicDocumentTree<V> tree = new TranscodingAsyncAtomicDocumentTree<>(treeProxy, key -> serializer.encode(key), bytes -> serializer.decode(bytes));
        if (config.getCacheConfig().isEnabled()) {
            tree = new CachingAsyncAtomicDocumentTree<V>(tree, config.getCacheConfig());
        }
        return tree.sync();
    });
}
Also used : AtomicDocumentTreeConfig(io.atomix.core.tree.AtomicDocumentTreeConfig) PrimitiveManagementService(io.atomix.primitive.PrimitiveManagementService) ServiceConfig(io.atomix.primitive.service.ServiceConfig) AsyncAtomicDocumentTree(io.atomix.core.tree.AsyncAtomicDocumentTree) AtomicDocumentTree(io.atomix.core.tree.AtomicDocumentTree) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicDocumentTreeBuilder(io.atomix.core.tree.AtomicDocumentTreeBuilder) Serializer(io.atomix.utils.serializer.Serializer) ServiceConfig(io.atomix.primitive.service.ServiceConfig) Serializer(io.atomix.utils.serializer.Serializer)

Aggregations

ServiceConfig (io.atomix.primitive.service.ServiceConfig)11 Serializer (io.atomix.utils.serializer.Serializer)8 CompletableFuture (java.util.concurrent.CompletableFuture)8 PrimitiveManagementService (io.atomix.primitive.PrimitiveManagementService)7 BaseEncoding (com.google.common.io.BaseEncoding)5 ProxyClient (io.atomix.primitive.proxy.ProxyClient)4 PrimitiveType (io.atomix.primitive.PrimitiveType)3 PartitionService (io.atomix.primitive.partition.PartitionService)3 PrimitiveProtocol (io.atomix.primitive.protocol.PrimitiveProtocol)3 ProxyProtocol (io.atomix.primitive.protocol.ProxyProtocol)3 Collection (java.util.Collection)3 Collectors (java.util.stream.Collectors)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 AsyncLeaderElector (io.atomix.core.election.AsyncLeaderElector)1 LeaderElector (io.atomix.core.election.LeaderElector)1 LeaderElectorBuilder (io.atomix.core.election.LeaderElectorBuilder)1 LeaderElectorConfig (io.atomix.core.election.LeaderElectorConfig)1 AsyncDistributedList (io.atomix.core.list.AsyncDistributedList)1 DistributedList (io.atomix.core.list.DistributedList)1