use of io.pravega.segmentstore.server.ContainerEventProcessor in project pravega by pravega.
the class StreamSegmentContainerTests method testEventProcessorWithSerializationError.
/**
* Test the situation in which an EventProcessor gets BufferView.Reader.OutOfBoundsException during deserialization
* of events.
*
* @throws Exception
*/
@Test(timeout = 10000)
public void testEventProcessorWithSerializationError() throws Exception {
@Cleanup TestContext context = createContext();
val container = (StreamSegmentContainer) context.container;
container.startAsync().awaitRunning();
@Cleanup ContainerEventProcessor containerEventProcessor = new ContainerEventProcessorImpl(container, container.metadataStore, TIMEOUT_EVENT_PROCESSOR_ITERATION, TIMEOUT_EVENT_PROCESSOR_ITERATION, this.executorService());
ContainerEventProcessorTests.testEventProcessorWithSerializationError(containerEventProcessor);
}
use of io.pravega.segmentstore.server.ContainerEventProcessor in project pravega by pravega.
the class ContainerEventProcessorTests method testAppendWithFailingSegment.
/**
* Check the behavior of the EventProcessor when there are failures when adding events to the internal Segment.
*
* @throws Exception
*/
@Test(timeout = 10000)
public void testAppendWithFailingSegment() throws Exception {
DirectSegmentAccess faultySegment = mock(SegmentMock.class);
when(faultySegment.append(any(), any(), any())).thenThrow(NullPointerException.class);
SegmentMetadata mockMetadata = mock(SegmentMetadata.class);
when(mockMetadata.getLength()).thenReturn(0L);
when(faultySegment.getInfo()).thenReturn(mockMetadata);
Function<String, CompletableFuture<DirectSegmentAccess>> faultySegmentSupplier = s -> CompletableFuture.completedFuture(faultySegment);
@Cleanup ContainerEventProcessor eventProcessorService = new ContainerEventProcessorImpl(0, faultySegmentSupplier, ITERATION_DELAY, CONTAINER_OPERATION_TIMEOUT, this.executorService());
int maxItemsProcessed = 10;
int maxOutstandingBytes = 4 * 1024 * 1024;
int truncationDataSize = 500;
ContainerEventProcessor.EventProcessorConfig config = new ContainerEventProcessor.EventProcessorConfig(maxItemsProcessed, maxOutstandingBytes, truncationDataSize);
Function<List<BufferView>, CompletableFuture<Void>> doNothing = l -> null;
@Cleanup ContainerEventProcessor.EventProcessor processor = eventProcessorService.forConsumer("testSegmentMax", doNothing, config).get(TIMEOUT_FUTURE.toSeconds(), TimeUnit.SECONDS);
// Verify that the client gets the exception if there is some issue on add().
BufferView event = new ByteArraySegment("Test".getBytes());
AssertExtensions.assertThrows(NullPointerException.class, () -> processor.add(event, TIMEOUT_FUTURE).join());
}
use of io.pravega.segmentstore.server.ContainerEventProcessor in project pravega by pravega.
the class ContainerEventProcessorTests method testEventRejectionOnMaxOutstanding.
/**
* Check that an EventProcessor does not accept any new event once the maximum outstanding bytes has been reached.
*
* @throws Exception
*/
@Test(timeout = TIMEOUT_SUITE_MILLIS)
public void testEventRejectionOnMaxOutstanding() throws Exception {
@Cleanup ContainerEventProcessor eventProcessorService = new ContainerEventProcessorImpl(0, mockSegmentSupplier(), ITERATION_DELAY, CONTAINER_OPERATION_TIMEOUT, this.executorService());
testEventRejectionOnMaxOutstanding(eventProcessorService);
}
use of io.pravega.segmentstore.server.ContainerEventProcessor in project pravega by pravega.
the class ContainerEventProcessorTests method testContainerMaxItemsPerBatchRespected.
/**
* Check that the max number of elements processed per EventProcessor iteration is respected.
*
* @throws Exception
*/
@Test(timeout = TIMEOUT_SUITE_MILLIS)
public void testContainerMaxItemsPerBatchRespected() throws Exception {
@Cleanup ContainerEventProcessor eventProcessorService = new ContainerEventProcessorImpl(0, mockSegmentSupplier(), ITERATION_DELAY, CONTAINER_OPERATION_TIMEOUT, this.executorService());
testContainerMaxItemsPerBatchRespected(eventProcessorService);
}
use of io.pravega.segmentstore.server.ContainerEventProcessor in project pravega by pravega.
the class ContainerEventProcessorTests method testBasicContainerEventProcessor.
/**
* Check the most basic operation of the {@link ContainerEventProcessor} (add and process few events).
*
* @throws Exception
*/
@Test(timeout = 10000)
public void testBasicContainerEventProcessor() throws Exception {
@Cleanup ContainerEventProcessor eventProcessorService = new ContainerEventProcessorImpl(0, mockSegmentSupplier(), ITERATION_DELAY, CONTAINER_OPERATION_TIMEOUT, this.executorService());
testBasicContainerEventProcessor(eventProcessorService);
}
Aggregations