Skip to content

Commit

Permalink
bubble indexParallel exceptions up to the indexer main
Browse files Browse the repository at this point in the history
also get rid of the capability to perform per directory reindex

fixes #4696
  • Loading branch information
vladak committed Jan 7, 2025
1 parent f0276ad commit 3b8e3a3
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 362 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 @@ -143,12 +143,6 @@ public final class RuntimeEnvironment {

private final Set<ConfigurationChangedListener> listeners = new CopyOnWriteArraySet<>();

public List<String> getSubFiles() {
return subFiles;
}

private final List<String> subFiles = new ArrayList<>();

/**
* Maps project name to FileCollector object. This is used to pass the list of files acquired when
* generating history cache in the first phase of indexing to the second phase of indexing.
Expand Down Expand Up @@ -507,17 +501,15 @@ public String getPathRelativeToSourceRoot(File file) throws IOException, Forbidd
return maybeRelPath;
}

throw new FileNotFoundException("Failed to resolve [" + file.getPath()
+ "] relative to source root [" + sourceRoot + "]");
throw new FileNotFoundException(String.format("Failed to resolve '%s' relative to source root '%s'",
file.getPath(), sourceRoot));
}

/**
* Do we have any projects ?
*
* @return true if we have projects
* @return true if projects are enabled and there are some projects present
*/
public boolean hasProjects() {
return (this.isProjectsEnabled() && getProjects().size() > 0);
return (this.isProjectsEnabled() && !getProjects().isEmpty());
}

/**
Expand Down
Loading

0 comments on commit 3b8e3a3

Please sign in to comment.