本文整理了Java中org.apache.jackrabbit.core.data.DataStore
类的一些代码示例,展示了DataStore
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataStore
类的具体详情如下:
包路径:org.apache.jackrabbit.core.data.DataStore
类名称:DataStore
[英]Append-only store for binary streams. A data store consists of a number of identifiable data records that each contain a distinct binary stream. New binary streams can be added to the data store, but existing streams are never removed or modified.
A data store should be fully thread-safe, i.e. it should be possible to add and access data records concurrently. Optimally even separate processes should be able to concurrently access the data store with zero interprocess synchronization.
[中]仅为二进制流附加存储。数据存储由许多可识别的数据记录组成,每个记录都包含一个不同的二进制流。可以将新的二进制流添加到数据存储中,但不会删除或修改现有流。
数据存储应该是完全线程安全的,即应该可以同时添加和访问数据记录。最理想的情况是,即使是单独的进程也应该能够在零进程间同步的情况下并发访问数据存储。
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void close() throws DataStoreException {
delegate.close();
cache.invalidateAll();
closeQuietly(tracker);
}
代码示例来源:origin: org.apache.jackrabbit/oak-blob-plugins
@Nullable
@Override
public DataRecord apply(@Nullable DataIdentifier input) {
try {
return delegate.getRecord(input);
} catch (DataStoreException e) {
log.warn("Error occurred while fetching DataRecord for identifier {}", input, e);
}
return null;
}
});
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-data
/**
* Delete objects that have a modified date older than the specified date
* from the archive data store.
*
* @param min
* the minimum time
* @return the number of data records deleted
* @throws DataStoreException
*/
public int deleteAllOlderThan(long min) throws DataStoreException {
return archiveDataStore.deleteAllOlderThan(min);
}
代码示例来源:origin: apache/jackrabbit-oak
byte[] data = new byte[dataLength];
random.nextBytes(data);
DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data));
DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data));
ds.updateModifiedDateOnAccess(updateTime);
data = new byte[dataLength];
random.nextBytes(data);
DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data));
DataRecord rec4 = ds.addRecord(new ByteArrayInputStream(data));
rec1 = ds.getRecord(rec1.getIdentifier());
ds.clearInUse();
Assert.assertEquals("only rec2 should be deleted", 1,
ds.deleteAllOlderThan(updateTime));
assertNull("rec2 should be null",
ds.getRecordIfStored(rec2.getIdentifier()));
Iterator<DataIdentifier> itr = ds.getAllIdentifiers();
List<DataIdentifier> list = new ArrayList<DataIdentifier>();
list.add(rec1.getIdentifier());
代码示例来源:origin: apache/jackrabbit
/**
* Test {@link DataStore#getRecord(DataIdentifier)} and assert length and
* inputstream.
*/
protected void doGetRecordTest() throws Exception {
ds = createDataStore();
byte[] data = new byte[dataLength];
randomGen.nextBytes(data);
DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
rec = ds.getRecord(rec.getIdentifier());
assertEquals(data.length, rec.getLength());
assertRecord(data, rec);
ds.close();
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Test {@link MultiDataStoreAware#deleteRecord(DataIdentifier)}.
*/
protected void doDeleteRecordTest() throws Exception {
Random random = randomGen;
byte[] data1 = new byte[dataLength];
random.nextBytes(data1);
DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data1));
byte[] data2 = new byte[dataLength];
random.nextBytes(data2);
DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data2));
byte[] data3 = new byte[dataLength];
random.nextBytes(data3);
DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data3));
((MultiDataStoreAware)ds).deleteRecord(rec1.getIdentifier());
assertNull("rec1 should be null",
ds.getRecordIfStored(rec1.getIdentifier()));
assertEquals(new ByteArrayInputStream(data2),
ds.getRecord(rec2.getIdentifier()).getStream());
assertEquals(new ByteArrayInputStream(data3),
ds.getRecord(rec3.getIdentifier()).getStream());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testReference() throws DataStoreException, IOException {
String reference = "testReference";
String blobId = "test";
DataIdentifier testDI = new DataIdentifier(blobId);
DataRecord testDR = new ByteArrayDataRecord("foo".getBytes(), testDI, reference);
DataStore mockedDS = mock(DataStore.class);
when(mockedDS.getRecordFromReference(reference)).thenReturn(testDR);
when(mockedDS.getRecord(testDI)).thenReturn(testDR);
when(mockedDS.getRecordIfStored(testDI)).thenReturn(testDR);
DataStoreBlobStore ds = new DataStoreBlobStore(mockedDS);
assertEquals(reference,ds.getReference(blobId));
assertEquals(blobId, BlobId.of(ds.getBlobId(reference)).blobId);
assertEquals(BlobId.of(testDR).encodedValue(),ds.getBlobId(reference));
String inMemBlobId = InMemoryDataRecord.getInstance("foo".getBytes())
.getIdentifier().toString();
//For in memory record the reference should be null
assertNull(ds.getReference(inMemBlobId));
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override
public DataRecord addRecord(InputStream input, BlobOptions options) throws DataStoreException {
if (delegate instanceof TypedDataStore) {
return ((TypedDataStore) delegate).addRecord(input, options);
}
return delegate.addRecord(input);
}
代码示例来源:origin: apache/jackrabbit
/**
* Test if record can be accessed via
* {@link DataStore#getRecordFromReference(String)}
*/
protected void doReferenceTest() throws Exception {
ds = createDataStore();
byte[] data = new byte[dataLength];
randomGen.nextBytes(data);
String reference;
DataRecord record = ds.addRecord(new ByteArrayInputStream(data));
reference = record.getReference();
assertReference(data, reference, ds);
ds.close();
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Test {@link DataStore#getRecord(DataIdentifier)} and assert length and
* inputstream.
*/
protected void doGetRecordTest() throws Exception {
byte[] data = new byte[dataLength];
randomGen.nextBytes(data);
DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
rec = ds.getRecord(rec.getIdentifier());
Assert.assertEquals(data.length, rec.getLength());
assertRecord(data, rec);
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public BlobStore setUp() {
String className = System.getProperty("dataStore");
checkNotNull(className, "No system property named 'dataStore' defined");
try {
dataStore = Class.forName(className).asSubclass(DataStore.class).newInstance();
config = getConfig();
configure(dataStore, config);
dataStore = configureIfCloudDataStore(className, dataStore, config, unique.toLowerCase(), statisticsProvider);
storeDir = new File(basedir, unique);
dataStore.init(storeDir.getAbsolutePath());
blobStore = new DataStoreBlobStore(dataStore, true, fdsCacheInMB);
configure(blobStore);
return blobStore;
} catch (Exception e) {
throw new IllegalStateException("Cannot instantiate DataStore " + className, e);
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-blob-plugins
@Override
public void updateModifiedDateOnAccess(long before) {
delegate.updateModifiedDateOnAccess(before);
}
代码示例来源:origin: apache/jackrabbit
/**
* Get all identifiers from the archive data store.
*
* @return an iterator over all DataIdentifier objects
* @throws DataStoreException
* if the list could not be read
*/
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException {
return archiveDataStore.getAllIdentifiers();
}
代码示例来源:origin: apache/jackrabbit
public DataRecord getRecordFromReference(String reference)
throws DataStoreException {
DataRecord record = primaryDataStore.getRecordFromReference(reference);
if (record == null) {
record = archiveDataStore.getRecordFromReference(reference);
}
return record;
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-data
/**
* {@inheritDoc}
*/
public void clearInUse() {
archiveDataStore.clearInUse();
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void assertReferenceKey() throws Exception {
byte[] data = new byte[dataLength];
randomGen.nextBytes(data);
DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
Assert.assertEquals(data.length, rec.getLength());
assertRecord(data, rec);
DataRecord refRec = ds.getRecordFromReference(rec.getReference());
assertRecord(data, refRec);
// Check bytes retrieved from reference.key file
File refFile = new File(fsBackendPath, "reference.key");
assertTrue(refFile.exists());
byte[] keyRet = FileUtils.readFileToByteArray(refFile);
assertTrue(keyRet.length != 0);
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public String getReference(@NotNull String encodedBlobId) {
checkNotNull(encodedBlobId);
String blobId = extractBlobId(encodedBlobId);
//Reference are not created for in memory record
if (InMemoryDataRecord.isInstance(blobId)) {
return null;
}
DataRecord record;
try {
record = delegate.getRecordIfStored(new DataIdentifier(blobId));
if (record != null) {
return record.getReference();
} else {
log.debug("No blob found for id [{}]", blobId);
}
} catch (DataStoreException e) {
log.warn("Unable to access the blobId for [{}]", blobId, e);
}
return null;
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public DataRecord addRecord(InputStream input, BlobOptions options) throws DataStoreException {
if (delegate instanceof TypedDataStore) {
return ((TypedDataStore) delegate).addRecord(input, options);
}
return delegate.addRecord(input);
}
代码示例来源:origin: apache/jackrabbit
/**
* Test {@link DataStore#addRecord(InputStream)} and assert length of added
* record.
*/
protected void doAddRecordTest() throws Exception {
ds = createDataStore();
byte[] data = new byte[dataLength];
randomGen.nextBytes(data);
DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
assertEquals(data.length, rec.getLength());
assertRecord(data, rec);
ds.close();
}
代码示例来源:origin: org.apache.jackrabbit/oak-run-commons
@Override
public BlobStore setUp() {
String className = System.getProperty("dataStore");
checkNotNull(className, "No system property named 'dataStore' defined");
try {
dataStore = Class.forName(className).asSubclass(DataStore.class).newInstance();
config = getConfig();
configure(dataStore, config);
dataStore = configureIfCloudDataStore(className, dataStore, config, unique.toLowerCase(), statisticsProvider);
storeDir = new File(basedir, unique);
dataStore.init(storeDir.getAbsolutePath());
blobStore = new DataStoreBlobStore(dataStore, true, fdsCacheInMB);
configure(blobStore);
return blobStore;
} catch (Exception e) {
throw new IllegalStateException("Cannot instantiate DataStore " + className, e);
}
}
内容来源于网络,如有侵权,请联系作者删除!