Search in sources :

Example 1 with PartyLineCacheProviderFactory

use of org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory in project galley by Commonjava.

the class RoutingCacheProviderWrapperTest method prepare.

@Before
public void prepare() throws Exception {
    final File cacheDir = temp.newFolder();
    partylineFac = new PartyLineCacheProviderFactory(cacheDir);
    DefaultCacheManager cacheManager = new DefaultCacheManager();
    SimpleCacheInstance<String, String> cacheInstance = new SimpleCacheInstance<>("test", cacheManager.getCache("simpleNfsCache"));
    SimpleCacheInstance<String, ConcreteResource> testLocalFileCacheInstance = new SimpleCacheInstance<>("testLocalFileCache", cacheManager.getCache("simpleLocalFileCache"));
    fastLocalFac = new FastLocalCacheProviderFactory(cacheDir, temp.newFolder(), cacheInstance, testLocalFileCacheInstance, Executors.newFixedThreadPool(5));
}
Also used : PartyLineCacheProviderFactory(org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) FastLocalCacheProviderFactory(org.commonjava.maven.galley.cache.infinispan.FastLocalCacheProviderFactory) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) File(java.io.File) SimpleCacheInstance(org.commonjava.maven.galley.cache.infinispan.SimpleCacheInstance) Before(org.junit.Before)

Example 2 with PartyLineCacheProviderFactory

use of org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory 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

File (java.io.File)2 PartyLineCacheProviderFactory (org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory)2 Session (com.datastax.driver.core.Session)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 NamedThreadFactory (org.commonjava.cdi.util.weft.NamedThreadFactory)1 FastLocalCacheProviderFactory (org.commonjava.maven.galley.cache.infinispan.FastLocalCacheProviderFactory)1 SimpleCacheInstance (org.commonjava.maven.galley.cache.infinispan.SimpleCacheInstance)1 PathMappedCacheProviderFactory (org.commonjava.maven.galley.cache.pathmapped.PathMappedCacheProviderFactory)1 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)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 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 Before (org.junit.Before)1