use of io.atomix.primitive.PrimitiveRegistry in project atomix by atomix.
the class CorePrimitiveRegistry method start.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<PrimitiveRegistry> start() {
ProxyProtocol protocol = partitionService.getSystemPartitionGroup().newProtocol();
ProxyClient proxy = protocol.newProxy("primitives", AtomicMapType.instance(), AtomicMapService.class, new ServiceConfig(), partitionService);
return proxy.connect().thenApply(v -> {
AtomicMapProxy mapProxy = new AtomicMapProxy(proxy, this);
primitives = new TranscodingAsyncAtomicMap<>(mapProxy, key -> key, key -> key, value -> value != null ? SERIALIZER.encode(value) : null, value -> value != null ? SERIALIZER.decode(value) : null);
started.set(true);
return this;
});
}
use of io.atomix.primitive.PrimitiveRegistry in project atomix by atomix.
the class RaftTest method createPrimitive.
/**
* Creates a new primitive instance.
*/
private TestPrimitive createPrimitive(RaftClient client, ReadConsistency consistency) throws Exception {
SessionClient partition = createSession(client, consistency);
ProxyClient<TestPrimitiveService> proxy = new DefaultProxyClient<>("test", TestPrimitiveType.INSTANCE, MultiRaftProtocol.builder().build(), TestPrimitiveService.class, Collections.singletonList(partition), (key, partitions) -> partitions.get(0));
PrimitiveRegistry registry = mock(PrimitiveRegistry.class);
when(registry.createPrimitive(any(String.class), any(PrimitiveType.class))).thenReturn(CompletableFuture.completedFuture(new PrimitiveInfo("raft-test", TestPrimitiveType.INSTANCE)));
when(registry.deletePrimitive(any(String.class))).thenReturn(CompletableFuture.completedFuture(null));
return new TestPrimitiveImpl(proxy, registry);
}
Aggregations