Search in sources :

Example 26 with Measure

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

the class StoreEnablementManager method onStoreError.

@Measure
public void onStoreError(@Observes IndyStoreErrorEvent evt) {
    Logger logger = LoggerFactory.getLogger(getClass());
    StoreKey key = evt.getStoreKey();
    Throwable error = evt.getError();
    try {
        ArtifactStore store = storeDataManager.getArtifactStore(key);
        if (store == null) {
            logger.warn("Attempt to disable missing repo! Skipping.");
            return;
        }
        store = store.copyOf();
        int disableTimeout = store.getDisableTimeout();
        if (disableTimeout <= TIMEOUT_NEVER_DISABLE) {
            logger.debug("Disable-timeout set to {}, will never disable the repo", disableTimeout);
            store.setDisabled(false);
        } else {
            store.setDisabled(true);
            final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, String.format("Disabling %s due to error: %s\n\nStack Trace:\n  %s", key, error, StringUtils.join(error.getStackTrace(), "\n  ")));
            storeDataManager.storeArtifactStore(store, changeSummary, false, true, new EventMetadata());
            logger.warn("{} has been disabled due to store-level error: {}\n Will re-enable in {} seconds.", key, error, disableTimeout == TIMEOUT_USE_DEFAULT ? config.getStoreDisableTimeoutSeconds() : disableTimeout);
            // TODO: How is it this doesn't duplicate the event handler method onStoreUpdate()...we're updating the store just above here.
            setReEnablementTimeout(key);
        }
    } catch (IndyDataException e) {
        logger.error(String.format("Failed to disable %s on error: %s", key, error), e);
    } catch (IndySchedulerException e) {
        logger.error(String.format("Failed to schedule re-enablement of %s for retry.", key), e);
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) Logger(org.slf4j.Logger) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) StoreKey(org.commonjava.indy.model.core.StoreKey) IndySchedulerException(org.commonjava.indy.core.expire.IndySchedulerException) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 27 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 SchedulerEvent evt) {
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.debug("Checking for store-reenable event in: {} (trigger? {} Disable-Timeout? {})", evt, evt instanceof SchedulerTriggerEvent, DISABLE_TIMEOUT.equals(evt.getJobType()));
    if ((evt instanceof SchedulerTriggerEvent) && DISABLE_TIMEOUT.equals(evt.getJobType())) {
        handleDisableTimeout(evt.getPayload());
    }
}
Also used : SchedulerTriggerEvent(org.commonjava.indy.core.expire.SchedulerTriggerEvent) Logger(org.slf4j.Logger) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 28 with Measure

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

the class ContentGeneratorManager method generateGroupFileContent.

@Measure
public Transfer generateGroupFileContent(Group group, List<ArtifactStore> members, String path, EventMetadata eventMetadata) throws IndyWorkflowException {
    Transfer item = null;
    String storagePath = pathGenerator.getPath(new ConcreteResource(LocationUtils.toLocation(group), path));
    for (final ContentGenerator generator : contentGenerators) {
        final boolean canProcess = generator.canProcess(path) || generator.canProcess(storagePath);
        if (canProcess) {
            item = generator.generateGroupFileContent(group, members, path, eventMetadata);
            logger.trace("From content {}.generateGroupFileContent: {} (exists? {})", generator.getClass().getSimpleName(), item, item != null && item.exists());
            if (item != null && item.exists()) {
                break;
            }
        }
    }
    return item;
}
Also used : ContentGenerator(org.commonjava.indy.content.ContentGenerator) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 29 with Measure

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

the class FoloRecordCache method seal.

@Override
@Measure
public TrackedContent seal(final TrackingKey trackingKey) {
    TrackedContent record = sealedRecordCache.get(trackingKey);
    Logger logger = LoggerFactory.getLogger(getClass());
    if (record != null) {
        logger.debug("Tracking record: {} already sealed! Returning sealed record.", trackingKey);
        return record;
    }
    logger.debug("Listing unsealed tracking record entries for: {}...", trackingKey);
    return inProgressByTrackingKey(trackingKey, (qb, cacheHandle) -> {
        Query query = qb.build();
        List<TrackedContentEntry> results = query.list();
        TrackedContent created = null;
        if (results != null) {
            logger.debug("Adding {} entries to record: {}", results.size(), trackingKey);
            Set<TrackedContentEntry> uploads = new TreeSet<>();
            Set<TrackedContentEntry> downloads = new TreeSet<>();
            results.forEach((result) -> {
                if (StoreEffect.DOWNLOAD == result.getEffect()) {
                    downloads.add(result);
                } else if (StoreEffect.UPLOAD == result.getEffect()) {
                    uploads.add(result);
                }
                logger.trace("Removing in-progress entry: {}", result);
                inProgressRecordCache.remove(result);
            });
            created = new TrackedContent(trackingKey, uploads, downloads);
        }
        logger.debug("Sealing record for: {}", trackingKey);
        sealedRecordCache.put(trackingKey, created);
        return created;
    });
}
Also used : Query(org.infinispan.query.dsl.Query) TreeSet(java.util.TreeSet) TrackedContent(org.commonjava.indy.folo.model.TrackedContent) TrackedContentEntry(org.commonjava.indy.folo.model.TrackedContentEntry) Logger(org.slf4j.Logger) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 30 with Measure

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

the class IndexingContentManagerDecorator method store.

@Override
@Measure
public Transfer store(final ArtifactStore store, final String path, final InputStream stream, final TransferOperation op, final EventMetadata eventMetadata) throws IndyWorkflowException {
    if (!indexCfg.isEnabled()) {
        return delegate.store(store, path, stream, op, eventMetadata);
    }
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.trace("Storing: {} in: {} from indexing level", path, store.getKey());
    Transfer transfer = delegate.store(store, path, stream, op, eventMetadata);
    if (transfer != null) {
        if (indexCfg.isEnabled()) {
            logger.trace("Indexing: {} in: {}", transfer, store.getKey());
            indexManager.indexTransferIn(transfer, store.getKey());
        }
        nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(store), path));
        // may change the content index sequence based on the constituents sequence in parent groups
        if (store.getType() == StoreType.hosted) {
            final String name = String.format("ContentIndexStoreDeIndex-store(%s)-path(%s)", store.getKey(), path);
            final String context = String.format("Class: %s, method: %s, store: %s, path: %s", this.getClass().getName(), "store", store.getKey(), path);
            storeDataManager.asyncGroupAffectedBy(new StoreDataManager.ContextualTask(name, context, () -> {
                try {
                    Set<Group> groups = storeDataManager.affectedBy(Arrays.asList(store.getKey()), eventMetadata);
                    if (groups != null && !groups.isEmpty() && indexCfg.isEnabled()) {
                        groups.forEach(g -> {
                            indexManager.deIndexStorePath(g.getKey(), path);
                            nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(g), path));
                        });
                    }
                } catch (IndyDataException e) {
                    logger.error(String.format("Failed to get groups which contains: %s for NFC handling. Reason: %s", store.getKey(), e.getMessage()), e);
                }
            }));
        }
    }
    return transfer;
}
Also used : Delegate(javax.decorator.Delegate) Arrays(java.util.Arrays) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) LoggerFactory(org.slf4j.LoggerFactory) SpecialPathInfo(org.commonjava.maven.galley.model.SpecialPathInfo) Group(org.commonjava.indy.model.core.Group) ArrayList(java.util.ArrayList) GROUP_METADATA_GENERATED(org.commonjava.indy.core.content.group.GroupMergeHelper.GROUP_METADATA_GENERATED) Inject(javax.inject.Inject) HashSet(java.util.HashSet) Transfer(org.commonjava.maven.galley.model.Transfer) Measure(org.commonjava.o11yphant.metrics.annotation.Measure) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) TransferOperation(org.commonjava.maven.galley.model.TransferOperation) Any(javax.enterprise.inject.Any) Decorator(javax.decorator.Decorator) StoreKey(org.commonjava.indy.model.core.StoreKey) GROUP_METADATA_EXISTS(org.commonjava.indy.core.content.group.GroupMergeHelper.GROUP_METADATA_EXISTS) LocationUtils(org.commonjava.indy.util.LocationUtils) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Logger(org.slf4j.Logger) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) Executor(java.util.concurrent.Executor) PathMaskChecker(org.commonjava.indy.core.content.PathMaskChecker) Collection(java.util.Collection) StoreType(org.commonjava.indy.model.core.StoreType) Set(java.util.Set) SpecialPathManager(org.commonjava.maven.galley.spi.io.SpecialPathManager) NotFoundCache(org.commonjava.maven.galley.spi.nfc.NotFoundCache) ContentManager(org.commonjava.indy.content.ContentManager) Objects(java.util.Objects) List(java.util.List) HostedRepository(org.commonjava.indy.model.core.HostedRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) ContentIndexConfig(org.commonjava.indy.content.index.conf.ContentIndexConfig) IndyDataException(org.commonjava.indy.data.IndyDataException) StoreDataManager(org.commonjava.indy.data.StoreDataManager) InputStream(java.io.InputStream) IndyDataException(org.commonjava.indy.data.IndyDataException) HashSet(java.util.HashSet) Set(java.util.Set) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) StoreDataManager(org.commonjava.indy.data.StoreDataManager) Logger(org.slf4j.Logger) 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