You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2019/06/14 11:00:23 UTC

svn commit: r1861329 - in /jackrabbit/oak/branches/1.10: ./ oak-run/README.md oak-run/src/main/java/org/apache/jackrabbit/oak/run/ResetClusterIdCommand.java

Author: reschke
Date: Fri Jun 14 11:00:22 2019
New Revision: 1861329

URL: http://svn.apache.org/viewvc?rev=1861329&view=rev
Log:
OAK-8349: RDBDocumentStore*: "reset clusterId tool" in oak-run (ported to 1.10)

Modified:
    jackrabbit/oak/branches/1.10/   (props changed)
    jackrabbit/oak/branches/1.10/oak-run/README.md
    jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/ResetClusterIdCommand.java

Propchange: jackrabbit/oak/branches/1.10/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 14 11:00:22 2019
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852135,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853083,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1855993,1856049,1856056,1856538,1856545,1857000,1857010,1857104,1857159,1857212,1857221,1857238,1857247,1857253,1857294,1857314,1857463,1857480,1857577,1857589,1857592,1857634-1857635,1857638,1857640,1857687,1857936,1858032,1858053,1858123,1858139,1858385,1858424,1858571,1858578,1858810,1858926,1858931,1859231,1859292,1859294,1859533,1859609,1859612,1859619,1859711,1859716,1859776,1859780,1859843,1859854,1859881,1860120,1860131,1860202,1860278
 ,1860328,1860330,1860355,1860393,1860442,1860548
+/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852135,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853083,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1855993,1856049,1856056,1856538,1856545,1857000,1857010,1857104,1857159,1857212,1857221,1857238,1857247,1857253,1857294,1857314,1857463,1857480,1857577,1857589,1857592,1857634-1857635,1857638,1857640,1857687,1857936,1858032,1858053,1858123,1858139,1858385,1858424,1858571,1858578,1858810,1858926,1858931,1859231,1859292,1859294,1859533,1859609,1859612,1859619,1859711,1859716,1859776,1859780,1859843,1859854,1859881,1860120,1860131,1860137,1860202
 ,1860278,1860328,1860330,1860355,1860393,1860442,1860548,1860564
 /jackrabbit/trunk:1345480

Modified: jackrabbit/oak/branches/1.10/oak-run/README.md
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-run/README.md?rev=1861329&r1=1861328&r2=1861329&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.10/oak-run/README.md (original)
+++ jackrabbit/oak/branches/1.10/oak-run/README.md Fri Jun 14 11:00:22 2019
@@ -600,7 +600,7 @@ Reset Cluster Id
 Resets the cluster id generated internally. Use the following command after stopping the server
 
     $ java -jar oak-run-*.jar resetclusterid \
-            { /path/to/oak/repository | mongodb://host:port/database }
+            { /path/to/oak/repository | mongodb://host:port/database | jdbc:...}
 
 The cluster id will be removed and will be generated on next server start up.
 

Modified: jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/ResetClusterIdCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/ResetClusterIdCommand.java?rev=1861329&r1=1861328&r2=1861329&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/ResetClusterIdCommand.java (original)
+++ jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/ResetClusterIdCommand.java Fri Jun 14 11:00:22 2019
@@ -19,9 +19,6 @@ package org.apache.jackrabbit.oak.run;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.run.commons.Command;
-import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
-import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
-import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.spi.cluster.ClusterRepositoryInfo;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
@@ -29,17 +26,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 
 import com.google.common.io.Closer;
-import com.mongodb.MongoClient;
-import com.mongodb.MongoClientURI;
-import com.mongodb.MongoURI;
-
-import joptsimple.OptionParser;
-import joptsimple.OptionSet;
-
-import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentNodeStoreBuilder.newMongoDocumentNodeStoreBuilder;
-import static org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
-
-import java.io.File;
 
 /**
  * OFFLINE utility to delete the clusterId stored as hidden
@@ -59,13 +45,13 @@ class ResetClusterIdCommand implements C
         NodeBuilder builder = store.getRoot().builder();
         NodeBuilder clusterConfigNode = builder.getChildNode(
                 ClusterRepositoryInfo.CLUSTER_CONFIG_NODE);
-        
+
         if (!clusterConfigNode.exists()) {
             // if it doesn't exist, then there is no way to delete
             System.out.println("clusterId was never set or already deleted.");
             return;
         }
-        
+
         if (!clusterConfigNode.hasProperty(ClusterRepositoryInfo.CLUSTER_ID_PROP)) {
             // the config node exists, but the clusterId not 
             // so again, no way to delete
@@ -80,49 +66,24 @@ class ResetClusterIdCommand implements C
 
             System.out.println("clusterId deleted successfully. (old id was " + oldClusterId + ")");
         } catch (CommitFailedException e) {
-            System.err.println("Failed to delete clusterId due to exception: "+e.getMessage());
+            System.err.println("Failed to delete clusterId due to exception: " + e.getMessage());
             e.printStackTrace();
         }
     }
 
     @Override
     public void execute(String... args) throws Exception {
-        OptionParser parser = new OptionParser();
-        OptionSet options = parser.parse(args);
-
-        if (options.nonOptionArguments().isEmpty()) {
-            System.out.println("usage: resetclusterid {<path>|<mongo-uri>}");
-            System.exit(1);
-        }
-
-        String source = options.nonOptionArguments().get(0).toString();
+        String help = "resetclusterid {<path>|<mongo-uri>|<jdbc-uri>}";
+        Utils.NodeStoreOptions opts = new Utils.NodeStoreOptions(help).parse(args);
 
         Closer closer = Closer.create();
         try {
-            NodeStore store;
-            if (args[0].startsWith(MongoURI.MONGODB_PREFIX)) {
-                MongoClientURI uri = new MongoClientURI(source);
-                MongoClient client = new MongoClient(uri);
-                final DocumentNodeStore dns = newMongoDocumentNodeStoreBuilder()
-                        .setMongoDB(client, uri.getDatabase())
-                        .build();
-                closer.register(Utils.asCloseable(dns));
-                store = dns;
-            } else {
-                FileStore fileStore = fileStoreBuilder(new File(source))
-                    .withStrictVersionCheck(true)
-                    .build();
-                closer.register(fileStore);
-                store = SegmentNodeStoreBuilders.builder(fileStore).build();
-            }
-            
+            NodeStore store = Utils.bootstrapNodeStore(opts, closer);
             deleteClusterId(store);
         } catch (Throwable e) {
             throw closer.rethrow(e);
         } finally {
             closer.close();
         }
-    
     }
-    
-}
\ No newline at end of file
+}