use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class AzureBlobStoreBackend method getAllMetadataRecords.
@Override
public List<DataRecord> getAllMetadataRecords(String prefix) {
if (null == prefix) {
throw new NullPointerException("prefix");
}
long start = System.currentTimeMillis();
final List<DataRecord> records = Lists.newArrayList();
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
CloudBlobDirectory metaDir = getAzureContainer().getDirectoryReference(META_DIR_NAME);
for (ListBlobItem item : metaDir.listBlobs(prefix)) {
if (item instanceof CloudBlob) {
CloudBlob blob = (CloudBlob) item;
records.add(new AzureBlobStoreDataRecord(this, connectionString, containerName, new DataIdentifier(stripMetaKeyPrefix(blob.getName())), blob.getProperties().getLastModified().getTime(), blob.getProperties().getLength(), true));
}
}
LOG.debug("Metadata records read. recordsRead={} metadataFolder={} duration={}", records.size(), prefix, (System.currentTimeMillis() - start));
} catch (StorageException e) {
LOG.info("Error reading all metadata records. metadataFolder={}", prefix, e);
} catch (DataStoreException | URISyntaxException e) {
LOG.debug("Error reading all metadata records. metadataFolder={}", prefix, e);
} finally {
if (null != contextClassLoader) {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
return records;
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class AzureDataStoreTest method testCreateAndDeleteBlobHappyPath.
@Test
public void testCreateAndDeleteBlobHappyPath() throws DataStoreException, IOException {
final DataRecord uploadedRecord = ds.addRecord(new ByteArrayInputStream(testBuffer));
DataIdentifier identifier = uploadedRecord.getIdentifier();
assertTrue(backend.exists(identifier));
assertTrue(0 != uploadedRecord.getLastModified());
assertEquals(testBuffer.length, uploadedRecord.getLength());
final DataRecord retrievedRecord = ds.getRecord(identifier);
validateRecord(retrievedRecord, new String(testBuffer), uploadedRecord);
ds.deleteRecord(identifier);
assertFalse(backend.exists(uploadedRecord.getIdentifier()));
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class AzureDataStoreTest method testCreateAndReUploadBlob.
@Test
public void testCreateAndReUploadBlob() throws DataStoreException, IOException {
final DataRecord createdRecord = ds.addRecord(new ByteArrayInputStream(testBuffer));
DataIdentifier identifier1 = createdRecord.getIdentifier();
assertTrue(backend.exists(identifier1));
final DataRecord record1 = ds.getRecord(identifier1);
validateRecord(record1, new String(testBuffer), createdRecord);
try {
Thread.sleep(1001);
} catch (InterruptedException e) {
}
final DataRecord updatedRecord = ds.addRecord(new ByteArrayInputStream(testBuffer));
DataIdentifier identifier2 = updatedRecord.getIdentifier();
assertTrue(backend.exists(identifier2));
assertTrue(identifier1.toString().equals(identifier2.toString()));
validateRecord(record1, new String(testBuffer), createdRecord);
ds.deleteRecord(identifier1);
assertFalse(backend.exists(createdRecord.getIdentifier()));
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class TestS3DataStore method testNoSecretDefined.
@Test
public void testNoSecretDefined() throws Exception {
assumeTrue(isS3Configured());
assumeTrue(s3Class.equals(S3DataStoreUtils.JR2_S3.getName()));
Random randomGen = new Random();
props = S3DataStoreUtils.getS3Config();
ds = getS3DataStore(s3Class, props, dataStoreDir.getAbsolutePath());
byte[] data = new byte[4096];
randomGen.nextBytes(data);
DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
assertEquals(data.length, rec.getLength());
assertNull(rec.getReference());
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class DataStoreBlobStore method getBlobId.
@Override
public String getBlobId(@Nonnull String reference) {
checkNotNull(reference);
DataRecord record;
try {
record = delegate.getRecordFromReference(reference);
if (record != null) {
return getBlobId(record);
}
} catch (DataStoreException e) {
log.warn("Unable to access the blobId for [{}]", reference, e);
}
return null;
}
Aggregations