private void sealActiveChunk(RollingSegmentHandle handle) throws StreamSegmentException { SegmentHandle activeChunk = handle.getActiveChunkHandle(); SegmentChunk last = handle.lastChunk(); if (activeChunk != null && !last.isSealed()) { this.baseStorage.seal(activeChunk); handle.setActiveChunkHandle(null); last.markSealed(); log.debug("Sealed active SegmentChunk '{}' for '{}'.", activeChunk.getSegmentName(), handle.getSegmentName()); } }
/** * Creates a new instance of the SegmentChunk class with the same information as this one, but with a new offset. * * @param newOffset The new offset. * @return A new SegmentChunk. */ SegmentChunk withNewOffset(long newOffset) { SegmentChunk ns = new SegmentChunk(this.name, newOffset); ns.setLength(getLength()); if (isSealed()) { ns.markSealed(); } if (!exists()) { ns.markInexistent(); } return ns; }
private RollingSegmentHandle newHandle(String segmentName, int chunkCount) { val chunks = new ArrayList<SegmentChunk>(); long offset = 0; val rnd = new Random(0); for (int i = 0; i < chunkCount; i++) { val chunk = new SegmentChunk(StreamSegmentNameUtils.getSegmentChunkName(segmentName, offset), offset); chunk.setLength(MathHelpers.abs(rnd.nextInt())); if (i < chunkCount - 1) { chunk.markSealed(); } chunks.add(chunk); offset += chunk.getLength(); } return new RollingSegmentHandle(new TestHandle(StreamSegmentNameUtils.getHeaderSegmentName(segmentName), false), TEST_ROLLING_POLICY, chunks); }
if (last != null) { last.setLength(s.getStartOffset() - last.getStartOffset()); last.markSealed(); last.setLength(si.getLength()); if (si.isSealed()) { last.markSealed(); if (handle.getHeaderHandle() == null) { handle.markSealed();