You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by to...@apache.org on 2018/04/11 12:47:00 UTC
svn commit: r1828899 - in
/jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure:
AzureArchiveManager.java AzureSegmentArchiveReader.java AzureUtilities.java
Author: tomekr
Date: Wed Apr 11 12:47:00 2018
New Revision: 1828899
URL: http://svn.apache.org/viewvc?rev=1828899&view=rev
Log:
OAK-7403: AzureSegmentArchiveReader should get the metadata from listBlobs() operation
Modified:
jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java
jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveReader.java
jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureUtilities.java
Modified: jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java?rev=1828899&r1=1828898&r2=1828899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java (original)
+++ jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java Wed Apr 11 12:47:00 2018
@@ -91,7 +91,7 @@ public class AzureArchiveManager impleme
if (!archiveDirectory.getBlockBlobReference("closed").exists()) {
throw new IOException("The archive " + archiveName + " hasn't been closed correctly.");
}
- return new AzureSegmentArchiveReader(archiveDirectory, ioMonitor, monitor);
+ return new AzureSegmentArchiveReader(archiveDirectory, ioMonitor);
} catch (StorageException | URISyntaxException e) {
throw new IOException(e);
}
Modified: jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveReader.java?rev=1828899&r1=1828898&r2=1828899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveReader.java (original)
+++ jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentArchiveReader.java Wed Apr 11 12:47:00 2018
@@ -21,7 +21,6 @@ import com.microsoft.azure.storage.Stora
import com.microsoft.azure.storage.blob.CloudBlob;
import com.microsoft.azure.storage.blob.CloudBlobDirectory;
import com.microsoft.azure.storage.blob.CloudBlockBlob;
-import org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitor;
import org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitor;
import org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveEntry;
import org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveReader;
@@ -47,31 +46,23 @@ public class AzureSegmentArchiveReader i
private final IOMonitor ioMonitor;
- private final FileStoreMonitor monitor;
-
private final long length;
private final Map<UUID, AzureSegmentArchiveEntry> index = new LinkedHashMap<>();
private Boolean hasGraph;
- AzureSegmentArchiveReader(CloudBlobDirectory archiveDirectory, IOMonitor ioMonitor, FileStoreMonitor monitor) throws IOException {
+ AzureSegmentArchiveReader(CloudBlobDirectory archiveDirectory, IOMonitor ioMonitor) throws IOException {
this.archiveDirectory = archiveDirectory;
this.ioMonitor = ioMonitor;
- this.monitor = monitor;
long length = 0;
- try {
- for (CloudBlob blob : AzureUtilities.getBlobs(archiveDirectory).collect(Collectors.toList())) {
- blob.downloadAttributes();
- Map<String, String> metadata = blob.getMetadata();
- if (AzureBlobMetadata.isSegment(metadata)) {
- AzureSegmentArchiveEntry indexEntry = AzureBlobMetadata.toIndexEntry(metadata, (int) blob.getProperties().getLength());
- index.put(new UUID(indexEntry.getMsb(), indexEntry.getLsb()), indexEntry);
- }
- length += blob.getProperties().getLength();
+ for (CloudBlob blob : AzureUtilities.getBlobs(archiveDirectory).collect(Collectors.toList())) {
+ Map<String, String> metadata = blob.getMetadata();
+ if (AzureBlobMetadata.isSegment(metadata)) {
+ AzureSegmentArchiveEntry indexEntry = AzureBlobMetadata.toIndexEntry(metadata, (int) blob.getProperties().getLength());
+ index.put(new UUID(indexEntry.getMsb(), indexEntry.getLsb()), indexEntry);
}
- } catch (StorageException e) {
- throw new IOException(e);
+ length += blob.getProperties().getLength();
}
this.length = length;
}
@@ -131,7 +122,7 @@ public class AzureSegmentArchiveReader i
}
@Override
- public void close() throws IOException {
+ public void close() {
// do nothing
}
Modified: jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureUtilities.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureUtilities.java?rev=1828899&r1=1828898&r2=1828899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureUtilities.java (original)
+++ jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureUtilities.java Wed Apr 11 12:47:00 2018
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.oak.segment.azure;
import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.blob.BlobListingDetails;
import com.microsoft.azure.storage.blob.CloudBlob;
import com.microsoft.azure.storage.blob.CloudBlobDirectory;
@@ -24,6 +25,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.nio.file.Paths;
+import java.util.EnumSet;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -54,7 +56,7 @@ public final class AzureUtilities {
public static Stream<CloudBlob> getBlobs(CloudBlobDirectory directory) throws IOException {
try {
- return StreamSupport.stream(directory.listBlobs().spliterator(), false)
+ return StreamSupport.stream(directory.listBlobs(null, false, EnumSet.of(BlobListingDetails.METADATA), null, null).spliterator(), false)
.filter(i -> i instanceof CloudBlob)
.map(i -> (CloudBlob) i);
} catch (StorageException | URISyntaxException e) {
@@ -62,19 +64,6 @@ public final class AzureUtilities {
}
}
- public static long getDirectorySize(CloudBlobDirectory directory) throws IOException {
- long size = 0;
- for (CloudBlob b : getBlobs(directory).collect(Collectors.toList())) {
- try {
- b.downloadAttributes();
- } catch (StorageException e) {
- throw new IOException(e);
- }
- size += b.getProperties().getLength();
- }
- return size;
- }
-
public static void readBufferFully(CloudBlob blob, ByteBuffer buffer) throws IOException {
try {
buffer.rewind();