use of org.commonjava.maven.galley.io.checksum.Md5GeneratorFactory in project indy by Commonjava.
the class InfinispanGalleyStorageProvider method setup.
@PostConstruct
public void setup() {
SpecialPathInfo infoSpi = SpecialPathInfo.from(new FilePatternMatcher(".+\\.info")).setDecoratable(false).setDeletable(false).setListable(false).setPublishable(false).setRetrievable(false).setStorable(false).build();
specialPathManager.registerSpecialPathInfo(infoSpi);
transferDecorator = new ChecksummingTransferDecorator(Collections.singleton(TransferOperation.GENERATE), specialPathManager, new Md5GeneratorFactory(), new Sha1GeneratorFactory());
this.cacheProvider = new GridFileSystemCacheProvider(pathGenerator, fileEventManager, transferDecorator, cacheFs);
}
use of org.commonjava.maven.galley.io.checksum.Md5GeneratorFactory in project indy by Commonjava.
the class DefaultGalleyStorageProvider method setup.
@PostConstruct
public void setup() {
SpecialPathInfo infoSpi = SpecialPathInfo.from(new FilePatternMatcher(".+\\.info")).setDecoratable(false).setDeletable(false).setListable(false).setPublishable(false).setRetrievable(false).setStorable(false).build();
specialPathManager.registerSpecialPathInfo(infoSpi);
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;
};
transferDecorator = new TransferDecoratorPipeline(new ChecksummingTransferDecorator(readAdvisor, writeAdvisor, specialPathManager, contentMetadataConsumer, new Md5GeneratorFactory(), new Sha1GeneratorFactory(), new Sha256GeneratorFactory()), new ContentsFilteringTransferDecorator(), new NoCacheTransferDecorator(specialPathManager));
final File storeRoot = config.getStorageRootDirectory();
cacheProviderFactory = new PartyLineCacheProviderFactory(storeRoot);
final File nfsBasedir = config.getNFSStorageRootDirectory();
if (nfsBasedir != null) {
if (!nfsBasedir.exists()) {
nfsBasedir.mkdirs();
}
// nfs root can not be created due to some security reason(like permission), will bypass FastLocal provider and use PartyLine
if (nfsBasedir.exists()) {
final FastLocalCacheProviderFactory fastLocalFac = new FastLocalCacheProviderFactory(storeRoot, nfsBasedir, new CacheInstanceAdapter(nfsOwnerCache), fastLocalExecutors);
cacheProviderFactory = new RoutingCacheProviderFactory((resource) -> {
if (resource != null) {
final Location loc = resource.getLocation();
// looking for KeyedLocation and StoreType.hosted should be faster than regex on the URI.
return ((loc instanceof KeyedLocation) && hosted == ((KeyedLocation) loc).getKey().getType());
}
return false;
}, fastLocalFac, cacheProviderFactory);
} else {
logger.warn("[Indy] nfs base dir {} can not be created correctly due to some unknown reasons, will use partyline cache provider as default", nfsBasedir);
}
}
// TODO: Tie this into a config file!
transportManagerConfig = new TransportManagerConfig();
}
Aggregations