private void ensureNotDeleted(RollingSegmentHandle handle) throws StreamSegmentNotExistsException { if (handle.isDeleted()) { throw new StreamSegmentNotExistsException(handle.getSegmentName()); } }
/** * Updates the contents of this handle with information from the given one. * * @param source The RollingSegmentHandle to update from. */ synchronized void refresh(RollingSegmentHandle source) { Preconditions.checkArgument(source.getSegmentName().equals(this.getSegmentName()), "SegmentName mismatch."); if (this.readOnly == source.readOnly) { // Update the header handle, but only if both this handle and the source one have the same read-only flag. // Otherwise we risk attaching a read-only header handle to a read-write handle or vice-versa. this.headerHandle = source.headerHandle; } this.segmentChunks = new ArrayList<>(source.chunks()); setHeaderLength(source.getHeaderLength()); if (source.isSealed()) { markSealed(); } if (source.isDeleted()) { markDeleted(); } }
if (h.isDeleted()) { log.debug("Segment '{}' has been deleted. Cannot read anymore.", h); throw new StreamSegmentNotExistsException(handle.getSegmentName(), ex);
s.delete(writeHandle); Assert.assertFalse("Expecting the segment to be deleted.", s.exists(SEGMENT_NAME)); Assert.assertTrue("Expected the handle to be marked as deleted.", writeHandle.isDeleted()); Assert.assertFalse("Expected all SegmentChunks to be marked as deleted.", writeHandle.chunks().stream().anyMatch(SegmentChunk::exists));
Assert.assertEquals("Unexpected lastChunk.", chunk2, h.lastChunk()); h.lastChunk().markInexistent(); Assert.assertFalse("Unexpected value from isDeleted after last SegmentChunk marked as inexistent.", h.isDeleted());