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