test_class.declarator: connectionFactory = new MongoConnectionFactory()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public MongoConnectionFactory connectionFactory = new MongoConnectionFactory();
test_class.type: MongoConnectionFactory
test_class.var_name: connectionFactory
test_class.declarator: builderProvider = new DocumentMKBuilderProvider()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public DocumentMKBuilderProvider builderProvider = new DocumentMKBuilderProvider();
test_class.type: DocumentMKBuilderProvider
test_class.var_name: builderProvider
test_class.declarator: ns
test_class.modifier: private
test_class.original_string: private DocumentNodeStore ns;
test_class.type: DocumentNodeStore
test_class.var_name: ns
test_class.file: oak-run/src/test/java/org/apache/jackrabbit/oak/run/RecoveryCommandTest.java
test_class.identifier: RecoveryCommandTest
test_case.body: @Test
      public void recovery() throws Exception {
          RecoveryCommand cmd = new RecoveryCommand();
          cmd.execute(
                  "--clusterId",
                  String.valueOf(ns.getClusterId()),
                  MongoUtils.URL,
                  "dryRun"
          );
      }
test_case.class_method_signature: RecoveryCommandTest.recovery()
test_case.full_signature: @Test public void recovery()
test_case.identifier: recovery
test_case.invocations: execute valueOf getClusterId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void recovery()
focal_class.declarator: oldf = MapFactory.getInstance()
focal_class.original_string: MapFactory oldf = MapFactory.getInstance();
focal_class.type: MapFactory
focal_class.var_name: oldf
focal_class.file: oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java
focal_class.identifier: RecoveryCommand
focal_class.interfaces: implements Command
focal_class.class_method_signature: RecoveryCommand.execute(String... args)
focal_class.full_signature: @Override public void execute(String... args)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (String... args)
focal_class.return: void
focal_class.signature: void execute(String... args)
focal_method.body: @Override
      public void execute(String... args) throws Exception {
          Closer closer = Utils.createCloserWithShutdownHook();
          MapDBMapFactory mdbmf = new MapDBMapFactory();
          closer.register(mdbmf);
          MapFactory.setInstance(mdbmf);
          String h = "recovery mongodb://host:port/database|jdbc:... { dryRun }";
  
          try {
              DocumentNodeStoreBuilder<?> builder = Utils.createDocumentMKBuilder(args, closer, h);
  
              if (builder == null) {
                  System.err.println("Recovery only available for DocumentNodeStore backed by MongoDB or RDB persistence");
                  System.exit(1);
              }
  
              // The recovery command does not have options for the blob store
              // and the DocumentNodeStoreBuilder by default assumes the blobs
              // are stored in the same location as the documents. That is,
              // either in MongoDB or RDB, which is not necessarily the case and
              // can cause an exception when the blob store implementation starts
              // read-only on a database that does not have the required
              // collection. Use an in-memory blob store instead, because the
              // recovery command does not read blobs anyway.
              builder.setBlobStore(new MemoryBlobStore());
  
              // dryRun implies readonly repo
              boolean dryRun = Arrays.asList(args).contains("dryRun");
              if (dryRun) {
                  builder.setReadOnlyMode();
              }
  
              DocumentNodeStore dns = builder.build();
              closer.register(Utils.asCloseable(dns));
  
              DocumentStore ds = builder.getDocumentStore();
  
              LastRevRecoveryAgent agent = null;
              MissingLastRevSeeker seeker = null;
  
              if (ds instanceof MongoDocumentStore) {
                  MongoDocumentStore docStore = (MongoDocumentStore) ds;
                  agent = new LastRevRecoveryAgent(docStore, dns);
                  seeker = new MongoMissingLastRevSeeker(docStore, dns.getClock());
              } else if (ds instanceof RDBDocumentStore) {
                  RDBDocumentStore docStore = (RDBDocumentStore) ds;
                  agent = new LastRevRecoveryAgent(docStore, dns);
                  seeker = new RDBMissingLastRevSeeker(docStore, dns.getClock());
              }
  
              if (agent == null || seeker == null) {
                  System.err.println("Recovery only available for MongoDocumentStore and RDBDocumentStore (this: "
                          + ds.getClass().getName() + ")");
                  System.exit(1);
              }
  
              if (builder.getClusterId() == 0) {
                  System.err.println("Please specify the clusterId for recovery using --clusterId");
                  try {
                      List<ClusterNodeInfoDocument> all = ClusterNodeInfoDocument.all(ds);
                      System.err.println("Existing entries in the clusternodes collection are:");
                      for (ClusterNodeInfoDocument c : all) {
                          String state = c.isActive() ? "ACTIVE" : "INACTIVE";
                          System.err.println(c.getClusterId() +
                                  " (" + state + "): " +
                                  c.toString().replace('\n', ' '));
                      }
                  }
                  catch (Throwable e) {
                      e.printStackTrace(System.err);
                  }
                  System.exit(1);
              }
  
              Iterable<NodeDocument> docs = seeker.getCandidates(0);
              if (docs instanceof Closeable) {
                  closer.register((Closeable) docs);
              }
  
              agent.recover(docs, builder.getClusterId(), dryRun);
          } catch (Throwable e) {
              throw closer.rethrow(e);
          } finally {
              closer.close();
              MapFactory.setInstance(oldf);
          }
      }
focal_method.class_method_signature: RecoveryCommand.execute(String... args)
focal_method.full_signature: @Override public void execute(String... args)
focal_method.identifier: execute
focal_method.invocations: createCloserWithShutdownHook register setInstance createDocumentMKBuilder println exit setBlobStore contains asList setReadOnlyMode build register asCloseable getDocumentStore getClock getClock println getName getClass exit getClusterId println all println isActive println getClusterId replace toString printStackTrace exit getCandidates register recover getClusterId rethrow close setInstance
focal_method.modifiers: @Override public
focal_method.parameters: (String... args)
focal_method.return: void
focal_method.signature: void execute(String... args)