use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method reference.
@Test
public void reference() throws Exception {
LOG.info("Starting reference");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
// Record still in staging
DataRecord rec = dataStore.addRecord(fin);
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
//start & finish
taskLatch.countDown();
callbackLatch.countDown();
waitFinish();
// Now record in download cache
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
LOG.info("Finished reference");
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method syncAddGetDelete.
/**
* Add, get, delete with synchronous option.
* @throws Exception
*/
@Test
public void syncAddGetDelete() throws Exception {
LOG.info("Starting syncAddGetDelete");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
DataRecord rec = dataStore.addRecord(fin, new BlobOptions().setUpload(SYNCHRONOUS));
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(1, Iterators.size(dataStore.getAllIdentifiers()));
dataStore.deleteRecord(new DataIdentifier(id));
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNull(rec);
LOG.info("Finished syncAddGetDelete");
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class OakFileDataStore method getAllMetadataRecords.
@Override
public List<DataRecord> getAllMetadataRecords(String prefix) {
File root = new File(getPath());
List<DataRecord> rootRecords = new ArrayList<DataRecord>();
for (File file : FileFilterUtils.filterList(FileFilterUtils.prefixFileFilter(prefix), root.listFiles())) {
if (!file.isDirectory()) {
// skip directories which are actual data store files
rootRecords.add(new FileDataRecord(this, new DataIdentifier(file.getName()), file));
}
}
return rootRecords;
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method addDelete.
/**
* Add in datastore.
*/
@Test
public void addDelete() throws Exception {
LOG.info("Starting addDelete");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
DataRecord rec = dataStore.addRecord(fin);
assertEquals(id, rec.getIdentifier().toString());
//start & finish
taskLatch.countDown();
callbackLatch.countDown();
waitFinish();
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
dataStore.deleteRecord(new DataIdentifier(id));
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNull(rec);
LOG.info("Finished addDelete");
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method referenceNoCache.
@Test
public void referenceNoCache() throws Exception {
LOG.info("Starting referenceNoCache");
dataStore.close();
init(1, 0, 0);
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
// Record still in staging
DataRecord rec = dataStore.addRecord(fin);
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
LOG.info("Finished referenceNoCache");
}
Aggregations