Package io.pravega.client.stream.impl
Class ClientFactoryImpl
- java.lang.Object
-
- io.pravega.client.stream.impl.AbstractClientFactoryImpl
-
- io.pravega.client.stream.impl.ClientFactoryImpl
-
- All Implemented Interfaces:
EventStreamClientFactory,SynchronizerClientFactory,java.lang.AutoCloseable
public class ClientFactoryImpl extends AbstractClientFactoryImpl implements EventStreamClientFactory, SynchronizerClientFactory
-
-
Field Summary
-
Fields inherited from class io.pravega.client.stream.impl.AbstractClientFactoryImpl
connectionPool, controller, scope
-
-
Constructor Summary
Constructors Constructor Description ClientFactoryImpl(java.lang.String scope, Controller controller, ClientConfig config)Creates a new instance of ClientFactory class.ClientFactoryImpl(java.lang.String scope, Controller controller, ConnectionFactory connectionFactory)Creates a new instance of the ClientFactory class.ClientFactoryImpl(java.lang.String scope, Controller controller, ConnectionPool pool)Creates a new instance of the ClientFactory class.ClientFactoryImpl(java.lang.String scope, Controller controller, ConnectionPool connectionPool, SegmentInputStreamFactory inFactory, SegmentOutputStreamFactory outFactory, ConditionalOutputStreamFactory condFactory, SegmentMetadataClientFactory metaFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the client factory.<T> EventStreamWriter<T>createEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)Creates a new writer that can write to the specified stream.<T> EventStreamWriter<T>createEventWriter(java.lang.String writerId, java.lang.String streamName, Serializer<T> s, EventWriterConfig config)Creates a new writer that can write to the specified stream.<T> EventStreamReader<T>createReader(java.lang.String readerId, java.lang.String readerGroup, Serializer<T> s, ReaderConfig config)Creates (or recreates) a new reader that is part of aReaderGroup.<T> EventStreamReader<T>createReader(java.lang.String readerId, java.lang.String readerGroup, Serializer<T> s, ReaderConfig config, java.util.function.Supplier<java.lang.Long> nanoTime, java.util.function.Supplier<java.lang.Long> milliTime)<T> RevisionedStreamClient<T>createRevisionedStreamClient(java.lang.String streamName, Serializer<T> serializer, SynchronizerConfig config)Creates a new RevisionedStreamClient that will work with the specified stream.<StateT extends Revisioned,UpdateT extends Update<StateT>,InitT extends InitialUpdate<StateT>>
StateSynchronizer<StateT>createStateSynchronizer(java.lang.String streamName, Serializer<UpdateT> updateSerializer, Serializer<InitT> initialSerializer, SynchronizerConfig config)Creates a new StateSynchronizer that will work on the specified stream.<T> TransactionalEventStreamWriter<T>createTransactionalEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)Creates a new transactional writer that can write to the specified stream atomically.<T> TransactionalEventStreamWriter<T>createTransactionalEventWriter(java.lang.String writerId, java.lang.String streamName, Serializer<T> s, EventWriterConfig config)Creates a new transactional writer that can write to the specified stream atomically.-
Methods inherited from class io.pravega.client.stream.impl.AbstractClientFactoryImpl
getConnectionPool, getController
-
-
-
-
Constructor Detail
-
ClientFactoryImpl
public ClientFactoryImpl(java.lang.String scope, Controller controller, ClientConfig config)Creates a new instance of ClientFactory class. Note: Controller is closed whenclose()is invoked.- Parameters:
scope- The scope string.controller- The reference to Controller.config- The client config.
-
ClientFactoryImpl
public ClientFactoryImpl(java.lang.String scope, Controller controller, ConnectionFactory connectionFactory)Creates a new instance of the ClientFactory class. Note: ConnectionFactory and Controller is closed whenclose()is invoked.- Parameters:
scope- The scope string.controller- The reference to Controller.connectionFactory- The reference to Connection Factory impl.
-
ClientFactoryImpl
public ClientFactoryImpl(java.lang.String scope, Controller controller, ConnectionPool pool)Creates a new instance of the ClientFactory class. Note: ConnectionFactory and Controller is closed whenclose()is invoked.- Parameters:
scope- The scope string.controller- The reference to Controller.pool- The connection pool
-
ClientFactoryImpl
public ClientFactoryImpl(java.lang.String scope, Controller controller, ConnectionPool connectionPool, SegmentInputStreamFactory inFactory, SegmentOutputStreamFactory outFactory, ConditionalOutputStreamFactory condFactory, SegmentMetadataClientFactory metaFactory)
-
-
Method Detail
-
createEventWriter
public <T> EventStreamWriter<T> createEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
Description copied from interface:EventStreamClientFactoryCreates a new writer that can write to the specified stream. Uses an autogenerated writerId to refer to this writer.- Specified by:
createEventWriterin interfaceEventStreamClientFactory- Type Parameters:
T- The type of events.- Parameters:
streamName- The name of the stream to write to.s- The Serializer.config- The writer configuration.- Returns:
- Newly created writer object
-
createEventWriter
public <T> EventStreamWriter<T> createEventWriter(java.lang.String writerId, java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
Description copied from interface:EventStreamClientFactoryCreates a new writer that can write to the specified stream.- Specified by:
createEventWriterin interfaceEventStreamClientFactory- Type Parameters:
T- The type of events.- Parameters:
writerId- An name which identifies this writer.streamName- The name of the stream to write to.s- The Serializer.config- The writer configuration.- Returns:
- Newly created writer object
-
createTransactionalEventWriter
public <T> TransactionalEventStreamWriter<T> createTransactionalEventWriter(java.lang.String writerId, java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
Description copied from interface:EventStreamClientFactoryCreates a new transactional writer that can write to the specified stream atomically.- Specified by:
createTransactionalEventWriterin interfaceEventStreamClientFactory- Type Parameters:
T- The type of events.- Parameters:
writerId- An name which identifies this writer.streamName- The name of the stream to write to.s- The Serializer.config- The writer configuration.- Returns:
- Newly created writer object
-
createTransactionalEventWriter
public <T> TransactionalEventStreamWriter<T> createTransactionalEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
Description copied from interface:EventStreamClientFactoryCreates a new transactional writer that can write to the specified stream atomically. Uses an autogenerated writerId to refer to this writer.- Specified by:
createTransactionalEventWriterin interfaceEventStreamClientFactory- Type Parameters:
T- The type of events.- Parameters:
streamName- The name of the stream to write to.s- The Serializer.config- The writer configuration.- Returns:
- Newly created writer object
-
createReader
public <T> EventStreamReader<T> createReader(java.lang.String readerId, java.lang.String readerGroup, Serializer<T> s, ReaderConfig config)
Description copied from interface:EventStreamClientFactoryCreates (or recreates) a new reader that is part of aReaderGroup. The reader will join the group and the members of the group will automatically rebalance among themselves. In the event that the reader dies, the methodReaderGroup.readerOffline(String, Position)should be called, passing the last position of the reader (Usually done by storing the position along with the output when it is processed.) Which will trigger redistribute the events among the remaining readers.Note that calling reader offline while the reader is still online may result in multiple readers within the group receiving the same events.
- Specified by:
createReaderin interfaceEventStreamClientFactory- Type Parameters:
T- The type of events.- Parameters:
readerId- A unique name (within the group) for this reader.readerGroup- The name of the group to join.s- The serializer for events.config- The reader's configuration.- Returns:
- Newly created reader object that is a part of reader group
-
createReader
public <T> EventStreamReader<T> createReader(java.lang.String readerId, java.lang.String readerGroup, Serializer<T> s, ReaderConfig config, java.util.function.Supplier<java.lang.Long> nanoTime, java.util.function.Supplier<java.lang.Long> milliTime)
-
createRevisionedStreamClient
public <T> RevisionedStreamClient<T> createRevisionedStreamClient(java.lang.String streamName, Serializer<T> serializer, SynchronizerConfig config)
Description copied from interface:SynchronizerClientFactoryCreates a new RevisionedStreamClient that will work with the specified stream.- Specified by:
createRevisionedStreamClientin interfaceSynchronizerClientFactory- Type Parameters:
T- The type of events.- Parameters:
streamName- The name of the stream for the synchronizer.serializer- The serializer for updates.config- The client configuration.- Returns:
- Revisioned stream client.
-
createStateSynchronizer
public <StateT extends Revisioned,UpdateT extends Update<StateT>,InitT extends InitialUpdate<StateT>> StateSynchronizer<StateT> createStateSynchronizer(java.lang.String streamName, Serializer<UpdateT> updateSerializer, Serializer<InitT> initialSerializer, SynchronizerConfig config)
Description copied from interface:SynchronizerClientFactoryCreates a new StateSynchronizer that will work on the specified stream.- Specified by:
createStateSynchronizerin interfaceSynchronizerClientFactory- Type Parameters:
StateT- The type of the state being synchronized.UpdateT- The type of the updates being written.InitT- The type of the initial update used.- Parameters:
streamName- The name of the stream for the synchronizer.updateSerializer- The serializer for updates.initialSerializer- The serializer for the initial update.config- The synchronizer configuration.- Returns:
- Newly created StateSynchronizer that will work on the given stream.
-
close
public void close()
Description copied from interface:EventStreamClientFactoryCloses the client factory. This will close any connections created through it.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceEventStreamClientFactory- Specified by:
closein interfaceSynchronizerClientFactory- See Also:
AutoCloseable.close()
-
-