Search in sources :

Example 6 with CreateTransientSegment

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());
}
Also used : ReadTableKeys(io.pravega.shared.protocol.netty.WireCommands.ReadTableKeys) DeleteTableSegment(io.pravega.shared.protocol.netty.WireCommands.DeleteTableSegment) UpdateSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentAttribute) ReadSegment(io.pravega.shared.protocol.netty.WireCommands.ReadSegment) DeleteSegment(io.pravega.shared.protocol.netty.WireCommands.DeleteSegment) ReadTable(io.pravega.shared.protocol.netty.WireCommands.ReadTable) ReadTableEntriesDelta(io.pravega.shared.protocol.netty.WireCommands.ReadTableEntriesDelta) CreateTransientSegment(io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment) UpdateSegmentPolicy(io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentPolicy) SetupAppend(io.pravega.shared.protocol.netty.WireCommands.SetupAppend) Hello(io.pravega.shared.protocol.netty.WireCommands.Hello) CreateTableSegment(io.pravega.shared.protocol.netty.WireCommands.CreateTableSegment) MergeSegments(io.pravega.shared.protocol.netty.WireCommands.MergeSegments) SetupAppend(io.pravega.shared.protocol.netty.WireCommands.SetupAppend) ReadTableEntries(io.pravega.shared.protocol.netty.WireCommands.ReadTableEntries) TruncateSegment(io.pravega.shared.protocol.netty.WireCommands.TruncateSegment) GetSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute) RemoveTableKeys(io.pravega.shared.protocol.netty.WireCommands.RemoveTableKeys) UpdateTableEntries(io.pravega.shared.protocol.netty.WireCommands.UpdateTableEntries) UUID(java.util.UUID) CreateSegment(io.pravega.shared.protocol.netty.WireCommands.CreateSegment) SealSegment(io.pravega.shared.protocol.netty.WireCommands.SealSegment) Test(org.junit.Test)

Example 7 with CreateTransientSegment

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();
}
Also used : lombok.val(lombok.val) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CreateTransientSegment(io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment) UUID(java.util.UUID) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 8 with CreateTransientSegment

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);
    });
}
Also used : OperationUnsupported(io.pravega.shared.protocol.netty.WireCommands.OperationUnsupported) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Segment(io.pravega.client.segment.impl.Segment) NoSuchSegment(io.pravega.shared.protocol.netty.WireCommands.NoSuchSegment) CreateTransientSegment(io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment) EmptyTokenProviderImpl(io.pravega.client.security.auth.EmptyTokenProviderImpl) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) EventWriterConfig(io.pravega.client.stream.EventWriterConfig) SegmentIsSealed(io.pravega.shared.protocol.netty.WireCommands.SegmentIsSealed) MockConnectionFactoryImpl(io.pravega.client.stream.mock.MockConnectionFactoryImpl) MockController(io.pravega.client.stream.mock.MockController) ClientConnection(io.pravega.client.connection.impl.ClientConnection) NoSuchSegment(io.pravega.shared.protocol.netty.WireCommands.NoSuchSegment) Test(org.junit.Test)

Aggregations

CreateTransientSegment (io.pravega.shared.protocol.netty.WireCommands.CreateTransientSegment)8 Test (org.junit.Test)6 AppendSetup (io.pravega.shared.protocol.netty.WireCommands.AppendSetup)4 NoSuchSegment (io.pravega.shared.protocol.netty.WireCommands.NoSuchSegment)4 SegmentCreated (io.pravega.shared.protocol.netty.WireCommands.SegmentCreated)4 SetupAppend (io.pravega.shared.protocol.netty.WireCommands.SetupAppend)4 ArrayList (java.util.ArrayList)4 UUID (java.util.UUID)4 ByteBuf (io.netty.buffer.ByteBuf)3 ClientConnection (io.pravega.client.connection.impl.ClientConnection)3 Segment (io.pravega.client.segment.impl.Segment)3 MockConnectionFactoryImpl (io.pravega.client.stream.mock.MockConnectionFactoryImpl)3 MockController (io.pravega.client.stream.mock.MockController)3 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)3 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)3 DataAppended (io.pravega.shared.protocol.netty.WireCommands.DataAppended)3 SegmentIsSealed (io.pravega.shared.protocol.netty.WireCommands.SegmentIsSealed)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 EmptyTokenProviderImpl (io.pravega.client.security.auth.EmptyTokenProviderImpl)2 EventWriterConfig (io.pravega.client.stream.EventWriterConfig)2