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 invalidIndexOperationVersion() throws Exception {
  
          LogCustomizer custom = LogCustomizer
                  .forLogger(
                          "org.apache.jackrabbit.oak.indexversion.IndexVersionOperation")
                  .enable(Level.INFO).create();
          try {
              custom.starting();
              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, 1, false);
              createCustomIndex(TEST_INDEX_PATH, 4, 2, false);
              fixture.getAsyncIndexUpdate("async").run();
              fixture.close();
              PurgeOldIndexVersionCommand command = new PurgeOldIndexVersionCommand();
  
              // File outDir = temporaryFolder.newFolder();
              File storeDir = fixture.getDir();
              String[] args = {
                      storeDir.getAbsolutePath(),
                      "--read-write",
                      "--threshold=1"
              };
              command.execute(args);
              fixture = new RepositoryFixture(storeDir);
              fixture.close();
              List<String> logs = custom.getLogs();
              assertTrue(logs.size() == 1);
              assertThat("custom fooIndex don't have product version ", logs.toString(),
                      containsString("IndexVersionOperation List is not valid for index"));
          } finally {
              custom.finished();
          }
      }
test_case.class_method_signature: PurgeOldIndexVersionTest.invalidIndexOperationVersion()
test_case.full_signature: @Test public void invalidIndexOperationVersion()
test_case.identifier: invalidIndexOperationVersion
test_case.invocations: create enable forLogger starting createTestData createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex createCustomIndex run getAsyncIndexUpdate close getDir getAbsolutePath execute close getLogs assertTrue size assertThat toString containsString finished
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void invalidIndexOperationVersion()
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)