Search in sources :

Example 16 with Statistics

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

the class FileHistoryCache method createDirectoriesForFiles.

private void createDirectoriesForFiles(Set<String> files, Repository repository, String label) throws HistoryException {
    // The directories for the files have to be created before
    // the actual files otherwise storeFile() might be racing for
    // mkdirs() if there are multiple files from single directory
    // handled in parallel.
    Statistics elapsed = new Statistics();
    LOGGER.log(Level.FINE, "Starting directory creation for {0} ({1}): {2} directories", new Object[] { repository, label, files.size() });
    for (final String file : files) {
        File cache;
        try {
            cache = getCachedFile(new File(env.getSourceRootPath() + file));
        } catch (ForbiddenSymlinkException ex) {
            LOGGER.log(Level.FINER, ex.getMessage());
            continue;
        }
        File dir = cache.getParentFile();
        if (!dir.isDirectory() && !dir.mkdirs()) {
            LOGGER.log(Level.WARNING, "Unable to create cache directory ''{0}''.", dir);
        }
    }
    elapsed.report(LOGGER, String.format("Done creating directories for %s (%s)", repository, label));
}
Also used : ForbiddenSymlinkException(org.opengrok.indexer.util.ForbiddenSymlinkException) Statistics(org.opengrok.indexer.util.Statistics) File(java.io.File)

Aggregations

Statistics (org.opengrok.indexer.util.Statistics)16 IOException (java.io.IOException)8 ForbiddenSymlinkException (org.opengrok.indexer.util.ForbiddenSymlinkException)5 File (java.io.File)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 Project (org.opengrok.indexer.configuration.Project)3 RuntimeEnvironment (org.opengrok.indexer.configuration.RuntimeEnvironment)3 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ExecutorService (java.util.concurrent.ExecutorService)2 Analyzer (org.apache.lucene.analysis.Analyzer)2 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)2 Document (org.apache.lucene.document.Document)2 IndexWriter (org.apache.lucene.index.IndexWriter)2 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)2 Query (org.apache.lucene.search.Query)2 TopDocs (org.apache.lucene.search.TopDocs)2 AbstractAnalyzer (org.opengrok.indexer.analysis.AbstractAnalyzer)2