Search in sources :

Example 1 with UpdateOrInitSerializer

use of io.pravega.client.state.impl.UpdateOrInitSerializer in project pravega by pravega.

the class ClientFactoryImpl method createStateSynchronizer.

@Override
public <StateT extends Revisioned, UpdateT extends Update<StateT>, InitT extends InitialUpdate<StateT>> StateSynchronizer<StateT> createStateSynchronizer(String streamName, Serializer<UpdateT> updateSerializer, Serializer<InitT> initialSerializer, SynchronizerConfig config) {
    log.info("Creating state synchronizer with stream: {} and configuration: {}", streamName, config);
    Segment segment = new Segment(scope, streamName, 0);
    if (!Futures.getAndHandleExceptions(controller.isSegmentOpen(segment), InvalidStreamException::new)) {
        throw new InvalidStreamException("Segment does not exist: " + segment);
    }
    val serializer = new UpdateOrInitSerializer<>(updateSerializer, initialSerializer);
    return new StateSynchronizerImpl<StateT>(segment, createRevisionedStreamClient(streamName, serializer, config));
}
Also used : lombok.val(lombok.val) UpdateOrInitSerializer(io.pravega.client.state.impl.UpdateOrInitSerializer) Segment(io.pravega.client.segment.impl.Segment) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) StateSynchronizerImpl(io.pravega.client.state.impl.StateSynchronizerImpl)

Aggregations

Segment (io.pravega.client.segment.impl.Segment)1 StateSynchronizerImpl (io.pravega.client.state.impl.StateSynchronizerImpl)1 UpdateOrInitSerializer (io.pravega.client.state.impl.UpdateOrInitSerializer)1 InvalidStreamException (io.pravega.client.stream.InvalidStreamException)1 lombok.val (lombok.val)1