@Test @FixFor( "MODE-1683" ) public void shouldAppendJournalEntriesBetweenRestarts() throws Exception { final List<Integer> recordsOnStartup = new ArrayList<>(2); RepositoryOperation operation = repository -> { Session session = repository.login(); session.getRootNode().addNode("node1"); session.save(); session.logout(); Thread.sleep(100); int records = repository.runningState().journal().allRecords(false).size(); assertTrue(records > 0); recordsOnStartup.add(records); }; startRunStop(operation, "config/repo-config-journaling.json"); startRunStop(operation, "config/repo-config-journaling.json"); int countFirstTime = recordsOnStartup.get(0); int countSecondTime = recordsOnStartup.get(1); assertTrue(countSecondTime > countFirstTime); }
protected void reindexSince( JcrWorkspace workspace, long timestamp ) { ChangeJournal journal = runningState.journal(); assert journal != null; Iterator<NodeKey> changedNodes = journal.changedNodesSince(timestamp); if (!changedNodes.hasNext()) { // there are no nodes which have been changed since the given timestamp return; } reindexSince(workspace.getSession().cache().getWorkspace(), getIndexWriter(), changedNodes); }
protected void reindexSince( JcrWorkspace workspace, long timestamp ) { ChangeJournal journal = runningState.journal(); assert journal != null; Iterator<NodeKey> changedNodes = journal.changedNodesSince(timestamp); if (!changedNodes.hasNext()) { // there are no nodes which have been changed since the given timestamp return; } reindexSince(workspace.getSession().cache().getWorkspace(), getIndexWriter(), changedNodes); }
switch (mode) { case INCREMENTAL: { final ChangeJournal journal = runningState.journal(); if (journal == null) { logger.warn(JcrI18n.warnIncrementalIndexingJournalNotEnabled, repoConfig.getName());
LocalJournal.Records journalRecordsReversed = repository.runningState().journal().allRecords(true);
"config/cluster/repo-config-clustered-journal-indexes.json", node2Id); assertEquals(repository1.runningState().journal().allRecords(false).size(), repository2.runningState().journal().allRecords(false).size()); Thread.sleep(300); assertEquals(repository1.runningState().journal().allRecords(false).size(), repository2.runningState().journal().allRecords(false).size()); repository2.runningState().journal().shutdown(); repository2.runningState().journal().start(); Thread.sleep(500); assertEquals(repository1.runningState().journal().allRecords(false).size(), repository2.runningState().journal().allRecords(false).size()); } finally { TestingUtil.killRepositories(repository1, repository2);
switch (mode) { case INCREMENTAL: { final ChangeJournal journal = runningState.journal(); if (journal == null) { logger.warn(JcrI18n.warnIncrementalIndexingJournalNotEnabled, repoConfig.getName());
protected final ChangeJournal journal() { return runningState().journal(); }
protected final ChangeJournal journal() { return runningState().journal(); }
@Override public Future<Boolean> reindexSinceAsync( long timestamp ) throws RepositoryException { // First check permissions ... session.checkPermission(workspaceName, Path.ROOT_PATH, ModeShapePermissions.INDEX_WORKSPACE); // then if the journal is available JcrRepository.RunningState runningState = repository().runningState(); if (runningState.journal() == null) { throw new RepositoryException(JcrI18n.cannotReindexJournalNotEnabled.text(timestamp, repository().getName())); } return runningState.queryManager().reindexSinceAsync(this, timestamp); }
@Override public Future<Boolean> reindexSinceAsync( long timestamp ) throws RepositoryException { // First check permissions ... session.checkPermission(workspaceName, Path.ROOT_PATH, ModeShapePermissions.INDEX_WORKSPACE); // then if the journal is available JcrRepository.RunningState runningState = repository().runningState(); if (runningState.journal() == null) { throw new RepositoryException(JcrI18n.cannotReindexJournalNotEnabled.text(timestamp, repository().getName())); } return runningState.queryManager().reindexSinceAsync(this, timestamp); }
protected Future<Boolean> reindexSinceAsync( final JcrWorkspace workspace, final long timestamp ) { ChangeJournal journal = runningState.journal(); assert journal != null; Iterator<NodeKey> changedNodes = journal.changedNodesSince(timestamp); if (!changedNodes.hasNext()) { // there are no nodes which have been changed since the given timestamp return new ImmediateFuture<>(Boolean.FALSE); } return reindexSinceAsync(workspace.getSession().cache().getWorkspace(), getIndexWriter(), changedNodes); }
protected Future<Boolean> reindexSinceAsync( final JcrWorkspace workspace, final long timestamp ) { ChangeJournal journal = runningState.journal(); assert journal != null; Iterator<NodeKey> changedNodes = journal.changedNodesSince(timestamp); if (!changedNodes.hasNext()) { // there are no nodes which have been changed since the given timestamp return new ImmediateFuture<>(Boolean.FALSE); } return reindexSinceAsync(workspace.getSession().cache().getWorkspace(), getIndexWriter(), changedNodes); }
@Override protected void doRun( JcrRepository repository ) { ChangeJournal journal = repository.runningState().journal(); assert journal != null; journal.removeOldRecords(); } }
@Override public void reindexSince( long timestamp ) throws RepositoryException { // First check permissions ... session.checkPermission(workspaceName, Path.ROOT_PATH, ModeShapePermissions.INDEX_WORKSPACE); // then if the journal is available JcrRepository.RunningState runningState = repository().runningState(); if (runningState.journal() == null) { throw new RepositoryException(JcrI18n.cannotReindexJournalNotEnabled.text(timestamp, repository().getName())); } runningState.queryManager().reindexSince(this, timestamp); }
@Override protected void doRun( JcrRepository repository ) { ChangeJournal journal = repository.runningState().journal(); assert journal != null; journal.removeOldRecords(); } }
@Override public void reindexSince( long timestamp ) throws RepositoryException { // First check permissions ... session.checkPermission(workspaceName, Path.ROOT_PATH, ModeShapePermissions.INDEX_WORKSPACE); // then if the journal is available JcrRepository.RunningState runningState = repository().runningState(); if (runningState.journal() == null) { throw new RepositoryException(JcrI18n.cannotReindexJournalNotEnabled.text(timestamp, repository().getName())); } runningState.queryManager().reindexSince(this, timestamp); }