Permalink
Browse files

MODE-1693 - Added special handling to the case when transactions are …

…not configured: a dedicated exception should be thrown
  • Loading branch information...
1 parent 25eff0c commit c71173f290c46a709fecd6ac49cab3f7ceeac144 Horia Chiorean committed Nov 13, 2012
@@ -43,6 +43,7 @@
public static I18n repositoryCannotBeRestartedAfterRestore;
public static I18n repositoryIsCurrentlyBeingRestored;
public static I18n repositoryIsBeingRestoredAndCannotBeStarted;
+ public static I18n repositoryCannotBeStartedWithoutTransactionalSupport;
public static I18n repositoryReferencesNonExistantSource;
public static I18n indexRebuildingStarted;
public static I18n indexRebuildingComplete;
@@ -1011,6 +1011,7 @@ protected RunningState( JcrRepository.RunningState other,
this.context = other.context;
this.database = other.database;
this.txnMgr = database.getCache().getAdvancedCache().getTransactionManager();
+ validateTransactionsEnabled();
MonitorFactory monitorFactory = new RepositoryMonitorFactory(this);
this.transactions = createTransactions(config.getTransactionMode(), monitorFactory, this.txnMgr);
if (change.largeValueChanged) {
@@ -1042,6 +1043,7 @@ protected RunningState( JcrRepository.RunningState other,
this.database = Schematic.get(container, cacheName);
assert this.database != null;
this.txnMgr = this.database.getCache().getAdvancedCache().getTransactionManager();
+ validateTransactionsEnabled();
MonitorFactory monitorFactory = new RepositoryMonitorFactory(this);
this.transactions = createTransactions(config.getTransactionMode(), monitorFactory, this.txnMgr);
@@ -1210,6 +1212,12 @@ public void submit( final SequencingWorkItem work ) {
this.nodeTypesImporter = new NodeTypesImporter(config.getNodeTypes(), this);
}
+ private void validateTransactionsEnabled() {
+ if (txnMgr == null) {
+ throw new IllegalStateException(JcrI18n.repositoryCannotBeStartedWithoutTransactionalSupport.text(getName()));
+ }
+ }
+
protected Transactions createTransactions( TransactionMode mode,
MonitorFactory monitorFactory,
TransactionManager txnMgr ) {
@@ -33,6 +33,7 @@ repositoryCannotBeRestored = The '{0}' repository cannot be restored: {1}
repositoryCannotBeRestartedAfterRestore = The '{0}' repository cannot be restarted after being restored: {1}
repositoryIsBeingRestoredAndCannotBeStarted = The '{0}' repository is being restored and may not be started
repositoryIsCurrentlyBeingRestored = The '{0}' repository is currently being restored
+repositoryCannotBeStartedWithoutTransactionalSupport = The '{0}' repository cannot be started because transactions are not enabled. Please check your configuration.
repositoryReferencesNonExistantSource = The '{0}' repository references the '{1}' repository source that does not exist
indexRebuildingStarted = Started rebuilding indexes for repository '{0}'
indexRebuildingComplete = Completed rebuilding indexes for repository '{0}'
@@ -23,8 +23,6 @@
*/
package org.modeshape.jcr;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
import java.io.File;
import java.util.UUID;
import javax.jcr.NoSuchWorkspaceException;
@@ -33,18 +31,20 @@
import org.junit.Test;
import org.modeshape.common.FixFor;
import org.modeshape.common.util.FileUtil;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
/**
* Tests that related to repeatedly starting/stopping repositories (without another repository configured in the @Before and @After
* methods).
- *
+ *
* @author rhauch
* @author hchiorean
*/
public class JcrRepositoryStartupTest extends MultiPassAbstractTest {
@Test
- @FixFor( {"MODE-1526", "MODE-1512", "MODE-1617"} )
+ @FixFor( { "MODE-1526", "MODE-1512", "MODE-1617" } )
public void shouldKeepPersistentDataAcrossRestart() throws Exception {
File contentFolder = new File("target/persistent_repository/store/persistentRepository");
@@ -152,4 +152,10 @@ public Void call() throws Exception {
}
}, repositoryConfigFile);
}
+
+ @FixFor( "MODE-1693" )
+ @Test(expected = IllegalStateException.class)
+ public void shouldNotStartIfTransactionsArentEnabled() throws Exception {
+ startRunStop(null, "config/repo-config-no-transactions.json");
+ }
}
@@ -0,0 +1,18 @@
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
+ xmlns="urn:infinispan:config:5.1">
+ <global/>
+ <namedCache name="NoTxRepository">
+ <eviction strategy="LIRS" maxEntries="1000" />
+ <loaders passivation="false" shared="false" preload="true">
+ <loader class="org.infinispan.loaders.file.FileCacheStore"
+ fetchPersistentState="true" purgerThreads="3"
+ purgeSynchronously="true" ignoreModifications="false"
+ purgeOnStartup="false">
+ <properties>
+ <property name="location" value="NoTxRepository/storage" />
+ </properties>
+ </loader>
+ </loaders>
+ </namedCache>
+</infinispan>
@@ -0,0 +1,7 @@
+{
+ "name" : "RepositoryWithoutTransactions",
+ "storage" : {
+ "cacheName" : "NoTxRepository",
+ "cacheConfiguration" : "config/no_tx_cache_configuration.xml"
+ }
+}

0 comments on commit c71173f

Please sign in to comment.