@Override public void process(ReplyProcessor cp) { cp.dataAppended(this); }
@Override public void dataAppended(WireCommands.DataAppended dataAppended) { getNextReplyProcessor().dataAppended(dataAppended); }
order.verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked1.isDone()); AssertExtensions.assertBlocks(() -> output.flush(), () -> cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 1, 0))); assertEquals(false, acked1.isCompletedExceptionally()); assertEquals(true, acked1.isDone()); order.verify(connection).send(new Append(SEGMENT, cid, 2, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked2.isDone()); cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 3, 2L));
order.verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked1.isDone()); AssertExtensions.assertBlocks(() -> output.flush(), () -> cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 1, 0))); assertEquals(false, acked1.isCompletedExceptionally()); assertEquals(true, acked1.isDone()); order.verify(connection).send(new Append(SEGMENT, cid, 2, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked2.isDone()); cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 2, 3));
inOrder.verify(connection).send(new SetupAppend(2, cid, SEGMENT, "")); inOrder.verify(connection).sendAsync(Mockito.eq(Collections.singletonList(append)), Mockito.any()); cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 1, 0)); }); inOrder.verify(connection).close();
order.verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked1.isDone()); AssertExtensions.assertBlocks(() -> output.flush(), () -> cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 1, 0))); assertEquals(false, acked1.isCompletedExceptionally()); assertEquals(true, acked1.isDone()); order.verify(connection).send(new Append(SEGMENT, cid, 2, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked2.isDone()); AssertExtensions.assertBlocks(() -> output.flush(), () -> cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 2, 1))); assertEquals(false, acked2.isCompletedExceptionally()); assertEquals(true, acked2.isDone());
@Test(timeout = 10000) public void testClose() throws ConnectionFailedException, SegmentSealedException { UUID cid = UUID.randomUUID(); PravegaNodeUri uri = new PravegaNodeUri("endpoint", SERVICE_PORT); MockConnectionFactoryImpl cf = new MockConnectionFactoryImpl(); cf.setExecutor(executorService()); MockController controller = new MockController(uri.getEndpoint(), uri.getPort(), cf); ClientConnection connection = mock(ClientConnection.class); cf.provideConnection(uri, connection); SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, ""); output.reconnect(); verify(connection).send(new SetupAppend(1, cid, SEGMENT, "")); cf.getProcessor(uri).appendSetup(new AppendSetup(1, SEGMENT, cid, 0)); ByteBuffer data = getBuffer("test"); CompletableFuture<Void> acked = new CompletableFuture<>(); output.write(PendingEvent.withoutHeader(null, data, acked)); verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked.isDone()); AssertExtensions.assertBlocks(() -> output.close(), () -> cf.getProcessor(uri).dataAppended(new WireCommands.DataAppended(cid, 1, 0))); assertEquals(false, acked.isCompletedExceptionally()); assertEquals(true, acked.isDone()); verify(connection, Mockito.atMost(1)).send(new WireCommands.KeepAlive()); verify(connection).close(); verifyNoMoreInteractions(connection); }