Search in sources :

Example 1 with PathMappedStorageConfig

use of org.commonjava.storage.pathmapped.config.PathMappedStorageConfig 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);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) PhysicalStore(org.commonjava.storage.pathmapped.spi.PhysicalStore) NamedThreadFactory(org.commonjava.cdi.util.weft.NamedThreadFactory) DefaultPathMappedStorageConfig(org.commonjava.storage.pathmapped.config.DefaultPathMappedStorageConfig) PathMappedStorageConfig(org.commonjava.storage.pathmapped.config.PathMappedStorageConfig) PathMappedCacheProviderFactory(org.commonjava.maven.galley.cache.pathmapped.PathMappedCacheProviderFactory) CassandraPathDB(org.commonjava.storage.pathmapped.pathdb.datastax.CassandraPathDB) PartyLineCacheProviderFactory(org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory) MeasuredPathDB(org.commonjava.storage.pathmapped.metrics.MeasuredPathDB) PathDB(org.commonjava.storage.pathmapped.spi.PathDB) CassandraPathDB(org.commonjava.storage.pathmapped.pathdb.datastax.CassandraPathDB) File(java.io.File) MeasuredPathDB(org.commonjava.storage.pathmapped.metrics.MeasuredPathDB) Session(com.datastax.driver.core.Session)

Aggregations

Session (com.datastax.driver.core.Session)1 File (java.io.File)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 NamedThreadFactory (org.commonjava.cdi.util.weft.NamedThreadFactory)1 PartyLineCacheProviderFactory (org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory)1 PathMappedCacheProviderFactory (org.commonjava.maven.galley.cache.pathmapped.PathMappedCacheProviderFactory)1 DefaultPathMappedStorageConfig (org.commonjava.storage.pathmapped.config.DefaultPathMappedStorageConfig)1 PathMappedStorageConfig (org.commonjava.storage.pathmapped.config.PathMappedStorageConfig)1 MeasuredPathDB (org.commonjava.storage.pathmapped.metrics.MeasuredPathDB)1 CassandraPathDB (org.commonjava.storage.pathmapped.pathdb.datastax.CassandraPathDB)1 PathDB (org.commonjava.storage.pathmapped.spi.PathDB)1 PhysicalStore (org.commonjava.storage.pathmapped.spi.PhysicalStore)1