Search in sources :

Example 1 with NO_DECORATE

use of org.commonjava.maven.galley.io.checksum.ChecksummingDecoratorAdvisor.ChecksumAdvice.NO_DECORATE in project indy by Commonjava.

the class DefaultGalleyStorageProvider method getChecksummingTransferDecorator.

private ChecksummingTransferDecorator getChecksummingTransferDecorator() {
    ChecksummingDecoratorAdvisor readAdvisor = (transfer, op, eventMetadata) -> {
        ChecksummingDecoratorAdvisor.ChecksumAdvice result = NO_DECORATE;
        if (checksumAdvisors != null) {
            for (IndyChecksumAdvisor advisor : checksumAdvisors) {
                Optional<ChecksummingDecoratorAdvisor.ChecksumAdvice> advice = advisor.getChecksumReadAdvice(transfer, op, eventMetadata);
                if (advice.isPresent()) {
                    ChecksummingDecoratorAdvisor.ChecksumAdvice checksumAdvice = advice.get();
                    if (checksumAdvice.ordinal() > result.ordinal()) {
                        result = checksumAdvice;
                        if (checksumAdvice == CALCULATE_AND_WRITE) {
                            break;
                        }
                    }
                }
            }
        }
        logger.debug("Advising {} for {} of: {}", result, op, transfer);
        return result;
    };
    ChecksummingDecoratorAdvisor writeAdvisor = (transfer, op, eventMetadata) -> {
        ChecksummingDecoratorAdvisor.ChecksumAdvice result = NO_DECORATE;
        if (TransferOperation.GENERATE == op) {
            result = CALCULATE_AND_WRITE;
        } else if (checksumAdvisors != null) {
            for (IndyChecksumAdvisor advisor : checksumAdvisors) {
                Optional<ChecksummingDecoratorAdvisor.ChecksumAdvice> advice = advisor.getChecksumWriteAdvice(transfer, op, eventMetadata);
                if (advice.isPresent()) {
                    ChecksummingDecoratorAdvisor.ChecksumAdvice checksumAdvice = advice.get();
                    if (checksumAdvice.ordinal() > result.ordinal()) {
                        result = checksumAdvice;
                        if (checksumAdvice == CALCULATE_AND_WRITE) {
                            break;
                        }
                    }
                }
            }
        }
        logger.debug("Advising {} for {} of: {}", result, op, transfer);
        return result;
    };
    return new ChecksummingTransferDecorator(readAdvisor, writeAdvisor, specialPathManager, timerProviderFunction(), contentMetadataConsumer, new Md5GeneratorFactory(), new Sha1GeneratorFactory(), new Sha256GeneratorFactory());
}
Also used : TransportManagerConfig(org.commonjava.maven.galley.config.TransportManagerConfig) CassandraConfig(org.commonjava.indy.subsys.cassandra.config.CassandraConfig) Produces(javax.enterprise.inject.Produces) LoggerFactory(org.slf4j.LoggerFactory) PathGenerator(org.commonjava.maven.galley.spi.io.PathGenerator) FilePatternMatcher(org.commonjava.maven.galley.model.FilePatternMatcher) SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) DefaultStorageProviderConfiguration(org.commonjava.indy.filer.def.conf.DefaultStorageProviderConfiguration) SpecialPathSetProducer(org.commonjava.indy.content.SpecialPathSetProducer) ChecksummingTransferDecorator(org.commonjava.maven.galley.io.ChecksummingTransferDecorator) NameUtils.getSupername(org.commonjava.o11yphant.metrics.util.NameUtils.getSupername) WeftManaged(org.commonjava.cdi.util.weft.WeftManaged) TransferOperation(org.commonjava.maven.galley.model.TransferOperation) NO_DECORATE(org.commonjava.maven.galley.io.checksum.ChecksummingDecoratorAdvisor.ChecksumAdvice.NO_DECORATE) CassandraPathDBUtils(org.commonjava.storage.pathmapped.pathdb.datastax.util.CassandraPathDBUtils) Session(com.datastax.driver.core.Session) DefaultMetricsManager(org.commonjava.o11yphant.metrics.DefaultMetricsManager) Map(java.util.Map) Sha256GeneratorFactory(org.commonjava.maven.galley.io.checksum.Sha256GeneratorFactory) Instance(javax.enterprise.inject.Instance) ChecksummingDecoratorAdvisor(org.commonjava.maven.galley.io.checksum.ChecksummingDecoratorAdvisor) NoCacheTransferDecorator(org.commonjava.maven.galley.io.NoCacheTransferDecorator) MetricRegistry(org.commonjava.o11yphant.metrics.api.MetricRegistry) CassandraClient(org.commonjava.indy.subsys.cassandra.CassandraClient) Executors(java.util.concurrent.Executors) CacheProviderFactory(org.commonjava.maven.galley.cache.CacheProviderFactory) List(java.util.List) IndyConfiguration(org.commonjava.indy.conf.IndyConfiguration) Sha1GeneratorFactory(org.commonjava.maven.galley.io.checksum.Sha1GeneratorFactory) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) MeasuredPathDB(org.commonjava.storage.pathmapped.metrics.MeasuredPathDB) CacheProvider(org.commonjava.maven.galley.spi.cache.CacheProvider) CALCULATE_AND_WRITE(org.commonjava.maven.galley.io.checksum.ChecksummingDecoratorAdvisor.ChecksumAdvice.CALCULATE_AND_WRITE) GalleyInitException(org.commonjava.maven.galley.GalleyInitException) HashMap(java.util.HashMap) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) Function(java.util.function.Function) UploadMetadataGenTransferDecorator(org.commonjava.maven.galley.transport.htcli.UploadMetadataGenTransferDecorator) IndyChecksumAdvisor(org.commonjava.indy.content.IndyChecksumAdvisor) ArrayList(java.util.ArrayList) NamedThreadFactory(org.commonjava.cdi.util.weft.NamedThreadFactory) DefaultPathMappedStorageConfig(org.commonjava.storage.pathmapped.config.DefaultPathMappedStorageConfig) Inject(javax.inject.Inject) ExecutorConfig(org.commonjava.cdi.util.weft.ExecutorConfig) InternalFeatureConfig(org.commonjava.indy.conf.InternalFeatureConfig) Meter(org.commonjava.o11yphant.metrics.api.Meter) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BiConsumer(java.util.function.BiConsumer) PhysicalStore(org.commonjava.storage.pathmapped.spi.PhysicalStore) TransferMetadataConsumer(org.commonjava.maven.galley.io.checksum.TransferMetadataConsumer) ExecutorService(java.util.concurrent.ExecutorService) Default(javax.enterprise.inject.Default) Logger(org.slf4j.Logger) PartyLineCacheProviderFactory(org.commonjava.maven.galley.cache.partyline.PartyLineCacheProviderFactory) SpecialPathManager(org.commonjava.maven.galley.spi.io.SpecialPathManager) TimingProvider(org.commonjava.maven.galley.spi.metrics.TimingProvider) PathDB(org.commonjava.storage.pathmapped.spi.PathDB) PathMappedCacheProviderFactory(org.commonjava.maven.galley.cache.pathmapped.PathMappedCacheProviderFactory) IndyMetricsConfig(org.commonjava.indy.subsys.metrics.conf.IndyMetricsConfig) File(java.io.File) CassandraPathDB(org.commonjava.storage.pathmapped.pathdb.datastax.CassandraPathDB) Timer(org.commonjava.o11yphant.metrics.api.Timer) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) TransferDecorator(org.commonjava.maven.galley.spi.io.TransferDecorator) FileEventManager(org.commonjava.maven.galley.spi.event.FileEventManager) Md5GeneratorFactory(org.commonjava.maven.galley.io.checksum.Md5GeneratorFactory) PathMappedStorageConfig(org.commonjava.storage.pathmapped.config.PathMappedStorageConfig) IndyChecksumAdvisor(org.commonjava.indy.content.IndyChecksumAdvisor) Sha1GeneratorFactory(org.commonjava.maven.galley.io.checksum.Sha1GeneratorFactory) ChecksummingDecoratorAdvisor(org.commonjava.maven.galley.io.checksum.ChecksummingDecoratorAdvisor) Optional(java.util.Optional) ChecksummingTransferDecorator(org.commonjava.maven.galley.io.ChecksummingTransferDecorator) Sha256GeneratorFactory(org.commonjava.maven.galley.io.checksum.Sha256GeneratorFactory) Md5GeneratorFactory(org.commonjava.maven.galley.io.checksum.Md5GeneratorFactory)

Aggregations

Session (com.datastax.driver.core.Session)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 PostConstruct (javax.annotation.PostConstruct)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Default (javax.enterprise.inject.Default)1 Instance (javax.enterprise.inject.Instance)1 Produces (javax.enterprise.inject.Produces)1 Inject (javax.inject.Inject)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 ExecutorConfig (org.commonjava.cdi.util.weft.ExecutorConfig)1