use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.OakDirectory.PROP_UNSAFE_FOR_ACTIVE_DELETION in project jackrabbit-oak by apache.
the class OakDirectoryTestBase method blobsCreatedWhenActiveDeletionIsUnsafe.
// OAK-6950
@Test
public void blobsCreatedWhenActiveDeletionIsUnsafe() throws Exception {
final int fileSize = 1;
IndexDefinition def = new IndexDefinition(root, builder.getNodeState(), "/foo");
BlobFactory factory = in -> {
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(in, out);
byte[] data = out.toByteArray();
return new ArrayBasedBlob(data);
};
final AtomicBoolean markingForceActiveDeletionUnsafe = new AtomicBoolean();
OakDirectory dir = getOakDirectoryBuilder(builder, def).setReadOnly(false).with(factory).with(new ActiveDeletedBlobCollectorFactory.BlobDeletionCallback() {
@Override
public void deleted(String blobId, Iterable<String> ids) {
}
@Override
public void commitProgress(IndexProgress indexProgress) {
}
@Override
public boolean isMarkingForActiveDeletionUnsafe() {
return markingForceActiveDeletionUnsafe.get();
}
}).build();
// file1 created before marking was flagged as unsafe
writeFile(dir, "file1", fileSize);
markingForceActiveDeletionUnsafe.set(true);
// file2 created after marking was flagged as unsafe
writeFile(dir, "file2", fileSize);
dir.close();
NodeBuilder dataBuilder = builder.getChildNode(INDEX_DATA_CHILD_NAME);
assertNull("file1 must not get flagged to be unsafe to be actively deleted", dataBuilder.getChildNode("file1").getProperty(PROP_UNSAFE_FOR_ACTIVE_DELETION));
assertTrue("file2 must get flagged to be unsafe to be actively deleted", dataBuilder.getChildNode("file2").getProperty(PROP_UNSAFE_FOR_ACTIVE_DELETION).getValue(Type.BOOLEAN));
}
Aggregations