Author: reschke
Date: Thu Sep 24 13:37:04 2015
New Revision: 1705055
URL: http://svn.apache.org/viewvc?rev=1705055&view=rev
Log:
OAK-3420: DocumentNodeStoreService: never attempt to re-register a
DocmentNodeStore
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java?rev=1705055&r1=1705054&r2=1705055&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
Thu Sep 24 13:37:04 2015
@@ -261,6 +261,7 @@ public class DocumentNodeStoreService {
private ObserverTracker observerTracker;
private ComponentContext context;
private Whiteboard whiteboard;
+ private long deactivationTimestamp = 0;
/**
@@ -327,7 +328,10 @@ public class DocumentNodeStoreService {
}
private void registerNodeStoreIfPossible() throws IOException {
- if (context == null) {
+ // disallow attempts to restart (OAK-3420)
+ if (deactivationTimestamp != 0) {
+ log.info("DocumentNodeStore was already unregistered ({}ms ago)",
System.currentTimeMillis() - deactivationTimestamp);
+ } else if (context == null) {
log.info("Component still not activated. Ignoring the
initialization call");
} else if (customBlobStore && blobStore == null) {
log.info("Custom BlobStore use enabled. DocumentNodeStoreService
would be initialized when "
@@ -543,6 +547,8 @@ public class DocumentNodeStoreService {
}
private void unregisterNodeStore() {
+ deactivationTimestamp = System.currentTimeMillis();
+
for (Registration r : registrations) {
r.unregister();
}
Modified:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy?rev=1705055&r1=1705054&r2=1705055&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
(original)
+++
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
Thu Sep 24 13:37:04 2015
@@ -76,6 +76,11 @@ abstract class AbstractRepositoryFactory
return ((ServiceRegistryProvider) repository).getServiceRegistry()
}
+ protected <T> void assertNoService(Class<T> clazz) {
+ ServiceReference<T> sr = registry.getServiceReference(clazz.name)
+ assert sr == null: "Service of type $clazz was found"
+ }
+
protected <T> T getService(Class<T> clazz) {
ServiceReference<T> sr = registry.getServiceReference(clazz.name)
assert sr: "Not able to found a service of type $clazz"
Modified:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy?rev=1705055&r1=1705054&r2=1705055&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy
(original)
+++
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy
Thu Sep 24 13:37:04 2015
@@ -66,6 +66,32 @@ class DocumentNodeStoreConfigTest extend
}
@Test
+ public void testRDBDocumentStoreRestart() throws Exception {
+ registry = repositoryFactory.initializeServiceRegistry(config)
+
+ //1. Register the DataSource as a service
+ DataSource ds =
createDS("jdbc:h2:mem:testRDBrestart;DB_CLOSE_DELAY=-1")
+ ServiceRegistration srds =
registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak']
as Hashtable)
+
+ //2. Create config for DocumentNodeStore with RDB enabled
+ createConfig([
+
'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [
+ documentStoreType: 'RDB'
+ ]
+ ])
+
+ DocumentNodeStore ns = getServiceWithWait(NodeStore.class)
+
+ //3. Shut down ds
+ srds.unregister();
+ assertNoService(NodeStore.class)
+
+ //4. Restart ds, service should still be down
+ srds = registry.registerService(DataSource.class.name, ds,
['datasource.name': 'oak'] as Hashtable)
+ assertNoService(NodeStore.class)
+ }
+
+ @Test
public void testRDBDocumentStoreLateDataSource() throws Exception {
registry = repositoryFactory.initializeServiceRegistry(config)