@Override public boolean hasGraph() { if (hasGraph == null) { try { getGraph(); } catch (IOException ignore) { } } return hasGraph; }
@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 SegmentArchiveReader forceOpen(String archiveName) throws IOException { CloudBlobDirectory archiveDirectory = getDirectory(archiveName); return new AzureSegmentArchiveReader(archiveDirectory, ioMonitor); }
private Buffer readBlob(String name) throws IOException { try { CloudBlockBlob blob = getBlob(name); if (!blob.exists()) { return null; } long length = blob.getProperties().getLength(); Buffer buffer = Buffer.allocate((int) length); AzureUtilities.readBufferFully(blob, buffer); return buffer; } catch (StorageException e) { throw new IOException(e); } }
@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 SegmentArchiveReader forceOpen(String archiveName) throws IOException { CloudBlobDirectory archiveDirectory = getDirectory(archiveName); return new AzureSegmentArchiveReader(archiveDirectory, ioMonitor); }
private Buffer readBlob(String name) throws IOException { try { CloudBlockBlob blob = getBlob(name); if (!blob.exists()) { return null; } long length = blob.getProperties().getLength(); Buffer buffer = Buffer.allocate((int) length); AzureUtilities.readBufferFully(blob, buffer); return buffer; } catch (StorageException e) { throw new IOException(e); } }
@Override public SegmentArchiveReader open(String archiveName) throws IOException { try { CloudBlobDirectory archiveDirectory = getDirectory(archiveName); if (!archiveDirectory.getBlockBlobReference("closed").exists()) { throw new IOException("The archive " + archiveName + " hasn't been closed correctly."); } return new AzureSegmentArchiveReader(archiveDirectory, ioMonitor); } catch (StorageException | URISyntaxException e) { throw new IOException(e); } }
@Override public boolean hasGraph() { if (hasGraph == null) { try { getGraph(); } catch (IOException ignore) { } } return hasGraph; }
@Override public SegmentArchiveReader open(String archiveName) throws IOException { try { CloudBlobDirectory archiveDirectory = getDirectory(archiveName); if (!archiveDirectory.getBlockBlobReference("closed").exists()) { throw new IOException("The archive " + archiveName + " hasn't been closed correctly."); } return new AzureSegmentArchiveReader(archiveDirectory, ioMonitor); } catch (StorageException | URISyntaxException e) { throw new IOException(e); } }