Search in sources :

Example 1 with ResourceLock

use of org.opengrok.indexer.util.ResourceLock in project OpenGrok by OpenGrok.

the class RuntimeEnvironment method setConfiguration.

/**
 * Sets the configuration and performs necessary actions.
 *
 * @param configuration new configuration
 * @param subFileList   list of repositories
 * @param cmdType       command timeout type
 */
public synchronized void setConfiguration(Configuration configuration, List<String> subFileList, CommandTimeoutType cmdType) {
    try (ResourceLock resourceLock = configLock.writeLockAsResource()) {
        // noinspection ConstantConditions to avoid warning of no reference to auto-closeable
        assert resourceLock != null;
        this.configuration = configuration;
    }
    // HistoryGuru constructor needs environment properties so no locking is done here.
    HistoryGuru histGuru = HistoryGuru.getInstance();
    // Set the working repositories in HistoryGuru.
    if (subFileList != null) {
        histGuru.invalidateRepositories(getRepositories(), subFileList, cmdType);
    } else {
        histGuru.invalidateRepositories(getRepositories(), cmdType);
    }
    // The invalidation of repositories above might have excluded some
    // repositories in HistoryGuru so the configuration needs to reflect that.
    setRepositories(new ArrayList<>(histGuru.getRepositories()));
    // generate repository map is dependent on getRepositories()
    try {
        generateProjectRepositoriesMap();
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, "Cannot generate project - repository map", ex);
    }
    // populate groups is dependent on repositories map
    populateGroups(getGroups(), new TreeSet<>(getProjects().values()));
    includeFiles.reloadIncludeFiles();
}
Also used : ResourceLock(org.opengrok.indexer.util.ResourceLock) HistoryGuru(org.opengrok.indexer.history.HistoryGuru) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 HistoryGuru (org.opengrok.indexer.history.HistoryGuru)1 ResourceLock (org.opengrok.indexer.util.ResourceLock)1