Support for out of band indexing with read only access to NodeStore
Special handling for 'head' checkpoint as this causes issue when passed as
is to DocumentNodeStore
@@ -111,16 +111,10 @@ public class OutOfBandIndexer implements Closeable, IndexUpdateCallback, NodeTra
public void reindex() throws CommitFailedException, IOException {
Stopwatch w = Stopwatch.createStarted();
- NodeState checkpointedState = indexHelper.getNodeStore().retrieve(checkpoint);
- if (checkpointedState == null && HEAD_AS_CHECKPOINT.equals(checkpoint)) {
- checkpointedState = indexHelper.getNodeStore().getRoot();
- log.warn("Using head state for indexing. Such an index cannot be imported back");
- }
+ NodeState checkpointedState = retrieveNodeStateForCheckpoint();
- checkNotNull(checkpointedState, "Not able to retrieve revision referred via checkpoint [%s]", checkpoint);
copyOnWriteStore = new MemoryNodeStore(checkpointedState);
- checkpointInfo = indexHelper.getNodeStore().checkpointInfo(checkpoint);
//TODO Check for indexPaths being empty
log.info("Proceeding to index {} upto checkpoint {} {}", indexHelper.getIndexPaths(), checkpoint, checkpointInfo);
@@ -213,6 +207,19 @@ public class OutOfBandIndexer implements Closeable, IndexUpdateCallback, NodeTra
log.info("Switched the async lane for indexes at {} to {} and marked them for reindex", indexHelper.getIndexPaths(), REINDEX_LANE);
}
+ private NodeState retrieveNodeStateForCheckpoint() {
+ NodeState checkpointedState;
+ if (HEAD_AS_CHECKPOINT.equals(checkpoint)) {
+ checkpointedState = indexHelper.getNodeStore().getRoot();
+ log.warn("Using head state for indexing. Such an index cannot be imported back");
+ } else {
+ checkpointedState = indexHelper.getNodeStore().retrieve(checkpoint);
+ checkNotNull(checkpointedState, "Not able to retrieve revision referred via checkpoint [%s]", checkpoint);
+ checkpointInfo = indexHelper.getNodeStore().checkpointInfo(checkpoint);
+ }
+ return checkpointedState;
+ }
+
/**
* Make a copy of current async value and replace it with one required for offline reindexing
*/
