Search in sources :

Example 1 with AtomicDocumentTree

use of io.atomix.core.tree.AtomicDocumentTree 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

AsyncAtomicDocumentTree (io.atomix.core.tree.AsyncAtomicDocumentTree)1 AtomicDocumentTree (io.atomix.core.tree.AtomicDocumentTree)1 AtomicDocumentTreeBuilder (io.atomix.core.tree.AtomicDocumentTreeBuilder)1 AtomicDocumentTreeConfig (io.atomix.core.tree.AtomicDocumentTreeConfig)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