use of org.commonjava.storage.pathmapped.spi.PathDB in project indy by Commonjava.
the class PathMappedMavenGACache method scan.
/**
* Scan the stores to find all GAs.
* @param notScanned
* @param gaMap
* @param completed
*/
private void scan(final Collection<String> notScanned, final Map<String, Set<String>> gaMap, final Set<String> completed) {
PathDB pathDB = pathMappedFileManager.getPathDB();
notScanned.forEach(storeName -> {
Set<String> gaSet = new HashSet<>();
pathDB.traverse("maven:hosted:" + storeName, ROOT_DIR, pathMap -> {
String gaPath = getGAPath(pathMap);
if (isNotBlank(gaPath)) {
gaSet.add(gaPath);
}
}, 0, PathDB.FileType.file);
gaSet.forEach(ga -> {
gaMap.computeIfAbsent(ga, k -> new HashSet<>()).add(storeName);
});
logger.info("Scan result, store: {}, gaSet: {}", storeName, gaSet);
completed.add(storeName);
});
}
use of org.commonjava.storage.pathmapped.spi.PathDB in project indy by Commonjava.
the class DefaultGalleyStorageProvider method setupCacheProviderFactory.
private void setupCacheProviderFactory() {
final File storeRoot = config.getStorageRootDirectory();
if (indyConfiguration.isStandalone()) {
logger.info("We're in standalone content-storage mode. Cassandra path-mapping database will NOT be used");
// Only work for local debug mode.
ScheduledExecutorService debugDeleteExecutor = Executors.newScheduledThreadPool(5, new NamedThreadFactory("debug-galley-delete-executor", new ThreadGroup("debug-galley-delete-executor"), true, 2));
cacheProviderFactory = new PartyLineCacheProviderFactory(storeRoot, debugDeleteExecutor);
return;
}
logger.info("Initializing Cassandra-based path-mapping database for content storage.");
PathDB pathDB = null;
PathMappedStorageConfig pathMappedStorageConfig = getPathMappedStorageConfig();
if (cassandraClient != null) {
String keyspace = config.getCassandraKeyspace();
Session session = cassandraClient.getSession(keyspace);
if (session != null) {
logger.info("Create pathDB, keyspace: {}", keyspace);
pathDB = new CassandraPathDB(pathMappedStorageConfig, session, keyspace, getReplicationFactor());
}
}
if (pathDB != null) {
if (metricsConfig.isPathDBMetricsEnabled()) {
final String operations = metricsConfig.getPathDBMetricsOperations();
logger.info("Create measured PathDB, operations: {}");
pathDB = new MeasuredPathDB(pathDB, metricsManager, getSupername("pathDB")) {
@Override
protected boolean isMetricEnabled(String metricName) {
if (isBlank(operations) || operations.contains(metricName)) {
return true;
}
return false;
}
};
}
}
File legacyBaseDir = config.getLegacyStorageBasedir();
PhysicalStore physicalStore = new LegacyReadonlyPhysicalStore(storeRoot, legacyBaseDir);
logger.info("Create cacheProviderFactory, pathDB: {}, physicalStore: {}", pathDB, physicalStore);
cacheProviderFactory = new PathMappedCacheProviderFactory(storeRoot, deleteExecutor, pathMappedStorageConfig, pathDB, physicalStore);
}
Aggregations