Skip to content

Commit

Permalink
get rid of subFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak committed Jan 6, 2025
1 parent 7bde135 commit e6193e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 6 additions & 7 deletions opengrok-indexer/src/main/java/org/opengrok/indexer/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import io.micrometer.statsd.StatsdConfig;
import io.micrometer.statsd.StatsdMeterRegistry;
import io.micrometer.statsd.StatsdFlavor;
import org.opengrok.indexer.configuration.Project;
import org.opengrok.indexer.configuration.RuntimeEnvironment;
import org.opengrok.indexer.index.Indexer;
import org.opengrok.indexer.logger.LoggerFactory;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -108,13 +108,12 @@ public boolean buffered() {
private Metrics() {
}

public static void updateSubFiles(List<String> subFiles) {
public static void updateProjects(Set<Project> projects) {
// Add tag for per-project reindex.
if (statsdRegistry != null && !subFiles.isEmpty()) {
String projects = subFiles.stream().
map(s -> s.startsWith(Indexer.PATH_SEPARATOR_STRING) ? s.substring(1) : s).
if (statsdRegistry != null && !projects.isEmpty()) {
String projectNames = projects.stream().map(Project::getName).
collect(Collectors.joining(","));
Tag commonTag = Tag.of("projects", projects);
Tag commonTag = Tag.of("projects", projectNames);
LOGGER.log(Level.FINE, "updating statsdRegistry with common tag: {}", commonTag);
statsdRegistry.config().commonTags(Collections.singleton(commonTag));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ public static int runMain(String[] argv) {
Statistics stats = new Statistics(); //this won't count JVM creation though

Executor.registerErrorHandler();
List<String> subFiles = RuntimeEnvironment.getInstance().getSubFiles();
Set<String> subFilePaths = new HashSet<>(); // absolute paths
Set<String> subFileArgs = new HashSet<>(); // relative to source root
List<Throwable> throwableList = new ArrayList<>();
Expand Down Expand Up @@ -339,18 +338,18 @@ public static int runMain(String[] argv) {
}
}

if (!subFilePaths.isEmpty() && subFiles.isEmpty()) {
if (!subFilePaths.isEmpty() && projects.isEmpty()) {
System.err.println("None of the paths were added, exiting");
return 1;
}

if (!subFiles.isEmpty() && configFilename != null) {
if (!projects.isEmpty() && configFilename != null) {
LOGGER.log(Level.WARNING, "The collection of paths to process is non empty ({0}), seems like " +
"the intention is to perform per project reindex, however the -W option is used. " +
"This will likely not work.", subFiles);
"This will likely not work.", projects);
}

Metrics.updateSubFiles(subFiles);
Metrics.updateProjects(projects);

// If the webapp is running with a config that does not contain
// 'projectsEnabled' property (case of upgrade or transition
Expand Down Expand Up @@ -418,7 +417,7 @@ public static int runMain(String[] argv) {
writeConfigToFile(env, configFilename);

// Finally, send new configuration to the web application in the case of full reindex.
if (webappURI != null && subFiles.isEmpty()) {
if (webappURI != null && projects.isEmpty()) {
getInstance().sendToConfigHost(env, webappURI);
}
} catch (ParseException e) {
Expand Down

0 comments on commit e6193e2

Please sign in to comment.