use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class IndexingContentManagerDecorator method getIndexedMemberTransfer.
@Measure
@Deprecated
public Transfer getIndexedMemberTransfer(final Group group, final String path, TransferOperation op, ContentManagementFunction func, final EventMetadata metadata) throws IndyWorkflowException {
StoreKey topKey = group.getKey();
List<StoreKey> toProcess = new ArrayList<>(group.getConstituents());
Set<StoreKey> seen = new HashSet<>();
while (!toProcess.isEmpty()) {
StoreKey key = toProcess.remove(0);
seen.add(key);
final ArtifactStore member;
try {
member = storeDataManager.getArtifactStore(key);
if (member == null) {
continue;
}
} catch (IndyDataException e) {
logger.error(String.format("Failed to lookup store: %s (in membership of: %s). Reason: %s", key, topKey, e.getMessage()), e);
continue;
}
Transfer transfer = getIndexedTransfer(key, topKey, path, op, metadata);
if (transfer == null && StoreType.group != key.getType()) {
// don't call this for constituents that are groups...we'll manually traverse the membership below...
transfer = func.apply(member);
}
if (transfer != null) {
if (indexCfg.isEnabled()) {
indexManager.indexTransferIn(transfer, key, topKey);
}
return transfer;
} else if (StoreType.group == key.getType()) {
int i = 0;
for (StoreKey memberKey : ((Group) member).getConstituents()) {
if (!seen.contains(memberKey)) {
toProcess.add(i, memberKey);
i++;
}
}
}
}
return null;
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class IndexingContentManagerDecorator method getIndexedTransfer.
@Measure
public Transfer getIndexedTransfer(final StoreKey storeKey, final StoreKey topKey, final String path, final TransferOperation op, final EventMetadata metadata) throws IndyWorkflowException {
if (!indexCfg.isEnabled()) {
logger.debug("Content indexing is disabled. Returning null for indexedTransfer of: {}/{}", storeKey, path);
return null;
}
logger.debug("Looking for indexed path: {} in: {} (entry point: {})", path, storeKey, topKey);
try {
ArtifactStore store = storeDataManager.getArtifactStore(storeKey);
if (store.isDisabled()) {
logger.debug("Content not available in index caching layer due to store disabled for {} in group {}", storeKey, topKey);
return null;
}
} catch (IndyDataException e) {
logger.error(String.format("Failed to lookup store: %s (in membership of: %s). Reason: %s", storeKey, topKey, e.getMessage()), e);
// TODO: Need further check if it is suitable to throw a IndyWorkflowException here.
return null;
}
StoreKey indexedStoreKey = indexManager.getIndexedStoreKey(storeKey, path);
if (indexedStoreKey != null) {
Transfer transfer = delegate.getTransfer(indexedStoreKey, path, op);
if (transfer == null || !transfer.exists()) {
if (indexedStoreKey.getType() == StoreType.remote) {
// Transfer not existing may be caused by not cached for remote repo, so we should trigger downloading
// immediately to check if it really exists.
logger.debug("Will trigger downloading of path {} from store {} from content index level", path, indexedStoreKey);
try {
transfer = delegate.retrieve(storeDataManager.getArtifactStore(indexedStoreKey), path, metadata);
if (transfer != null && transfer.exists()) {
logger.debug("Downloaded and found it: {}", transfer);
return transfer;
}
} catch (IndyDataException e) {
logger.warn("Error to get store {} caused by {}", indexedStoreKey, e.getMessage());
}
}
logger.trace("Found obsolete index entry: {},{}. De-indexing from: {} and {}", indexedStoreKey, path, storeKey, topKey);
// something happened to the underlying Transfer...de-index it, and don't return it.
indexManager.deIndexStorePath(storeKey, path);
if (topKey != null) {
logger.debug("{} Not found in: {}. De-indexing from: {} (topKey)", path, storeKey, topKey);
indexManager.deIndexStorePath(topKey, path);
}
} else {
logger.debug("Found it: {}", transfer);
return transfer;
}
}
return null;
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class DefaultContentIndexManager method indexTransferIn.
@Override
@Measure
public void indexTransferIn(Transfer transfer, StoreKey... topKeys) {
if (!config.isEnabled()) {
logger.debug("Content indexing is disabled.");
return;
}
if (transfer != null && transfer.exists()) {
StoreKey key = LocationUtils.getKey(transfer);
String path = getStrategyPath(key, transfer.getPath());
indexPathInStores(path, key, topKeys);
}
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class DefaultContentIndexManager method clearAllIndexedPathInStoreWithOriginal.
@Override
@Measure
public void clearAllIndexedPathInStoreWithOriginal(ArtifactStore store, ArtifactStore originalStore) {
if (!config.isEnabled()) {
logger.debug("Content indexing is disabled.");
return;
}
StoreKey sk = store.getKey();
StoreKey osk = originalStore.getKey();
long total = iterateRemove(() -> queryFactory.from(IndexedStorePath.class).maxResults(ITERATE_RESULT_SIZE).having("packageType").eq(osk.getPackageType()).and().having("storeType").eq(sk.getType().name()).and().having("storeName").eq(sk.getName()).and().having("originStoreType").eq(osk.getType().name()).and().having("originStoreName").eq(osk.getName()).toBuilder().build());
logger.trace("Cleared all indices with origin: {} and group: {}, size: {}", osk, sk, total);
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class ContentGeneratorManager method generateFileContentAnd.
@Measure
public Transfer generateFileContentAnd(final ArtifactStore store, final String path, final EventMetadata eventMetadata, Consumer<Transfer> consumer) throws IndyWorkflowException {
Transfer item = null;
for (final ContentGenerator generator : contentGenerators) {
logger.trace("Attempting to generate content, path: {}, store: {}, via: {}", path, store, generator);
item = generator.generateFileContent(store, path, eventMetadata);
if (item != null) {
consumer.accept(item);
break;
}
}
return item;
}
Aggregations