@Override public ByteBuffer getNext(ByteBuffer byteBuffer) { UUID uuid = fromByteBuffer(byteBuffer.duplicate()); return toByteBuffer(new java.util.UUID(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits() + 1)); }
@Override public String getString(ByteBuffer byteBuffer) { if (byteBuffer == null) return null; ByteBuffer dup = byteBuffer.duplicate(); long micros = TimeUUIDUtils.getMicrosTimeFromUUID(this.fromByteBuffer(dup)); return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date(micros / 1000)); }
/** * Use the age of the slabId as a heuristic to determine when we should ignore the lack of the "open slab marker". * <p> * When a slab is first created, the 'manifest' row is written with "open=true" but no columns are written to the * 'slab' column family. In that initial state, scanning the slab and finding no "open slab" marker does *not* * mean we've found a stale slab that can be closed or deleted. We could fix this by writing the "open slab" * marker before writing the manifest (not in the same batch mutation). But since the marker would only live for 20 * minutes without a followup write, simply checking the slabId age has exactly the same effect with fewer writes. */ private boolean isRecent(ByteBuffer slabId) { UUID uuid = TimeUUIDSerializer.get().fromByteBuffer(slabId.duplicate()); long age = System.currentTimeMillis() - TimeUUIDs.getTimeMillis(uuid); return age <= Constants.OPEN_SLAB_MARKER_TTL.toMillis(); }
/** * Use the age of the slabId as a heuristic to determine when we should ignore the lack of the "open slab marker". * <p> * When a slab is first created, the 'manifest' row is written with "open=true" but no columns are written to the * 'slab' column family. In that initial state, scanning the slab and finding no "open slab" marker does *not* * mean we've found a stale slab that can be closed or deleted. We could fix this by writing the "open slab" * marker before writing the manifest (not in the same batch mutation). But since the marker would only live for 20 * minutes without a followup write, simply checking the slabId age has exactly the same effect with fewer writes. */ private boolean isRecent(ByteBuffer slabId) { UUID uuid = TimeUUIDSerializer.get().fromByteBuffer(slabId.duplicate()); long age = System.currentTimeMillis() - TimeUUIDs.getTimeMillis(uuid); return age <= Constants.OPEN_SLAB_MARKER_TTL.toMillis(); }
@Override public boolean accept(ByteBuffer slabId, boolean open, ByteBuffer nextSlabId) { UUID nextSlabUUID = !foundStartingSlab && nextSlabId != null ? TimeUUIDSerializer.get().fromByteBuffer(nextSlabId.duplicate()) : null; // If the nextSlab's UUID is less than the desired timestamp, then skip reading events from this slab if (nextSlabUUID != null && TimeUUIDs.compareTimestamps(nextSlabUUID, sinceUUID) < 0) { return false; } if (!foundStartingSlab) { // Log the slab that we start reading from foundStartingSlab = true; _log.info("Starting to replay {} from slabid {}, for since timestamp of {}", channel, UUIDSerializer.get().fromByteBuffer(slabId), ISO_FORMATTER.format(since.toInstant())); } return true; } };
@Override public boolean accept(ByteBuffer slabId, boolean open, ByteBuffer nextSlabId) { UUID nextSlabUUID = !foundStartingSlab && nextSlabId != null ? TimeUUIDSerializer.get().fromByteBuffer(nextSlabId.duplicate()) : null; // If the nextSlab's UUID is less than the desired timestamp, then skip reading events from this slab if (nextSlabUUID != null && TimeUUIDs.compareTimestamps(nextSlabUUID, sinceUUID) < 0) { return false; } if (!foundStartingSlab) { // Log the slab that we start reading from foundStartingSlab = true; _log.info("Starting to replay {} from slabid {}, for since timestamp of {}", channel, UUIDSerializer.get().fromByteBuffer(slabId), ISO_FORMATTER.format(since.toInstant())); } return true; } };
if (peekingManifestColumns.hasNext()) { cacheOldestSlabForChannel(channel, TimeUUIDSerializer.get().fromByteBuffer(peekingManifestColumns.peek().getName())); return peekingManifestColumns; } else {
if (peekingManifestColumns.hasNext()) { cacheOldestSlabForChannel(channel, TimeUUIDSerializer.get().fromByteBuffer(peekingManifestColumns.peek().getName())); return peekingManifestColumns; } else {