use of io.atomix.primitive.protocol.PrimitiveProtocol in project atomix by atomix.
the class CoreTransactionService method start.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<TransactionService> start() {
PrimitiveProtocol protocol = managementService.getPartitionService().getSystemPartitionGroup().newProtocol();
return AtomicMapType.<TransactionId, TransactionInfo>instance().newBuilder("atomix-transactions", new AtomicMapConfig(), managementService).withSerializer(SERIALIZER).withProtocol((ProxyProtocol) protocol).withCacheEnabled().buildAsync().thenApply(transactions -> {
this.transactions = transactions.async();
managementService.getMembershipService().addListener(clusterEventListener);
LOGGER.info("Started");
started.set(true);
return this;
});
}
use of io.atomix.primitive.protocol.PrimitiveProtocol in project atomix by atomix.
the class DefaultDistributedSetBuilder method buildAsync.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<DistributedSet<E>> buildAsync() {
PrimitiveProtocol protocol = protocol();
if (protocol instanceof GossipProtocol) {
if (protocol instanceof SetProtocol) {
return managementService.getPrimitiveCache().getPrimitive(name, () -> CompletableFuture.completedFuture(((SetProtocol) protocol).<E>newSetDelegate(name, serializer(), managementService)).thenApply(set -> new GossipDistributedSet<>(name, protocol, set))).thenApply(AsyncDistributedSet::sync);
} else {
return Futures.exceptionalFuture(new UnsupportedOperationException("Sets are not supported by the provided gossip protocol"));
}
} else {
return newProxy(DistributedSetService.class, new ServiceConfig()).thenCompose(proxy -> new DistributedSetProxy((ProxyClient) proxy, managementService.getPrimitiveRegistry()).connect()).thenApply(rawSet -> {
Serializer serializer = serializer();
AsyncDistributedSet<E> set = new TranscodingAsyncDistributedSet<>(rawSet, element -> BaseEncoding.base16().encode(serializer.encode(element)), string -> serializer.decode(BaseEncoding.base16().decode(string)));
if (config.getCacheConfig().isEnabled()) {
set = new CachingAsyncDistributedSet<>(set, config.getCacheConfig());
}
if (config.isReadOnly()) {
set = new UnmodifiableAsyncDistributedSet<>(set);
}
return set.sync();
});
}
}
Aggregations