test_class.declarator: FOO1_INDEX_PATH = "/oak:index/fooIndex1"
test_class.modifier: private final static
test_class.original_string: private final static String FOO1_INDEX_PATH = "/oak:index/fooIndex1";
test_class.type: String
test_class.var_name: FOO1_INDEX_PATH
test_class.file: oak-run/src/test/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersionTest.java
test_class.identifier: PurgeOldIndexVersionTest
test_class.superclass: extends AbstractIndexCommandTest
test_case.body: @Test
      public void onlyDeleteVersionIndexesMentionedUnderIndexPaths() throws Exception {
          createTestData(false);
          createCustomIndex(TEST_INDEX_PATH, 2, 1, false);
          createCustomIndex(TEST_INDEX_PATH, 3, 0, false);
          createCustomIndex(TEST_INDEX_PATH, 3, 1, false);
          createCustomIndex(TEST_INDEX_PATH, 3, 2, false);
          createCustomIndex(TEST_INDEX_PATH, 4, 0, false);
          createCustomIndex(TEST_INDEX_PATH, 4, 1, false);
          createCustomIndex(TEST_INDEX_PATH, 4, 2, false);
          createCustomIndex(FOO1_INDEX_PATH, 2, 1, false);
          createCustomIndex(FOO1_INDEX_PATH, 2, 2, false);
          createCustomIndex(FOO1_INDEX_PATH, 3, 0, false);
          createCustomIndex(FOO1_INDEX_PATH, 3, 1, false);
          createCustomIndex(FOO1_INDEX_PATH, 3, 2, false);
  
          fixture.getAsyncIndexUpdate("async").run();
          fixture.close();
          PurgeOldIndexVersionCommand command = new PurgeOldIndexVersionCommand();
          File storeDir = fixture.getDir();
          String[] args = {
                  storeDir.getAbsolutePath(),
                  "--read-write",
                  "--threshold=1",
                  "--index-paths=/oak:index/fooIndex"
          };
          command.execute(args);
          fixture = new RepositoryFixture(storeDir);
          fixture.close();
  
          Assert.assertFalse("Index:" + "fooIndex-2" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-2").exists());
          Assert.assertFalse("Index:" + "fooIndex-2-custom-1" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-2-custom-1").exists());
          Assert.assertFalse("Index:" + "fooIndex-3" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-3").exists());
          Assert.assertFalse("Index:" + "fooIndex-3-custom-1" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-3-custom-1").exists());
          Assert.assertFalse("Index:" + "fooIndex-3-custom-2" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-3-custom-2").exists());
          Assert.assertFalse("Index:" + "fooIndex" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex").exists());
          Assert.assertEquals(fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-4").getProperty("type").getValue(Type.STRING), "disabled");
          Assert.assertFalse(isHiddenChildNodePresent(fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-4")));
          Assert.assertFalse("Index:" + "fooIndex-4-custom-1" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-4-custom-1").exists());
          Assert.assertTrue("Index:" + "fooIndex-4-custom-2" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex-4-custom-2").exists());
  
          Assert.assertTrue("Index:" + "fooIndex1-3-custom-1" + " deleted", fixture.getNodeStore().getRoot().getChildNode("oak:index").getChildNode("fooIndex1-3-custom-1").exists());
      }
test_case.class_method_signature: PurgeOldIndexVersionTest.onlyDeleteVersionIndexesMentionedUnderIndexPaths()
test_case.full_signature: @Test public void onlyDeleteVersionIndexesMentionedUnderIndexPaths()
test_case.identifier: onlyDeleteVersionIndexesMentionedUnderIndexPaths
test_case.invocations: createTestData createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex run getAsyncIndexUpdate close getDir getAbsolutePath execute close assertFalse exists getChildNode getChildNode getRoot getNodeStore assertFalse exists getChildNode getChildNode getRoot getNodeStore assertFalse exists getChildNode getChildNode getRoot getNodeStore assertFalse exists getChildNode getChildNode getRoot getNodeStore assertFalse exists getChildNode getChildNode getRoot getNodeStore assertFalse exists getChildNode getChildNode getRoot getNodeStore assertEquals getValue getProperty getChildNode getChildNode getRoot getNodeStore assertFalse isHiddenChildNodePresent getChildNode getChildNode getRoot getNodeStore assertFalse exists getChildNode getChildNode getRoot getNodeStore assertTrue exists getChildNode getChildNode getRoot getNodeStore assertTrue exists getChildNode getChildNode getRoot getNodeStore
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void onlyDeleteVersionIndexesMentionedUnderIndexPaths()
focal_class.declarator: LOG = LoggerFactory.getLogger(PurgeOldIndexVersion.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(PurgeOldIndexVersion.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.file: oak-run/src/main/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersion.java
focal_class.identifier: PurgeOldIndexVersion
focal_class.class_method_signature: PurgeOldIndexVersion.execute(Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_class.full_signature: public void execute(Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_class.identifier: execute
focal_class.modifiers: public
focal_class.parameters: (Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_class.return: void
focal_class.signature: void execute(Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_class.class_method_signature: PurgeOldIndexVersion.sanitiseUserIndexPaths(List<String> userIndexPaths)
focal_class.full_signature: private List<String> sanitiseUserIndexPaths(List<String> userIndexPaths)
focal_class.identifier: sanitiseUserIndexPaths
focal_class.modifiers: private
focal_class.parameters: (List<String> userIndexPaths)
focal_class.return: List<String>
focal_class.signature: List<String> sanitiseUserIndexPaths(List<String> userIndexPaths)
focal_class.class_method_signature: PurgeOldIndexVersion.segregateIndexes(Set<String> indexPathSet)
focal_class.full_signature: private Map<String, Set<String>> segregateIndexes(Set<String> indexPathSet)
focal_class.identifier: segregateIndexes
focal_class.modifiers: private
focal_class.parameters: (Set<String> indexPathSet)
focal_class.return: Map<String, Set<String>>
focal_class.signature: Map<String, Set<String>> segregateIndexes(Set<String> indexPathSet)
focal_class.class_method_signature: PurgeOldIndexVersion.getRepositoryIndexPaths(NodeStore store)
focal_class.full_signature: private Iterable<String> getRepositoryIndexPaths(NodeStore store)
focal_class.identifier: getRepositoryIndexPaths
focal_class.modifiers: private
focal_class.parameters: (NodeStore store)
focal_class.return: Iterable<String>
focal_class.signature: Iterable<String> getRepositoryIndexPaths(NodeStore store)
focal_class.class_method_signature: PurgeOldIndexVersion.filterIndexPaths(Iterable<String> repositoryIndexPaths, List<String> commandlineIndexPaths)
focal_class.full_signature: private Set<String> filterIndexPaths(Iterable<String> repositoryIndexPaths, List<String> commandlineIndexPaths)
focal_class.identifier: filterIndexPaths
focal_class.modifiers: private
focal_class.parameters: (Iterable<String> repositoryIndexPaths, List<String> commandlineIndexPaths)
focal_class.return: Set<String>
focal_class.signature: Set<String> filterIndexPaths(Iterable<String> repositoryIndexPaths, List<String> commandlineIndexPaths)
focal_class.class_method_signature: PurgeOldIndexVersion.getIndexNameObjectList(Set<String> versionedIndexPaths)
focal_class.full_signature: private List<IndexName> getIndexNameObjectList(Set<String> versionedIndexPaths)
focal_class.identifier: getIndexNameObjectList
focal_class.modifiers: private
focal_class.parameters: (Set<String> versionedIndexPaths)
focal_class.return: List<IndexName>
focal_class.signature: List<IndexName> getIndexNameObjectList(Set<String> versionedIndexPaths)
focal_class.class_method_signature: PurgeOldIndexVersion.purgeOldIndexVersion(NodeStore store,
                                        List<IndexVersionOperation> toDeleteIndexNameObjectList)
focal_class.full_signature: private void purgeOldIndexVersion(NodeStore store,
                                        List<IndexVersionOperation> toDeleteIndexNameObjectList)
focal_class.identifier: purgeOldIndexVersion
focal_class.modifiers: private
focal_class.parameters: (NodeStore store,
                                        List<IndexVersionOperation> toDeleteIndexNameObjectList)
focal_class.return: void
focal_class.signature: void purgeOldIndexVersion(NodeStore store,
                                        List<IndexVersionOperation> toDeleteIndexNameObjectList)
focal_method.body: public void execute(Options opts, long purgeThresholdMillis, List<String> indexPaths) throws Exception {
          boolean isReadWriteRepository = opts.getCommonOpts().isReadWrite();
          if (!isReadWriteRepository) {
              LOG.info("Repository connected in read-only mode. Use '--read-write' for write operations");
          }
          try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(opts)) {
              NodeStore nodeStore = fixture.getStore();
              List<String> sanitisedIndexPaths = sanitiseUserIndexPaths(indexPaths);
              Set<String> indexPathSet = filterIndexPaths(getRepositoryIndexPaths(nodeStore), sanitisedIndexPaths);
              Map<String, Set<String>> segregateIndexes = segregateIndexes(indexPathSet);
              for (Map.Entry<String, Set<String>> entry : segregateIndexes.entrySet()) {
                  String baseIndexPath = entry.getKey();
                  String parentPath = PathUtils.getParentPath(entry.getKey());
                  List<IndexName> indexNameObjectList = getIndexNameObjectList(entry.getValue());
                  NodeState indexDefParentNode = NodeStateUtils.getNode(nodeStore.getRoot(),
                          parentPath);
                  List<IndexVersionOperation> toDeleteIndexNameObjectList =
                          IndexVersionOperation.generateIndexVersionOperationList(indexDefParentNode, indexNameObjectList, purgeThresholdMillis);
                  if (isReadWriteRepository && !toDeleteIndexNameObjectList.isEmpty()) {
                      purgeOldIndexVersion(nodeStore, toDeleteIndexNameObjectList);
                  } else {
                      LOG.info("Repository is opened in read-only mode: IndexOperations" +
                              " for index at path {} are : {}", baseIndexPath, toDeleteIndexNameObjectList);
                  }
              }
          }
      }
focal_method.class_method_signature: PurgeOldIndexVersion.execute(Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_method.full_signature: public void execute(Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_method.identifier: execute
focal_method.invocations: isReadWrite getCommonOpts info create getStore sanitiseUserIndexPaths filterIndexPaths getRepositoryIndexPaths segregateIndexes entrySet getKey getParentPath getKey getIndexNameObjectList getValue getNode getRoot generateIndexVersionOperationList isEmpty purgeOldIndexVersion info
focal_method.modifiers: public
focal_method.parameters: (Options opts, long purgeThresholdMillis, List<String> indexPaths)
focal_method.return: void
focal_method.signature: void execute(Options opts, long purgeThresholdMillis, List<String> indexPaths)