DLUtils { public static Long nextLogSegmentSequenceNumber(List<LogSegmentMetadata> segmentListDesc) { int lastAssignedLogSegmentIdx = -1; Long lastAssignedLogSegmentSeqNo = null; Long nextLogSegmentSeqNo = null; for (int i = 0; i < segmentListDesc.size(); i++) { LogSegmentMetadata metadata = segmentListDesc.get(i); if (LogSegmentMetadata.supportsLogSegmentSequenceNo(metadata.getVersion())) { lastAssignedLogSegmentSeqNo = metadata.getLogSegmentSequenceNumber(); lastAssignedLogSegmentIdx = i; break; } } if (null != lastAssignedLogSegmentSeqNo) { nextLogSegmentSeqNo = lastAssignedLogSegmentSeqNo + lastAssignedLogSegmentIdx + 1; } return nextLogSegmentSeqNo; }  static String getZKServersFromDLUri(URI uri); static int findLogSegmentNotLessThanTxnId(List<LogSegmentMetadata> segments,
                                                     long transactionId); static Long nextLogSegmentSequenceNumber(List<LogSegmentMetadata> segmentListDesc); static long computeStartSequenceId(List<LogSegmentMetadata> logSegmentDescList,
                                              LogSegmentMetadata segment); static long deserializeLogSegmentSequenceNumber(byte[] data); static byte[] serializeLogSegmentSequenceNumber(long logSegmentSeqNo); static long deserializeTransactionId(byte[] data); static byte[] serializeTransactionId(long transactionId); static byte[] ledgerId2Bytes(long ledgerId); static long bytes2LedgerId(byte[] data);  }
@Test(timeout = 60000) public void testNextLogSegmentSequenceNumber() throws Exception { List<LogSegmentMetadata> v1List = Lists.newArrayList( completedLogSegment(2L, 100L, 199L, LogSegmentMetadataVersion.VERSION_V1_ORIGINAL.value), completedLogSegment(1L, 0L, 99L, LogSegmentMetadataVersion.VERSION_V1_ORIGINAL.value)); assertNull(DLUtils.nextLogSegmentSequenceNumber(v1List)); List<LogSegmentMetadata> afterV1List = Lists.newArrayList( completedLogSegment(2L, 100L, 199L), completedLogSegment(1L, 0L, 99L)); assertEquals((Long) 3L, DLUtils.nextLogSegmentSequenceNumber(afterV1List)); List<LogSegmentMetadata> mixList1 = Lists.newArrayList( completedLogSegment(2L, 100L, 199L, LogSegmentMetadataVersion.VERSION_V1_ORIGINAL.value), completedLogSegment(1L, 0L, 99L)); assertEquals((Long) 3L, DLUtils.nextLogSegmentSequenceNumber(mixList1)); List<LogSegmentMetadata> mixList2 = Lists.newArrayList( completedLogSegment(2L, 100L, 199L), completedLogSegment(1L, 0L, 99L, LogSegmentMetadataVersion.VERSION_V1_ORIGINAL.value)); assertEquals((Long) 3L, DLUtils.nextLogSegmentSequenceNumber(mixList2)); }