use of io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment in project pravega by pravega.
the class FailingRequestProcessorTest method testEverythingThrows.
@Test
public void testEverythingThrows() {
assertThrows(IllegalStateException.class, () -> rp.hello(new Hello(0, 0)));
assertThrows(IllegalStateException.class, () -> rp.setupAppend(new SetupAppend(0, null, "", "")));
assertThrows(IllegalStateException.class, () -> rp.append(new Append("", null, 0, EMPTY_EVENT, 0)));
assertThrows(IllegalStateException.class, () -> rp.readSegment(new ReadSegment("", 0, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.updateSegmentAttribute(new UpdateSegmentAttribute(0, "", null, 0, 0, "")));
assertThrows(IllegalStateException.class, () -> rp.getSegmentAttribute(new GetSegmentAttribute(0, "", null, "")));
assertThrows(IllegalStateException.class, () -> rp.getStreamSegmentInfo(new WireCommands.GetStreamSegmentInfo(0, "", "")));
assertThrows(IllegalStateException.class, () -> rp.createSegment(new CreateSegment(0, "", (byte) 0, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.updateSegmentPolicy(new UpdateSegmentPolicy(0, "", (byte) 0, 0, "")));
assertThrows(IllegalStateException.class, () -> rp.createTableSegment(new CreateTableSegment(0, "", false, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.deleteTableSegment(new DeleteTableSegment(0, "", false, "")));
assertThrows(IllegalStateException.class, () -> rp.updateTableEntries(new UpdateTableEntries(0, "", "", null, 0)));
assertThrows(IllegalStateException.class, () -> rp.removeTableKeys(new RemoveTableKeys(0, "", "", null, 0)));
assertThrows(IllegalStateException.class, () -> rp.readTable(new ReadTable(0, "", "", null)));
assertThrows(IllegalStateException.class, () -> rp.readTableKeys(new ReadTableKeys(0, "", "", 0, null)));
assertThrows(IllegalStateException.class, () -> rp.readTableEntries(new ReadTableEntries(0, "", "", 0, null)));
assertThrows(IllegalStateException.class, () -> rp.mergeSegments(new MergeSegments(0, "", "", "")));
assertThrows(IllegalStateException.class, () -> rp.sealSegment(new SealSegment(0, "", "")));
assertThrows(IllegalStateException.class, () -> rp.truncateSegment(new TruncateSegment(0, "", 0, "")));
assertThrows(IllegalStateException.class, () -> rp.deleteSegment(new DeleteSegment(0, "", "")));
assertThrows(IllegalStateException.class, () -> rp.readTableEntries(new ReadTableEntries(0, "", "", 0, null)));
assertThrows(IllegalStateException.class, () -> rp.createTableSegment(new CreateTableSegment(0, "", false, 0, "", 0)));
assertThrows(IllegalStateException.class, () -> rp.readTableEntriesDelta(new ReadTableEntriesDelta(0, "", "", 0, 0)));
assertThrows(IllegalStateException.class, () -> rp.createTransientSegment(new CreateTransientSegment(0, new UUID(0, 0), "", "")));
assertThrows(IllegalStateException.class, () -> rp.connectionDropped());
}
use of io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment in project pravega by pravega.
the class AppendProcessorTest method testTransientSegmentCleanupOnClose.
// Verifies that the AppendProcessor performs a clean-up call on each Transient Segment it is tracking.
@Test
public void testTransientSegmentCleanupOnClose() {
String parentSegmentName = "scope/stream/parentSegment";
StreamSegmentStore store = mock(StreamSegmentStore.class);
ServerConnection connection = mock(ServerConnection.class);
ConnectionTracker tracker = mock(ConnectionTracker.class);
val mockedRecorder = Mockito.mock(SegmentStatsRecorder.class);
@Cleanup AppendProcessor processor = AppendProcessor.defaultBuilder().store(store).connection(new TrackedConnection(connection, tracker)).statsRecorder(mockedRecorder).build();
interceptCreateTransient(store, parentSegmentName);
int transientSegments = 10;
for (int i = 1; i <= transientSegments; i++) {
UUID writerId = new UUID(0, i);
CreateTransientSegment createTransientSegment = new CreateTransientSegment(i, writerId, parentSegmentName, "");
processor.createTransientSegment(createTransientSegment);
}
verify(connection, times(transientSegments)).send(any(WireCommands.SegmentCreated.class));
processor.close();
// For each Transient Segment we created, make sure that the StreamSegmentStore calls deleteStreamSegment on them.
verify(store, times(transientSegments)).deleteStreamSegment(any(), any());
// Make sure the connection has also been properly closed.
verify(connection).close();
}
use of io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment in project pravega by pravega.
the class LargeEventWriterTest method testThrownErrors.
@Test(timeout = 5000)
public void testThrownErrors() throws ConnectionFailedException {
Segment segment = Segment.fromScopedName("foo/bar/1");
MockConnectionFactoryImpl connectionFactory = new MockConnectionFactoryImpl();
MockController controller = new MockController("localhost", 0, connectionFactory, false);
ClientConnection connection = Mockito.mock(ClientConnection.class);
PravegaNodeUri location = new PravegaNodeUri("localhost", 0);
connectionFactory.provideConnection(location, connection);
EmptyTokenProviderImpl tokenProvider = new EmptyTokenProviderImpl();
EventWriterConfig config = EventWriterConfig.builder().enableLargeEvents(true).build();
ArrayList<ByteBuffer> events = new ArrayList<>();
events.add(ByteBuffer.allocate(1));
answerRequest(connectionFactory, connection, location, CreateTransientSegment.class, r -> new NoSuchSegment(r.getRequestId(), "foo/bar/1", "stacktrace", -1));
AssertExtensions.assertThrows(NoSuchSegmentException.class, () -> {
LargeEventWriter writer = new LargeEventWriter(writerId, controller, connectionFactory);
writer.writeLargeEvent(segment, events, tokenProvider, config);
});
answerRequest(connectionFactory, connection, location, CreateTransientSegment.class, r -> new SegmentIsSealed(r.getRequestId(), "foo/bar/1", "stacktrace", -1));
AssertExtensions.assertThrows(SegmentSealedException.class, () -> {
LargeEventWriter writer = new LargeEventWriter(writerId, controller, connectionFactory);
writer.writeLargeEvent(segment, events, tokenProvider, config);
});
answerRequest(connectionFactory, connection, location, CreateTransientSegment.class, r -> new OperationUnsupported(r.getRequestId(), "CreateTransientSegment", "stacktrace"));
AssertExtensions.assertThrows(UnsupportedOperationException.class, () -> {
LargeEventWriter writer = new LargeEventWriter(writerId, controller, connectionFactory);
writer.writeLargeEvent(segment, events, tokenProvider, config);
});
}
Aggregations