Search in sources :

Example 21 with SpecialPathInfo

use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.

the class DefaultScheduleManager method setProxyTimeouts.

public void setProxyTimeouts(final StoreKey key, final String path) throws IndySchedulerException {
    if (!schedulerConfig.isEnabled()) {
        logger.debug("Scheduler disabled.");
        return;
    }
    RemoteRepository repo = null;
    try {
        repo = (RemoteRepository) dataManager.getArtifactStore(key);
    } catch (final IndyDataException e) {
        logger.error(String.format("Failed to retrieve store for: %s. Reason: %s", key, e.getMessage()), e);
    }
    if (repo == null) {
        return;
    }
    int timeout = config.getPassthroughTimeoutSeconds();
    final ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(repo), path);
    final SpecialPathInfo info = specialPathManager.getSpecialPathInfo(resource, key.getPackageType());
    if (!repo.isPassthrough()) {
        if ((info != null && info.isMetadata()) && repo.getMetadataTimeoutSeconds() >= 0) {
            if (repo.getMetadataTimeoutSeconds() == 0) {
                logger.debug("Using default metadata timeout for: {}", resource);
                timeout = config.getRemoteMetadataTimeoutSeconds();
            } else {
                logger.debug("Using metadata timeout for: {}", resource);
                timeout = repo.getMetadataTimeoutSeconds();
            }
        } else {
            if (info == null) {
                logger.debug("No special path info for: {}", resource);
            } else {
                logger.debug("{} is a special path, but not metadata.", resource);
            }
            timeout = repo.getCacheTimeoutSeconds();
        }
    }
    if (timeout > 0) {
        // logger.info( "[PROXY TIMEOUT SET] {}/{}; {}", repo.getKey(), path, new Date( System.currentTimeMillis()
        // + timeout ) );
        removeCache(new ScheduleKey(key, CONTENT_JOB_TYPE, path));
        scheduleContentExpiration(key, path, timeout);
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository)

Example 22 with SpecialPathInfo

use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.

the class DefaultDownloadManager method recurseListing.

private void recurseListing(final Transfer transfer, final List<Transfer> result) throws IndyWorkflowException {
    if (transfer.isDirectory()) {
        try {
            final String[] children = transfer.list();
            for (final String child : children) {
                final Transfer childTransfer = transfer.getChild(child);
                recurseListing(childTransfer, result);
            }
        } catch (final IOException e) {
            throw new IndyWorkflowException("Failed to list children of: %s. Reason: %s", e, transfer, e.getMessage());
        }
    } else if (transfer.exists()) {
        SpecialPathInfo spi = specialPathManager.getSpecialPathInfo(transfer.getPath());
        if (spi == null || spi.isListable()) {
            result.add(transfer);
        }
    }
}
Also used : SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Transfer(org.commonjava.maven.galley.model.Transfer) IOException(java.io.IOException)

Example 23 with SpecialPathInfo

use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.

the class DefaultContentManager method delete.

@Override
@Measure
public boolean delete(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
    if (Boolean.TRUE.equals(eventMetadata.get(CHECK_CACHE_ONLY)) && hosted == store.getKey().getType()) {
        SpecialPathInfo info = specialPathManager.getSpecialPathInfo(path, store.getPackageType());
        if (info != null && info.isMetadata()) {
            // Set ignore readonly for metadata so that we can delete stale metadata from readonly hosted repo
            eventMetadata.set(IGNORE_READONLY, Boolean.TRUE);
        } else {
            logger.info("Can not delete from hosted {}, path: {}, info: {}", store.getKey(), path, info);
            return false;
        }
    }
    logger.info("Delete from {}, path: {}, eventMetadata: {}", store.getKey(), path, eventMetadata);
    boolean result = false;
    if (group == store.getKey().getType()) {
        if (Boolean.TRUE.equals(eventMetadata.get(CASCADE))) {
            List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
            for (final ArtifactStore member : members) {
                if (downloadManager.delete(member, path, eventMetadata)) {
                    contentGeneratorManager.handleContentDeletion(member, path, eventMetadata);
                }
            }
        }
        contentGeneratorManager.handleContentDeletion(store, path, eventMetadata);
        result = true;
    } else {
        if (downloadManager.delete(store, path, eventMetadata)) {
            result = true;
            contentGeneratorManager.handleContentDeletion(store, path, eventMetadata);
        }
    }
    return result;
}
Also used : SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 24 with SpecialPathInfo

use of org.commonjava.maven.galley.model.SpecialPathInfo in project indy by Commonjava.

the class DefaultContentManager method getTransfer.

@Override
public Transfer getTransfer(final ArtifactStore store, final String path, final TransferOperation op) throws IndyWorkflowException {
    logger.trace("Getting transfer for: {}/{} (op: {})", store.getKey(), path, op);
    if (group == store.getKey().getType()) {
        KeyedLocation location = LocationUtils.toLocation(store);
        SpecialPathInfo spInfo = specialPathManager.getSpecialPathInfo(location, path, store.getPackageType());
        if (spInfo == null || !spInfo.isMergable()) {
            List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
            logger.trace("Trying to retrieve suitable transfer for: {} in group: {}", path, store.getName());
            logger.trace("Members in group {}: {}", store.getName(), members);
            return getTransfer(members, path, op);
        } else {
            logger.trace("Detected mergable special path: {}/{}.", store.getKey(), path);
        }
    }
    logger.trace("Retrieving storage reference (Transfer) directly for: {}/{}", store.getKey(), path);
    return downloadManager.getStorageReference(store, path, op);
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore)

Example 25 with SpecialPathInfo

use of org.commonjava.maven.galley.model.SpecialPathInfo 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);
    if (specialPathSetProducers != null) {
        specialPathSetProducers.forEach(producer -> {
            logger.trace("Adding special paths from: {}", producer.getClass().getName());
            specialPathManager.registerSpecialPathSet(producer.getSpecialPathSet());
        });
    }
    setupTransferDecoratorPipeline();
    setupCacheProviderFactory();
    // TODO: Tie this into a config file!
    transportManagerConfig = new TransportManagerConfig();
}
Also used : FilePatternMatcher(org.commonjava.maven.galley.model.FilePatternMatcher) SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) TransportManagerConfig(org.commonjava.maven.galley.config.TransportManagerConfig) PostConstruct(javax.annotation.PostConstruct)

Aggregations

SpecialPathInfo (org.commonjava.maven.galley.model.SpecialPathInfo)30 Transfer (org.commonjava.maven.galley.model.Transfer)10 IOException (java.io.IOException)7 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)6 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)5 TransferException (org.commonjava.maven.galley.TransferException)5 Logger (org.slf4j.Logger)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 IndyDataException (org.commonjava.indy.data.IndyDataException)4 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)4 StoreKey (org.commonjava.indy.model.core.StoreKey)4 StoreType (org.commonjava.indy.model.core.StoreType)4 List (java.util.List)3 Map (java.util.Map)3 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)3 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)3 OutputStream (java.io.OutputStream)2 HashSet (java.util.HashSet)2 PostConstruct (javax.annotation.PostConstruct)2