Author: tomekr
Date: Wed May  2 10:43:52 2018
New Revision: 1830742

URL: http://svn.apache.org/viewvc?rev=1830742&view=rev
Log:
OAK-7464: Allow to choose which instance should initialize the default mount

- Use the Clusterable interface to get the cluster id.

Modified:
    jackrabbit/oak/trunk/oak-store-composite/pom.xml
    
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java

Modified: jackrabbit/oak/trunk/oak-store-composite/pom.xml
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-composite/pom.xml?rev=1830742&r1=1830741&r2=1830742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-composite/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-store-composite/pom.xml Wed May  2 10:43:52 2018
@@ -94,11 +94,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
-      <artifactId>oak-store-document</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.jackrabbit</groupId>
       <artifactId>oak-store-spi</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -158,6 +153,12 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>oak-store-document</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>oak-store-document</artifactId>
       <version>${project.version}</version>
       <classifier>tests</classifier>
       <scope>test</scope>

Modified: 
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java?rev=1830742&r1=1830741&r2=1830742&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java
 Wed May  2 10:43:52 2018
@@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
 import org.apache.jackrabbit.oak.plugins.migration.FilteringNodeState;
 import org.apache.jackrabbit.oak.plugins.migration.report.LoggingReporter;
 import org.apache.jackrabbit.oak.plugins.migration.report.ReportingNodeState;
@@ -30,6 +29,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.mount.Mount;
 import org.apache.jackrabbit.oak.spi.mount.MountInfo;
 import org.apache.jackrabbit.oak.spi.state.ApplyDiff;
+import org.apache.jackrabbit.oak.spi.state.Clusterable;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -47,7 +47,7 @@ public class InitialContentMigrator {
 
     private static final int LOG_NODE_COPY = 
Integer.getInteger("oak.upgrade.logNodeCopy", 10000);
 
-    private static final int CLUSTER_ID = 
Integer.getInteger("oak.composite.seed.clusterId", 1);
+    private static final String CLUSTER_ID = 
System.getProperty("oak.composite.seed.clusterId", "1");
 
     private static final Logger LOG = 
LoggerFactory.getLogger(InitialContentMigrator.class);
 
@@ -102,11 +102,11 @@ public class InitialContentMigrator {
     public void migrate() throws IOException, CommitFailedException {
         if (isTargetInitialized()) {
             LOG.info("The target is already initialized, no need to copy the 
seed mount");
-        } else if (targetNodeStore instanceof DocumentNodeStore) {
-            DocumentNodeStore dns = (DocumentNodeStore) targetNodeStore;
-            int clusterId = dns.getClusterId();
+        } else if (targetNodeStore instanceof Clusterable) {
+            Clusterable dns = (Clusterable) targetNodeStore;
+            String clusterId = dns.getInstanceId();
             LOG.info("The target isn't initialized and the cluster id = {}.", 
clusterId);
-            if (clusterId == CLUSTER_ID) {
+            if (CLUSTER_ID.equals(clusterId)) {
                 LOG.info("This cluster id {} is configured to initialized the 
repository.", CLUSTER_ID);
                 doMigrate();
             } else {


Reply via email to