amit-jain commented on code in PR #2409:
URL: https://github.com/apache/jackrabbit-oak/pull/2409#discussion_r2415573540
##########
oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackend.java:
##########
@@ -468,75 +385,69 @@ public DataRecord getRecord(DataIdentifier identifier)
throws DataStoreException
}
@Override
- public Iterator<DataIdentifier> getAllIdentifiers() {
- return new RecordsIterator<>(
- input -> new
DataIdentifier(getIdentifierName(input.getName())));
+ public Iterator<DataIdentifier> getAllIdentifiers() throws
DataStoreException {
+ return getAzureContainer().listBlobs().stream()
+ .map(blobItem -> new
DataIdentifier(getIdentifierName(blobItem.getName())))
+ .iterator();
}
-
-
@Override
- public Iterator<DataRecord> getAllRecords() {
+ public Iterator<DataRecord> getAllRecords() throws DataStoreException {
final AbstractSharedBackend backend = this;
- return new RecordsIterator<>(
- input -> new AzureBlobStoreDataRecord(
+ final BlobContainerClient containerClient = getAzureContainer();
+ return containerClient.listBlobs().stream()
+ .map(blobItem -> (DataRecord) new AzureBlobStoreDataRecord(
backend,
azureBlobContainerProvider,
- new DataIdentifier(getIdentifierName(input.getName())),
- input.getLastModified(),
- input.getLength())
- );
+ new
DataIdentifier(getIdentifierName(blobItem.getName())),
+
getLastModified(containerClient.getBlobClient(blobItem.getName()).getBlockBlobClient()),
+ blobItem.getProperties().getContentLength()))
+ .iterator();
}
@Override
public boolean exists(DataIdentifier identifier) throws DataStoreException
{
- long start = System.currentTimeMillis();
+ Stopwatch stopwatch = Stopwatch.createStarted();
String key = getKeyName(identifier);
ClassLoader contextClassLoader =
Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- boolean exists
=getAzureContainer().getBlockBlobReference(key).exists();
- LOG.debug("Blob exists={} identifier={} duration={}", exists, key,
(System.currentTimeMillis() - start));
+ boolean exists =
getAzureContainer().getBlobClient(key).getBlockBlobClient().exists();
+ LOG.debug("Blob exists={} identifier={} duration={}", exists, key,
stopwatch.elapsed(TimeUnit.MILLISECONDS));
return exists;
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new DataStoreException(e);
- }
- finally {
- if (null != contextClassLoader) {
+ } finally {
+ if (contextClassLoader != null) {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
}
@Override
- public void close() throws DataStoreException {
+ public void close(){
Review Comment:
```suggestion
public void close() {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]