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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations