@Override public void appendSetup(AppendSetup appendSetup) { log.info("Received AppendSetup {}", appendSetup); long ackLevel = appendSetup.getLastEventNumber(); ackUpTo(ackLevel); List<Append> toRetransmit = state.getAllInflight() .stream() .map(entry -> new Append(segmentName, writerId, entry.getKey(), 1, entry.getValue().getData(), null)) .collect(Collectors.toList()); ClientConnection connection = state.getConnection(); if (connection == null) { log.warn("Connection setup could not be completed because connection is already failed.", writerId); return; } if (toRetransmit == null || toRetransmit.isEmpty()) { log.info("Connection setup complete for writer {}", writerId); state.connectionSetupComplete(connection); } else { connection.sendAsync(toRetransmit, e -> { if (e == null) { state.connectionSetupComplete(connection); } else { failConnection(e); } }); } }
@Before public void setUp() throws Exception { when(buffer.readableBytes()).thenReturn(10); appendCmd = new Append("segment0", UUID.randomUUID(), 2, 1, buffer, 10L); doNothing().when(tracker).recordAppend(anyLong(), anyInt()); when(ctx.channel()).thenReturn(ch); when(ch.eventLoop()).thenReturn(loop); when(ch.writeAndFlush(any(Object.class))).thenReturn(completedFuture); handler = new ClientConnectionInboundHandler("testConnection", processor, tracker); }
Append append = new Append(segmentName, writerId, eventNumber, 1, event.getData(), null); log.trace("Sending append request: {}", append); connection.send(append);
private void sendAndVerifyEvent(UUID cid, ClientConnection connection, SegmentOutputStreamImpl output, ByteBuffer data, int num) throws SegmentSealedException, ConnectionFailedException { CompletableFuture<Void> acked = new CompletableFuture<>(); output.write(PendingEvent.withoutHeader(null, data, acked)); verify(connection).send(new Append(SEGMENT, cid, num, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, acked.isDone()); }
private long append(String segment, UUID writerId, long offset, int messageNumber, int length, ByteBuf out) throws Exception { byte[] content = new byte[length]; Arrays.fill(content, (byte) messageNumber); Event event = new Event(Unpooled.wrappedBuffer(content)); Append msg = new Append(segment, writerId, messageNumber, event); assertEquals(length + WireCommands.TYPE_PLUS_LENGTH_SIZE, msg.data.readableBytes()); encoder.encode(null, msg, out); assertEquals(length + WireCommands.TYPE_PLUS_LENGTH_SIZE, msg.data.readableBytes()); return offset + length; }
@Test public void testSetupSkipped() { String streamSegmentName = "testAppendSegment"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null); try { processor.append(new Append(streamSegmentName, clientId, data.length, 1, Unpooled.wrappedBuffer(data), null)); fail(); } catch (RuntimeException e) { //expected } verifyNoMoreInteractions(connection); verifyNoMoreInteractions(store); }
@Test public void testEventNumbersOldClient() { String streamSegmentName = "testAppendSegment"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null); when(store.getAttributes(streamSegmentName, Collections.singleton(clientId), true, AppendProcessor.TIMEOUT)) .thenReturn(CompletableFuture.completedFuture(Collections.singletonMap(clientId, 100L))); processor.setupAppend(new SetupAppend(1, clientId, streamSegmentName, "")); verify(store).getAttributes(streamSegmentName, Collections.singleton(clientId), true, AppendProcessor.TIMEOUT); int eventCount = 10; CompletableFuture<Void> result = CompletableFuture.completedFuture(null); when(store.append(streamSegmentName, data, updateEventNumber(clientId, 200, 100, eventCount), AppendProcessor.TIMEOUT)).thenReturn(result); processor.append(new Append(streamSegmentName, clientId, 200, eventCount, Unpooled.wrappedBuffer(data), null)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, 200, 100, eventCount), AppendProcessor.TIMEOUT); when(store.append(streamSegmentName, data, updateEventNumber(clientId, 300, 200, eventCount), AppendProcessor.TIMEOUT)).thenReturn(result); processor.append(new Append(streamSegmentName, clientId, 300, eventCount, Unpooled.wrappedBuffer(data), null)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, 300, 200, eventCount), AppendProcessor.TIMEOUT); verifyNoMoreInteractions(store); }
@Test public void testEventNumbers() { String streamSegmentName = "testAppendSegment"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null); when(store.getAttributes(streamSegmentName, Collections.singleton(clientId), true, AppendProcessor.TIMEOUT)) .thenReturn(CompletableFuture.completedFuture(Collections.emptyMap())); processor.setupAppend(new SetupAppend(1, clientId, streamSegmentName, "")); verify(store).getAttributes(streamSegmentName, Collections.singleton(clientId), true, AppendProcessor.TIMEOUT); CompletableFuture<Void> result = CompletableFuture.completedFuture(null); int eventCount = 100; when(store.append(streamSegmentName, data, updateEventNumber(clientId, 100, Attributes.NULL_ATTRIBUTE_VALUE, eventCount), AppendProcessor.TIMEOUT)).thenReturn(result); processor.append(new Append(streamSegmentName, clientId, 100, eventCount, Unpooled.wrappedBuffer(data), null)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, 100, Attributes.NULL_ATTRIBUTE_VALUE, eventCount), AppendProcessor.TIMEOUT); when(store.append(streamSegmentName, data, updateEventNumber(clientId, 200, 100, eventCount), AppendProcessor.TIMEOUT)).thenReturn(result); processor.append(new Append(streamSegmentName, clientId, 200, eventCount, Unpooled.wrappedBuffer(data), null)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, 200, 100, eventCount), AppendProcessor.TIMEOUT); verifyNoMoreInteractions(store); }
@Test public void testInvalidOffset() { String streamSegmentName = "testAppendSegment"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null); setupGetAttributes(streamSegmentName, clientId, 100, store); processor.setupAppend(new SetupAppend(1, clientId, streamSegmentName, "")); try { processor.append(new Append(streamSegmentName, clientId, data.length, 1, Unpooled.wrappedBuffer(data), null)); fail(); } catch (RuntimeException e) { //expected } verify(store).getAttributes(anyString(), eq(Collections.singleton(clientId)), eq(true), eq(AppendProcessor.TIMEOUT)); verify(connection).send(new AppendSetup(1, streamSegmentName, clientId, 100)); verify(connection, atLeast(0)).resumeReading(); verifyNoMoreInteractions(connection); verifyNoMoreInteractions(store); }
@Test public void testUnsupportedOperation() { String streamSegmentName = "testAppendSegment"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null); setupGetAttributes(streamSegmentName, clientId, store); CompletableFuture<Void> result = Futures.failedFuture(new UnsupportedOperationException()); when(store.append(streamSegmentName, data, updateEventNumber(clientId, data.length), AppendProcessor.TIMEOUT)) .thenReturn(result); processor.setupAppend(new SetupAppend(1, clientId, streamSegmentName, "")); processor.append(new Append(streamSegmentName, clientId, data.length, 1, Unpooled.wrappedBuffer(data), null)); verify(store).getAttributes(anyString(), eq(Collections.singleton(clientId)), eq(true), eq(AppendProcessor.TIMEOUT)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, data.length), AppendProcessor.TIMEOUT); verify(connection).send(new AppendSetup(1, streamSegmentName, clientId, 0)); verify(connection, atLeast(0)).resumeReading(); verify(connection).send(new OperationUnsupported(data.length, "appending data", "")); verifyNoMoreInteractions(connection); verifyNoMoreInteractions(store); }
@Test public void testVerySmallBlockSize() throws Exception { @Cleanup("release") ByteBuf fakeNetwork = ByteBufAllocator.DEFAULT.buffer(); byte[] content = new byte[100]; Arrays.fill(content, (byte) 1); Event event = new Event(Unpooled.wrappedBuffer(content)); Append msg = new Append("segment", writerId, 1, event); CommandEncoder commandEncoder = new CommandEncoder(new FixedBatchSizeTracker(3)); SetupAppend setupAppend = new SetupAppend(1, writerId, "segment", ""); commandEncoder.encode(null, setupAppend, fakeNetwork); appendDecoder.processCommand(setupAppend); ArrayList<Object> received = new ArrayList<>(); commandEncoder.encode(null, msg, fakeNetwork); read(fakeNetwork, received); assertEquals(2, received.size()); Append readAppend = (Append) received.get(1); assertEquals(msg.data.readableBytes(), readAppend.data.readableBytes()); assertEquals(content.length + TYPE_PLUS_LENGTH_SIZE, readAppend.data.readableBytes()); }
@Test public void testTransactionAppend() throws Exception { String streamSegmentName = "transactionSegment#transaction.01234567890123456789012345678901"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); DynamicLogger mockedDynamicLogger = Mockito.mock(DynamicLogger.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null, mockedDynamicLogger); setupGetAttributes(streamSegmentName, clientId, store); CompletableFuture<Void> result = CompletableFuture.completedFuture(null); when(store.append(streamSegmentName, data, updateEventNumber(clientId, data.length), AppendProcessor.TIMEOUT)) .thenReturn(result); processor.setupAppend(new SetupAppend(1, clientId, streamSegmentName, "")); processor.append(new Append(streamSegmentName, clientId, data.length, 1, Unpooled.wrappedBuffer(data), null)); verify(store).getAttributes(anyString(), eq(Collections.singleton(clientId)), eq(true), eq(AppendProcessor.TIMEOUT)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, data.length), AppendProcessor.TIMEOUT); verify(connection).send(new AppendSetup(1, streamSegmentName, clientId, 0)); verify(connection, atLeast(0)).resumeReading(); verify(connection).send(new DataAppended(clientId, data.length, 0L)); verifyNoMoreInteractions(connection); verifyNoMoreInteractions(store); verify(mockedDynamicLogger).incCounterValue(globalMetricName(SEGMENT_WRITE_BYTES), 8); verify(mockedDynamicLogger).incCounterValue(globalMetricName(SEGMENT_WRITE_EVENTS), 1); verify(mockedDynamicLogger, never()).incCounterValue(nameFromSegment(SEGMENT_WRITE_BYTES, streamSegmentName), 8); verify(mockedDynamicLogger, never()).incCounterValue(nameFromSegment(SEGMENT_WRITE_EVENTS, streamSegmentName), 1); }
@Test public void testAppend() throws Exception { String streamSegmentName = "testAppendSegment"; UUID clientId = UUID.randomUUID(); byte[] data = new byte[] { 1, 2, 3, 4, 6, 7, 8, 9 }; StreamSegmentStore store = mock(StreamSegmentStore.class); ServerConnection connection = mock(ServerConnection.class); DynamicLogger mockedDynamicLogger = Mockito.mock(DynamicLogger.class); AppendProcessor processor = new AppendProcessor(store, connection, new FailingRequestProcessor(), null, mockedDynamicLogger); setupGetAttributes(streamSegmentName, clientId, store); CompletableFuture<Void> result = CompletableFuture.completedFuture(null); when(store.append(streamSegmentName, data, updateEventNumber(clientId, data.length), AppendProcessor.TIMEOUT)) .thenReturn(result); processor.setupAppend(new SetupAppend(1, clientId, streamSegmentName, "")); processor.append(new Append(streamSegmentName, clientId, data.length, 1, Unpooled.wrappedBuffer(data), null)); verify(store).getAttributes(anyString(), eq(Collections.singleton(clientId)), eq(true), eq(AppendProcessor.TIMEOUT)); verify(store).append(streamSegmentName, data, updateEventNumber(clientId, data.length), AppendProcessor.TIMEOUT); verify(connection).send(new AppendSetup(1, streamSegmentName, clientId, 0)); verify(connection, atLeast(0)).resumeReading(); verify(connection).send(new DataAppended(clientId, data.length, 0L)); verifyNoMoreInteractions(connection); verifyNoMoreInteractions(store); verify(mockedDynamicLogger).incCounterValue(globalMetricName(SEGMENT_WRITE_BYTES), 8); verify(mockedDynamicLogger).incCounterValue(globalMetricName(SEGMENT_WRITE_EVENTS), 1); verify(mockedDynamicLogger).incCounterValue(nameFromSegment(SEGMENT_WRITE_BYTES, streamSegmentName), 8); verify(mockedDynamicLogger).incCounterValue(nameFromSegment(SEGMENT_WRITE_EVENTS, streamSegmentName), 1); }
@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); }
@Test(timeout = 10000) public void testSealedBeforeFlush() throws Exception { 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); InOrder order = Mockito.inOrder(connection); SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, ""); output.reconnect(); order.verify(connection).send(new SetupAppend(1, cid, SEGMENT, "")); cf.getProcessor(uri).appendSetup(new AppendSetup(1, SEGMENT, cid, 0)); ByteBuffer data = getBuffer("test"); CompletableFuture<Void> ack = new CompletableFuture<>(); output.write(PendingEvent.withoutHeader(null, data, ack)); order.verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, ack.isDone()); cf.getProcessor(uri).segmentIsSealed(new WireCommands.SegmentIsSealed(1, SEGMENT, "SomeException")); output.getUnackedEventsOnSeal(); // this is invoked by the segmentSealedCallback. AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }
@Test public void sendReceivingAppend() throws Exception { String segment = "123"; ByteBuf data = Unpooled.wrappedBuffer("Hello world\n".getBytes()); StreamSegmentStore store = this.serviceBuilder.createStreamSegmentService(); @Cleanup EmbeddedChannel channel = createChannel(store); SegmentCreated created = (SegmentCreated) sendRequest(channel, new CreateSegment(1, segment, CreateSegment.NO_SCALE, 0, "")); assertEquals(segment, created.getSegment()); UUID uuid = UUID.randomUUID(); AppendSetup setup = (AppendSetup) sendRequest(channel, new SetupAppend(2, uuid, segment, "")); assertEquals(segment, setup.getSegment()); assertEquals(uuid, setup.getWriterId()); DataAppended ack = (DataAppended) sendRequest(channel, new Append(segment, uuid, data.readableBytes(), new Event(data))); assertEquals(uuid, ack.getWriterId()); assertEquals(data.readableBytes(), ack.getEventNumber()); assertEquals(Long.MIN_VALUE, ack.getPreviousEventNumber()); }
@Test(timeout = 10000) public void testFlushDuringTransactionAbort() throws Exception { 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); InOrder order = Mockito.inOrder(connection); SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(TXN_SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, ""); output.reconnect(); order.verify(connection).send(new SetupAppend(1, cid, TXN_SEGMENT, "")); cf.getProcessor(uri).appendSetup(new AppendSetup(1, TXN_SEGMENT, cid, 0)); ByteBuffer data = getBuffer("test"); // Write an Event. CompletableFuture<Void> ack = new CompletableFuture<>(); output.write(PendingEvent.withoutHeader(null, data, ack)); order.verify(connection).send(new Append(TXN_SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertFalse(ack.isDone()); //writer is not complete until a response from Segment Store is received. // Validate that flush() is blocking until there is a response from Segment Store. AssertExtensions.assertBlocks(() -> { // A flush() should throw a SegmentSealedException. AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }, () -> { // Simulate a NoSuchSegment response from SegmentStore due to a Transaction abort. cf.getProcessor(uri).noSuchSegment(new WireCommands.NoSuchSegment(1, TXN_SEGMENT, "SomeException")); }); AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }
@Test(timeout = 10000) public void testSealedAfterFlush() throws Exception { 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); InOrder order = Mockito.inOrder(connection); SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, ""); output.reconnect(); order.verify(connection).send(new SetupAppend(1, cid, SEGMENT, "")); cf.getProcessor(uri).appendSetup(new AppendSetup(1, SEGMENT, cid, 0)); ByteBuffer data = getBuffer("test"); CompletableFuture<Void> ack = new CompletableFuture<>(); output.write(PendingEvent.withoutHeader(null, data, ack)); order.verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, ack.isDone()); AssertExtensions.assertBlocks(() -> { AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }, () -> { cf.getProcessor(uri).segmentIsSealed(new WireCommands.SegmentIsSealed(1, SEGMENT, "SomeException")); output.getUnackedEventsOnSeal(); }); AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }
@Test(timeout = 10000) public void testNoSuchSegment() throws Exception { 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); InOrder order = Mockito.inOrder(connection); SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, ""); output.reconnect(); order.verify(connection).send(new SetupAppend(1, cid, SEGMENT, "")); cf.getProcessor(uri).appendSetup(new AppendSetup(1, SEGMENT, cid, 0)); ByteBuffer data = getBuffer("test"); //Write an Event. CompletableFuture<Void> ack = new CompletableFuture<>(); output.write(PendingEvent.withoutHeader(null, data, ack)); order.verify(connection).send(new Append(SEGMENT, cid, 1, 1, Unpooled.wrappedBuffer(data), null)); assertEquals(false, ack.isDone()); //writer is not complete until a response from Segment Store is received. //Simulate a No Such Segment while waiting on flush. AssertExtensions.assertBlocks(() -> { AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }, () -> { cf.getProcessor(uri).noSuchSegment(new WireCommands.NoSuchSegment(1, SEGMENT, "SomeException")); output.getUnackedEventsOnSeal(); }); AssertExtensions.assertThrows(SegmentSealedException.class, () -> output.flush()); }
@Test(timeout = 10000) public void testMultipleAppends() throws Exception { String segment = "123"; ByteBuf data = Unpooled.wrappedBuffer("Hello world\n".getBytes()); StreamSegmentStore store = this.serviceBuilder.createStreamSegmentService(); @Cleanup EmbeddedChannel channel = createChannel(store); SegmentCreated created = (SegmentCreated) sendRequest(channel, new CreateSegment(1, segment, CreateSegment.NO_SCALE, 0, "")); assertEquals(segment, created.getSegment()); UUID uuid = UUID.randomUUID(); AppendSetup setup = (AppendSetup) sendRequest(channel, new SetupAppend(2, uuid, segment, "")); assertEquals(segment, setup.getSegment()); assertEquals(uuid, setup.getWriterId()); data.retain(); DataAppended ack = (DataAppended) sendRequest(channel, new Append(segment, uuid, 1, new Event(data))); assertEquals(uuid, ack.getWriterId()); assertEquals(1, ack.getEventNumber()); assertEquals(Long.MIN_VALUE, ack.getPreviousEventNumber()); DataAppended ack2 = (DataAppended) sendRequest(channel, new Append(segment, uuid, 2, new Event(data))); assertEquals(uuid, ack2.getWriterId()); assertEquals(2, ack2.getEventNumber()); assertEquals(1, ack2.getPreviousEventNumber()); }