Search in sources :

Example 36 with Measure

use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.

the class ContentGeneratorManager method handleContentStorage.

@Measure
public void handleContentStorage(ArtifactStore transferStore, String path, Transfer txfr, EventMetadata eventMetadata) throws IndyWorkflowException {
    for (final ContentGenerator generator : contentGenerators) {
        logger.debug("{} Handling content storage of: {} in: {}", generator, path, transferStore.getKey());
        generator.handleContentStorage(transferStore, path, txfr, eventMetadata);
    }
}
Also used : ContentGenerator(org.commonjava.indy.content.ContentGenerator) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 37 with Measure

use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.

the class StoreEnablementManager method onDisableTimeout.

@Measure
public void onDisableTimeout(@Observes ScheduleTriggerEvent evt) {
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.debug("Checking for store-reenable event in: {} (trigger? {} Disable-Timeout? {})", evt, true, DISABLE_TIMEOUT.equals(evt.getJobType()));
    if (DISABLE_TIMEOUT.equals(evt.getJobType())) {
        handleDisableTimeout(evt.getPayload());
    }
}
Also used : Logger(org.slf4j.Logger) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 38 with Measure

use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.

the class DefaultDownloadManager method listRecursively.

@Override
@Measure
public List<Transfer> listRecursively(final StoreKey src, final String startPath) throws IndyWorkflowException {
    final List<Transfer> result = new ArrayList<>();
    final Transfer transfer = getStorageReference(src, startPath);
    recurseListing(transfer, result);
    logger.debug("listRecursively result: {}", result);
    return result;
}
Also used : Transfer(org.commonjava.maven.galley.model.Transfer) ArrayList(java.util.ArrayList) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 39 with Measure

use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.

the class DefaultDownloadManager method list.

@Override
@Measure
public List<StoreResource> list(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
    final List<StoreResource> result = new ArrayList<>();
    if (store.getKey().getType() == StoreType.group) {
        try {
            final List<ListingResult> results = transfers.listAll(locationExpander.expand(new VirtualResource(LocationUtils.toLocations(store), path)), eventMetadata);
            for (final ListingResult lr : results) {
                if (lr != null && lr.getListing() != null) {
                    for (final String file : lr.getListing()) {
                        result.add(new StoreResource((KeyedLocation) lr.getLocation(), path, file));
                    }
                }
            }
        } catch (final TransferLocationException e) {
            fireIndyStoreErrorEvent(e);
            logger.warn("Location Error: " + e.getMessage(), e);
            throw new IndyWorkflowException("Failed to list ALL paths: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
        } catch (final TransferException e) {
            logger.error(e.getMessage(), e);
            throw new IndyWorkflowException("Failed to list ALL paths: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
        }
    } else {
        if (!PathMaskChecker.checkListingMask(store, path)) {
            // if list not permitted for the path, return empty list
            return result;
        }
        final KeyedLocation loc = LocationUtils.toLocation(store);
        final StoreResource res = new StoreResource(loc, path);
        if (store instanceof RemoteRepository) {
            try {
                final ListingResult lr = transfers.list(res, eventMetadata);
                if (lr != null && lr.getListing() != null) {
                    for (final String file : lr.getListing()) {
                        result.add(new StoreResource(loc, path, file));
                    }
                }
            } catch (final TransferLocationException e) {
                fireIndyStoreErrorEvent(e);
                logger.warn("Location Error: " + e.getMessage(), e);
                throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
            } catch (final TransferException e) {
                logger.error(e.getMessage(), e);
                throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
            }
        } else {
            try {
                final ListingResult listing = transfers.list(res, eventMetadata);
                if (listing != null && listing.getListing() != null) {
                    for (final String child : listing.getListing()) {
                        result.add(new StoreResource(loc, path, child));
                    }
                }
            } catch (final TransferLocationException e) {
                fireIndyStoreErrorEvent(e);
                logger.warn("Timeout  / bad gateway: " + e.getMessage(), e);
                throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
            } catch (final TransferException e) {
                logger.error(e.getMessage(), e);
                throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
            }
        }
    }
    return dedupeListing(result);
}
Also used : StoreResource(org.commonjava.indy.content.StoreResource) TransferException(org.commonjava.maven.galley.TransferException) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) ArrayList(java.util.ArrayList) VirtualResource(org.commonjava.maven.galley.model.VirtualResource) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) ListingResult(org.commonjava.maven.galley.model.ListingResult) TransferLocationException(org.commonjava.maven.galley.TransferLocationException) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 40 with Measure

use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.

the class DefaultContentManager method list.

@Override
@Measure
public List<StoreResource> list(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
    final EventMetadata metadata = setAllowRemoteDownloading(eventMetadata);
    List<StoreResource> listed;
    if (group == store.getKey().getType()) {
        List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
        listed = new ArrayList<>();
        contentGeneratorManager.generateGroupDirectoryContentAnd((Group) store, members, path, eventMetadata, listed::addAll);
        for (final ArtifactStore member : members) {
            List<StoreResource> storeListing = null;
            try {
                storeListing = list(member, path, metadata);
            } catch (IndyWorkflowException e) {
                e.filterLocationErrors();
            }
            if (storeListing != null) {
                listed.addAll(storeListing);
            }
        }
    } else {
        listed = downloadManager.list(store, path, metadata);
        contentGeneratorManager.generateDirectoryContentAnd(store, path, listed, metadata, listed::addAll);
    }
    return dedupeListing(listed);
}
Also used : StoreResource(org.commonjava.indy.content.StoreResource) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Aggregations

Measure (org.commonjava.o11yphant.metrics.annotation.Measure)65 StoreKey (org.commonjava.indy.model.core.StoreKey)23 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)19 Transfer (org.commonjava.maven.galley.model.Transfer)19 Logger (org.slf4j.Logger)19 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)16 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)14 IndyDataException (org.commonjava.indy.data.IndyDataException)13 ArrayList (java.util.ArrayList)12 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)11 HashSet (java.util.HashSet)9 Group (org.commonjava.indy.model.core.Group)8 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)8 BoundStatement (com.datastax.driver.core.BoundStatement)6 StoreDataManager (org.commonjava.indy.data.StoreDataManager)6 StoreKey.fromString (org.commonjava.indy.model.core.StoreKey.fromString)6 Query (org.infinispan.query.dsl.Query)6 IOException (java.io.IOException)5 Set (java.util.Set)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5