@Override public PartitionId getPartitionId(String key) { return client.getPartitionId(key); }
public DefaultAsyncDistributedLog(String name, LogClient client, Serializer serializer) { this.name = checkNotNull(name); this.client = checkNotNull(client); this.serializer = checkNotNull(serializer); client.getPartitions().forEach(partition -> { DefaultAsyncDistributedLogPartition<E> logPartition = new DefaultAsyncDistributedLogPartition<>(this, partition, serializer); partitions.put(partition.partitionId().id(), logPartition); sortedPartitions.add(logPartition); }); }
@Override public CompletableFuture<Void> delete() { return client.close(); } }
/** * Returns the partition for the given key. * * @param key the key for which to return the partition * @return the partition for the given key */ default LogSession getPartition(String key) { return getPartition(getPartitionId(key)); }
@Override public CompletableFuture<DistributedLog<E>> buildAsync() { LogProtocol protocol = (LogProtocol) protocol(); return protocol.newClient(managementService.getPartitionService()) .connect() .thenApply(client -> new DefaultAsyncDistributedLog<E>(name, client, serializer()).sync()); } }
@Override public PrimitiveProtocol protocol() { return client.protocol(); }
@Override public CompletableFuture<DistributedLog<E>> buildAsync() { LogProtocol protocol = (LogProtocol) protocol(); return protocol.newClient(managementService.getPartitionService()) .connect() .thenApply(client -> new DefaultAsyncDistributedLog<E>(name, client, serializer()).sync()); } }
@Override public PrimitiveProtocol protocol() { return client.protocol(); }
@Override public PartitionId getPartitionId(Object key) { return client.getPartitionId(BaseEncoding.base16().encode(serializer.encode(key))); } }
public LogProxyClient( String name, PrimitiveType type, PrimitiveProtocol protocol, Class<S> serviceType, ServiceConfig serviceConfig, LogClient client) { super(name, type, protocol, createSessions(name, type, serviceType, serviceConfig, client.getPartitions())); this.client = client; this.serializer = Serializer.using(type.namespace()); }
@Override public CompletableFuture<Void> close() { return client.close(); }
@Override public AsyncDistributedLogPartition<E> getPartition(E entry) { return partitions.get(client.getPartitionId(BaseEncoding.base16().encode(encode(entry))).id()); }
public DefaultAsyncDistributedLog(String name, LogClient client, Serializer serializer) { this.name = checkNotNull(name); this.client = checkNotNull(client); this.serializer = checkNotNull(serializer); client.getPartitions().forEach(partition -> { DefaultAsyncDistributedLogPartition<E> logPartition = new DefaultAsyncDistributedLogPartition<>(this, partition, serializer); partitions.put(partition.partitionId().id(), logPartition); sortedPartitions.add(logPartition); }); }
@Override public CompletableFuture<Void> delete() { return client.close(); } }
@Override public CompletableFuture<Void> produce(E entry) { byte[] bytes = encode(entry); return partitions.get(client.getPartitionId(BaseEncoding.base16().encode(bytes)).id()).produce(bytes); }
@Override public CompletableFuture<Void> close() { return client.close(); }
@Override public AsyncDistributedLogPartition<E> getPartition(E entry) { return partitions.get(client.getPartitionId(BaseEncoding.base16().encode(encode(entry))).id()); }
@Override public CompletableFuture<Void> produce(E entry) { byte[] bytes = encode(entry); return partitions.get(client.getPartitionId(BaseEncoding.base16().encode(bytes)).id()).produce(bytes); }