public static String getSegmentFileName(AzureSegmentArchiveEntry indexEntry) { return getSegmentFileName(indexEntry.getPosition(), indexEntry.getMsb(), indexEntry.getLsb()); }
public static String getSegmentFileName(AzureSegmentArchiveEntry indexEntry) { return getSegmentFileName(indexEntry.getPosition(), indexEntry.getMsb(), indexEntry.getLsb()); }
@Override public Buffer readSegment(long msb, long lsb) throws IOException { UUID uuid = new UUID(msb, lsb); Optional<SegmentWriteAction> segment = queue.map(q -> q.read(uuid)); if (segment.isPresent()) { return segment.get().toBuffer(); } AzureSegmentArchiveEntry indexEntry = index.get(new UUID(msb, lsb)); if (indexEntry == null) { return null; } Buffer buffer; if (OFF_HEAP) { buffer = Buffer.allocateDirect(indexEntry.getLength()); } else { buffer = Buffer.allocate(indexEntry.getLength()); } readBufferFully(getBlob(getSegmentFileName(indexEntry)), buffer); return buffer; }
@Override public Buffer readSegment(long msb, long lsb) throws IOException { UUID uuid = new UUID(msb, lsb); Optional<SegmentWriteAction> segment = queue.map(q -> q.read(uuid)); if (segment.isPresent()) { return segment.get().toBuffer(); } AzureSegmentArchiveEntry indexEntry = index.get(new UUID(msb, lsb)); if (indexEntry == null) { return null; } Buffer buffer; if (OFF_HEAP) { buffer = Buffer.allocateDirect(indexEntry.getLength()); } else { buffer = Buffer.allocate(indexEntry.getLength()); } readBufferFully(getBlob(getSegmentFileName(indexEntry)), buffer); return buffer; }
private void doWriteEntry(AzureSegmentArchiveEntry indexEntry, byte[] data, int offset, int size) throws IOException { long msb = indexEntry.getMsb(); long lsb = indexEntry.getLsb(); ioMonitor.beforeSegmentWrite(pathAsFile(), msb, lsb, size); Stopwatch stopwatch = Stopwatch.createStarted(); try { CloudBlockBlob blob = getBlob(getSegmentFileName(indexEntry)); blob.setMetadata(AzureBlobMetadata.toSegmentMetadata(indexEntry)); blob.uploadFromByteArray(data, offset, size); blob.uploadMetadata(); } catch (StorageException e) { throw new IOException(e); } ioMonitor.afterSegmentWrite(pathAsFile(), msb, lsb, size, stopwatch.elapsed(TimeUnit.NANOSECONDS)); }
private void doWriteEntry(AzureSegmentArchiveEntry indexEntry, byte[] data, int offset, int size) throws IOException { long msb = indexEntry.getMsb(); long lsb = indexEntry.getLsb(); ioMonitor.beforeSegmentWrite(pathAsFile(), msb, lsb, size); Stopwatch stopwatch = Stopwatch.createStarted(); try { CloudBlockBlob blob = getBlob(getSegmentFileName(indexEntry)); blob.setMetadata(AzureBlobMetadata.toSegmentMetadata(indexEntry)); blob.uploadFromByteArray(data, offset, size); blob.uploadMetadata(); } catch (StorageException e) { throw new IOException(e); } ioMonitor.afterSegmentWrite(pathAsFile(), msb, lsb, size, stopwatch.elapsed(TimeUnit.NANOSECONDS)); }
@Override public Buffer readSegment(long msb, long lsb) throws IOException { AzureSegmentArchiveEntry indexEntry = index.get(new UUID(msb, lsb)); if (indexEntry == null) { return null; } Buffer buffer; if (OFF_HEAP) { buffer = Buffer.allocateDirect(indexEntry.getLength()); } else { buffer = Buffer.allocate(indexEntry.getLength()); } ioMonitor.beforeSegmentRead(pathAsFile(), msb, lsb, indexEntry.getLength()); Stopwatch stopwatch = Stopwatch.createStarted(); readBufferFully(getBlob(getSegmentFileName(indexEntry)), buffer); long elapsed = stopwatch.elapsed(TimeUnit.NANOSECONDS); ioMonitor.afterSegmentRead(pathAsFile(), msb, lsb, indexEntry.getLength(), elapsed); return buffer; }
@Override public Buffer readSegment(long msb, long lsb) throws IOException { AzureSegmentArchiveEntry indexEntry = index.get(new UUID(msb, lsb)); if (indexEntry == null) { return null; } Buffer buffer; if (OFF_HEAP) { buffer = Buffer.allocateDirect(indexEntry.getLength()); } else { buffer = Buffer.allocate(indexEntry.getLength()); } ioMonitor.beforeSegmentRead(pathAsFile(), msb, lsb, indexEntry.getLength()); Stopwatch stopwatch = Stopwatch.createStarted(); readBufferFully(getBlob(getSegmentFileName(indexEntry)), buffer); long elapsed = stopwatch.elapsed(TimeUnit.NANOSECONDS); ioMonitor.afterSegmentRead(pathAsFile(), msb, lsb, indexEntry.getLength(), elapsed); return buffer; }