public abstract class DistributedService<K,S> extends Object implements AutoCloseable
KafkaStreams
processing
nodes comprising the distributed streams application. It dispatches requests to services on local and remote
KafkaStreams processing nodes that contain parts of the data/functionality which is served up. The distribution
is performed given the key and storeName which is registered in the kafka streams application and the following
streams method: KafkaStreams.metadataForKey(String, Object, Serializer)
.Constructor and Description |
---|
DistributedService(org.apache.kafka.streams.KafkaStreams streams,
org.apache.kafka.streams.state.HostInfo localApplicationServer,
String storeName,
org.apache.kafka.common.serialization.Serde<K> keySerde,
Function<? super org.apache.kafka.streams.state.HostInfo,? extends io.grpc.Channel> grpcChannelProvider,
boolean parallel) |
Modifier and Type | Method and Description |
---|---|
protected Collection<S> |
allServices() |
protected Collection<S> |
allServicesForStore() |
protected Stream<S> |
allServicesForStoreStream() |
protected Stream<S> |
allServicesStream() |
void |
close() |
protected org.apache.kafka.common.serialization.Serde<K> |
getKeySerde() |
protected abstract S |
localService(String storeName,
org.apache.kafka.streams.KafkaStreams streams) |
protected abstract S |
remoteServiceGrpcClient(String storeName,
io.grpc.Channel channel,
org.apache.kafka.common.serialization.Serde<K> keySerde) |
protected S |
serviceForKey(K key) |
public DistributedService(org.apache.kafka.streams.KafkaStreams streams, org.apache.kafka.streams.state.HostInfo localApplicationServer, String storeName, org.apache.kafka.common.serialization.Serde<K> keySerde, Function<? super org.apache.kafka.streams.state.HostInfo,? extends io.grpc.Channel> grpcChannelProvider, boolean parallel)
streams
- The KafkaStreams
applicationlocalApplicationServer
- The HostInfo
derived from the
application.server
configuration property of local kafka streams node for the streams application.
This is used to identify requests for local service, bypassing gRPC callsstoreName
- The name of the store registered in the streams application and used for distribution
of keys among kafka streams processing nodes.keySerde
- the Serde
for keys of the service which are also the distribution keys of the
corresponding store.grpcChannelProvider
- A function that establishes gRPC Channel
to a remote service
for the given HostInfo
parameterparallel
- true
if service calls that need to dispatch to many local services in
the cluster are to be performed in parallelprotected org.apache.kafka.common.serialization.Serde<K> getKeySerde()
public void close()
close
in interface AutoCloseable
protected final Collection<S> allServicesForStore()
protected final Collection<S> allServices()
protected abstract S localService(String storeName, org.apache.kafka.streams.KafkaStreams streams)
Copyright © 2020 Red Hat. All rights reserved.