Search in sources :

Example 41 with Measure

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

the class DefaultContentManager method retrieveAll.

@Override
@Measure
public List<Transfer> retrieveAll(final List<? extends ArtifactStore> stores, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
    final List<Transfer> txfrs = new ArrayList<>();
    for (final ArtifactStore store : stores) {
        if (group == store.getKey().getType()) {
            List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
            final List<Transfer> storeTransfers = new ArrayList<>();
            contentGeneratorManager.generateGroupFileContentAnd((Group) store, members, path, eventMetadata, storeTransfers::add);
            // ...if it's generated, it's merged in this case.
            if (storeTransfers.isEmpty()) {
                for (final ArtifactStore member : members) {
                    // NOTE: This is only safe to call because we're concrete ordered stores, so anything passing through here is concrete.
                    final Transfer txfr = doRetrieve(member, path, eventMetadata);
                    if (txfr != null) {
                        storeTransfers.add(txfr);
                    }
                }
            }
            txfrs.addAll(storeTransfers);
        } else {
            // NOTE: This is only safe to call because we're doing the group check up front, so anything passing through here is concrete.
            final Transfer txfr = doRetrieve(store, path, eventMetadata);
            if (txfr != null) {
                txfrs.add(txfr);
            }
        }
    }
    return txfrs;
}
Also used : ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) Transfer(org.commonjava.maven.galley.model.Transfer) ArrayList(java.util.ArrayList) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 42 with Measure

use of org.commonjava.o11yphant.metrics.annotation.Measure 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 43 with Measure

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

the class DefaultDirectContentAccess method retrieveRaw.

@Override
@Measure
public Transfer retrieveRaw(final ArtifactStore store, String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
    // npm should handle the path as '/project' not '/project/package.json' when retrieves a remote registry
    if (store.getType() == remote && store.getPackageType().equals(NPM_PKG_KEY) && path.endsWith(NPM_METADATA_NAME)) {
        String project = path.substring(0, path.length() - (NPM_METADATA_NAME.length() + 1));
        if (project != null && project.length() > 0) {
            path = project;
        }
    }
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.trace("Attempting to retrieve: {} from: {}", path, store.getKey());
    Transfer item = null;
    try {
        item = downloadManager.retrieve(store, path, eventMetadata);
    } catch (IndyWorkflowException e) {
        e.filterLocationErrors();
    }
    return item;
}
Also used : IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Transfer(org.commonjava.maven.galley.model.Transfer) Logger(org.slf4j.Logger) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 44 with Measure

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

the class CassandraNotFoundCache method clearMissing.

@Override
@Measure
public void clearMissing(final ConcreteResource resource) {
    StoreKey key = getResourceKey(resource);
    BoundStatement bound = preparedDelete.bind(key.toString(), resource.getPath());
    session.execute(bound);
    inMemoryCache.remove(resource);
}
Also used : StoreKey(org.commonjava.indy.model.core.StoreKey) BoundStatement(com.datastax.driver.core.BoundStatement) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Example 45 with Measure

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

the class CassandraNotFoundCache method getMissing.

@Override
@Measure
public Set<String> getMissing(final Location location) {
    logger.debug("[NFC] getMissing for {}", location);
    StoreKey key = ((KeyedLocation) location).getKey();
    BoundStatement bound = preparedQueryByStore.bind(key.toString());
    ResultSet result = session.execute(bound);
    int count = 0;
    Set<String> matches = new HashSet<>();
    for (Row row : result) {
        if (maxResultSetSize > 0 && count >= maxResultSetSize) {
            logger.debug("[NFC] getMissing reach maxResultSetSize: {}", maxResultSetSize);
            break;
        }
        count++;
        matches.add(row.get("path", String.class));
    }
    logger.debug("[NFC] getMissing complete, count: {}", matches.size());
    return matches;
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) StoreKey(org.commonjava.indy.model.core.StoreKey) BoundStatement(com.datastax.driver.core.BoundStatement) HashSet(java.util.HashSet) 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