use of io.camunda.zeebe.logstreams.log.LogStreamReader in project zeebe-process-test by camunda.
the class EngineFactory method create.
public static ZeebeTestEngine create(final int port) {
final int partitionId = 1;
final int partitionCount = 1;
final ControlledActorClock clock = createActorClock();
final ActorScheduler scheduler = createAndStartActorScheduler(clock);
final InMemoryLogStorage logStorage = new InMemoryLogStorage();
final LogStream logStream = createLogStream(logStorage, scheduler, partitionId);
final SubscriptionCommandSenderFactory subscriptionCommandSenderFactory = new SubscriptionCommandSenderFactory(logStream.newLogStreamRecordWriter().join(), partitionId);
final GrpcToLogStreamGateway gateway = new GrpcToLogStreamGateway(logStream.newLogStreamRecordWriter().join(), partitionId, partitionCount, port);
final Server grpcServer = ServerBuilder.forPort(port).addService(gateway).build();
final GrpcResponseWriter grpcResponseWriter = new GrpcResponseWriter(gateway);
final ZeebeDb<ZbColumnFamilies> zeebeDb = createDatabase();
final EngineStateMonitor engineStateMonitor = new EngineStateMonitor(logStorage, logStream.newLogStreamReader().join());
final StreamProcessor streamProcessor = createStreamProcessor(logStream, zeebeDb, scheduler, grpcResponseWriter, engineStateMonitor, partitionCount, subscriptionCommandSenderFactory);
final LogStreamReader reader = logStream.newLogStreamReader().join();
final RecordStreamSourceImpl recordStream = new RecordStreamSourceImpl(reader, partitionId);
return new InMemoryEngine(grpcServer, streamProcessor, gateway, zeebeDb, logStream, scheduler, recordStream, clock, engineStateMonitor);
}
use of io.camunda.zeebe.logstreams.log.LogStreamReader in project zeebe by camunda.
the class TestStreams method events.
public Stream<LoggedEvent> events(final String logName) {
final SynchronousLogStream logStream = getLogStream(logName);
final LogStreamReader reader = logStream.newLogStreamReader();
closeables.manage(reader);
reader.seekToFirstEvent();
final Iterable<LoggedEvent> iterable = () -> reader;
return StreamSupport.stream(iterable.spliterator(), false);
}
use of io.camunda.zeebe.logstreams.log.LogStreamReader in project zeebe by camunda.
the class LogStreamImpl method createLogStreamReader.
private LogStreamReader createLogStreamReader() {
final LogStreamReader newReader = new LogStreamReaderImpl(logStorage.newReader());
readers.add(newReader);
return newReader;
}
use of io.camunda.zeebe.logstreams.log.LogStreamReader in project zeebe by camunda.
the class LogStreamReaderTest method shouldNotHaveNextIfReaderIsClosed.
@Test
public void shouldNotHaveNextIfReaderIsClosed() {
// given
final LogStreamReader reader = logStreamRule.getLogStreamReader();
reader.close();
// when - then
assertThat(reader.hasNext()).isFalse();
}
use of io.camunda.zeebe.logstreams.log.LogStreamReader in project zeebe by camunda.
the class LogStreamReaderTest method shouldThrowExceptionIfReaderClosedOnNext.
@Test
public void shouldThrowExceptionIfReaderClosedOnNext() {
// given
final LogStreamReader reader = logStreamRule.getLogStreamReader();
reader.close();
// when - then
assertThatCode(reader::next).isInstanceOf(NoSuchElementException.class);
}
Aggregations