@Test @FixFor( "MODE-2302" ) public void shouldRun4_0_0_Beta3_UpgradeFunction() throws Exception { FileUtil.delete("target/legacy_fs_binarystore"); String config = "config/repo-config-persistent-legacy-fsbinary.json"; // copy the test-resources legacy structure onto the configured one FileUtil.copy(new File("src/test/resources/legacy_fs_binarystore"), new File("target/legacy_fs_binarystore")); // this is coming from the test resources final BinaryKey binaryKey = new BinaryKey("ef2138973a86a8929eebe7bf52419b7cde73ba0a"); // first run is empty, so no upgrades will be performed but we'll decrement the last upgrade ID to force an upgrade next // restart startRunStop(repository -> { changeLastUpgradeId(repository, Upgrades.ModeShape_4_0_0_Beta3.INSTANCE.getId() - 1); FileSystemBinaryStore binaryStore = (FileSystemBinaryStore)repository.runningState().binaryStore(); assertFalse("No used binaries expected", binaryStore.getAllBinaryKeys().iterator().hasNext()); assertFalse("The binary should not be found", binaryStore.hasBinary(binaryKey)); File mainStorageDirectory = binaryStore.getDirectory(); File[] files = mainStorageDirectory.listFiles(); assertEquals("Just the trash directory was expected", 1, files.length); File trash = files[0]; assertTrue(trash.isDirectory()); }, config); // run the repo a second time, which should run the upgrade startRunStop(repository -> { FileSystemBinaryStore binaryStore = (FileSystemBinaryStore)repository.runningState().binaryStore(); assertFalse("No used binaries expected", binaryStore.getAllBinaryKeys().iterator().hasNext()); assertTrue("The binary should be found", binaryStore.hasBinary(binaryKey)); }, config); }
results.add(executors.submit(() -> { repository.runningState().removeSession(locker1); repository.runningState().cleanUpLocks(); return null; })); repository.runningState().removeSession(locker2); repository.runningState().cleanUpLocks(); return null; }));
private void validateCopyForExternalNode( AbstractJcrNode sourceNode, AbstractJcrNode destParentNode ) throws RepositoryException { String rootSourceKey = session.getRootNode().key().getSourceKey(); NodeKey parentKey = destParentNode.key(); if (parentKey.getSourceKey().equalsIgnoreCase(rootSourceKey)) { return; } String destExternalKey = parentKey.getSourceKey(); Connectors connectors = repository().runningState().connectors(); String destSourceName = connectors.getSourceNameAtKey(destExternalKey); Set<NodeKey> sourceKeys = session.cache().getNodeKeysAtAndBelow(sourceNode.key()); boolean sourceContainsExternalNodes = false; for (NodeKey sourceKey : sourceKeys) { String sourceNodeSourceKey = sourceKey.getSourceKey(); if (!rootSourceKey.equalsIgnoreCase(sourceNodeSourceKey)) { sourceContainsExternalNodes = true; if (!sourceNodeSourceKey.equalsIgnoreCase(destExternalKey)) { String sourceExternalSourceName = connectors.getSourceNameAtKey(sourceNodeSourceKey); throw new RepositoryException(JcrI18n.unableToCopySourceTargetMismatch.text(sourceExternalSourceName, destSourceName)); } } } String sourceNodeSourceKey = sourceNode.key().getSourceKey(); if (sourceContainsExternalNodes && !sourceNodeSourceKey.equalsIgnoreCase(destExternalKey)) { // the source graph contains external nodes, but the source itself is not an external node throw new RepositoryException(JcrI18n.unableToCopySourceNotExternal.text(sourceNode.path())); } }
warn(JcrI18n.storageRelatedConfigurationChangesWillTakeEffectAfterShutdown, getName()); warn(JcrI18n.storageRelatedConfigurationChangesWillTakeEffectAfterShutdown, getName()); this.documentStore = other.documentStore; this.txMgrLookup = other.txMgrLookup; this.txnMgr = other.txnManager(); this.transactions = other.transactions; suspendExistingUserTransaction(); this.schematicDb = environment().getDb(config.getPersistenceConfiguration()); this.txMgrLookup = config.getTransactionManagerLookup(); this.txnMgr = this.txMgrLookup.getTransactionManager(); this.transactions = createTransactions(this.txnMgr, schematicDb); this.connectors = new Connectors(this, config.getFederation(), problems); if (clustering.isEnabled()) { final String clusterName = clustering.getClusterName(); Channel channel = environment().getChannel(clusterName); if (channel != null) { this.clusteringService = ClusteringService.startStandalone(clusterName, channel); suspendExistingUserTransaction(); this.changeDispatchingQueue = this.context().getCachedTreadPool("modeshape-event-dispatcher", Integer.MAX_VALUE); ChangeBus localBus = new RepositoryChangeBus(name(), changeDispatchingQueue, statistics(), config.getEventBusSize()); this.changeBus = clusteringService != null ? new ClusteredChangeBus(localBus, clusteringService) : localBus;
warn(JcrI18n.storageRelatedConfigurationChangesWillTakeEffectAfterShutdown, getName()); warn(JcrI18n.storageRelatedConfigurationChangesWillTakeEffectAfterShutdown, getName()); this.documentStore = other.documentStore; this.txMgrLookup = other.txMgrLookup; this.txnMgr = other.txnManager(); this.transactions = other.transactions; suspendExistingUserTransaction(); this.schematicDb = environment().getDb(config.getPersistenceConfiguration()); this.txMgrLookup = config.getTransactionManagerLookup(); this.txnMgr = this.txMgrLookup.getTransactionManager(); this.transactions = createTransactions(this.txnMgr, schematicDb); this.connectors = new Connectors(this, config.getFederation(), problems); if (clustering.isEnabled()) { final String clusterName = clustering.getClusterName(); Channel channel = environment().getChannel(clusterName); if (channel != null) { this.clusteringService = ClusteringService.startStandalone(clusterName, channel); suspendExistingUserTransaction(); this.changeDispatchingQueue = this.context().getCachedTreadPool("modeshape-event-dispatcher", Integer.MAX_VALUE); ChangeBus localBus = new RepositoryChangeBus(name(), changeDispatchingQueue, statistics(), config.getEventBusSize()); this.changeBus = clusteringService != null ? new ClusteredChangeBus(localBus, clusteringService) : localBus;
sourceSession.cache(), repository().systemWorkspaceKey(), repository().runningState().connectors());
sourceSession.cache(), repository().systemWorkspaceKey(), repository().runningState().connectors());
Connectors connectors = repository().runningState().connectors(); if (sourceContainsExternalNodes && !targetIsExternal) { String sourceName = connectors.getSourceNameAtKey(externalSourceKey);
Connectors connectors = repository().runningState().connectors(); if (sourceContainsExternalNodes && !targetIsExternal) { String sourceName = connectors.getSourceNameAtKey(externalSourceKey);
repository.runningState().removeSession(locker1); repository.runningState().cleanUpLocks();
if (!validate || repository.documentStore().containsKey(externalNodeKeyString)) { result.add(projection); } else { SessionCache sessionCache = repository.repositoryCache().createSession(repository.context(), wsName, false); MutableCachedNode parentNode = sessionCache.mutable(projectedNodeKey); parentNode.removeFederatedSegment(externalNodeKeyString);
if (!validate || repository.documentStore().containsKey(externalNodeKeyString)) { result.add(projection); } else { SessionCache sessionCache = repository.repositoryCache().createSession(repository.context(), wsName, false); MutableCachedNode parentNode = sessionCache.mutable(projectedNodeKey); parentNode.removeFederatedSegment(externalNodeKeyString);
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);
assert state.get() == State.RUNNING; RunningState newState = new RunningState(oldState, configChanges); this.runningState.set(newState);
assert state.get() == State.RUNNING; RunningState newState = new RunningState(oldState, configChanges); this.runningState.set(newState);
switch (mode) { case INCREMENTAL: { final ChangeJournal journal = runningState.journal(); if (journal == null) { logger.warn(JcrI18n.warnIncrementalIndexingJournalNotEnabled, repoConfig.getName());
protected void deepClone( JcrSession sourceSession, NodeKey sourceNodeKey, JcrSession cloneSession, NodeKey cloneNodeKey ) throws RepositoryException { assert !cloneSession.cache().isReadOnly(); SessionCache sourceCache = sourceSession.cache(); CachedNode sourceNode = sourceCache.getNode(sourceNodeKey); SessionCache cloneCache = cloneSession.cache(); MutableCachedNode mutableCloneNode = cloneSession.node(cloneNodeKey, null).mutable(); /** * Perform the clone at the cache level - clone all properties & children */ mutableCloneNode.deepClone(cloneCache, sourceNode, sourceCache, repository().systemWorkspaceKey(), repository().runningState().connectors()); /** * Make sure the version history is preserved */ cloneSession.initBaseVersionKeys(); Set<NodeKey> sourceKeys = sourceCache.getNodeKeysAtAndBelow(sourceNodeKey); for (NodeKey sourceKey : sourceKeys) { AbstractJcrNode srcNode = sourceSession.node(sourceKey, null); if (srcNode.isNodeType(JcrMixLexicon.VERSIONABLE)) { // Preserve the base version of the versionable nodes (this will in turn preserve the version history) cloneSession.setDesiredBaseVersionKey(sourceKey, srcNode.getBaseVersion().key()); } } cloneSession.save(); }
protected void deepClone( JcrSession sourceSession, NodeKey sourceNodeKey, JcrSession cloneSession, NodeKey cloneNodeKey ) throws RepositoryException { assert !cloneSession.cache().isReadOnly(); SessionCache sourceCache = sourceSession.cache(); CachedNode sourceNode = sourceCache.getNode(sourceNodeKey); SessionCache cloneCache = cloneSession.cache(); MutableCachedNode mutableCloneNode = cloneSession.node(cloneNodeKey, null).mutable(); /** * Perform the clone at the cache level - clone all properties & children */ mutableCloneNode.deepClone(cloneCache, sourceNode, sourceCache, repository().systemWorkspaceKey(), repository().runningState().connectors()); /** * Make sure the version history is preserved */ cloneSession.initBaseVersionKeys(); Set<NodeKey> sourceKeys = sourceCache.getNodeKeysAtAndBelow(sourceNodeKey); for (NodeKey sourceKey : sourceKeys) { AbstractJcrNode srcNode = sourceSession.node(sourceKey, null); if (srcNode.isNodeType(JcrMixLexicon.VERSIONABLE)) { // Preserve the base version of the versionable nodes (this will in turn preserve the version history) cloneSession.setDesiredBaseVersionKey(sourceKey, srcNode.getBaseVersion().key()); } } cloneSession.save(); }