use of org.commonjava.indy.folo.model.TrackedContentEntry in project indy by Commonjava.
the class FoloAdminController method addTransfers.
private void addTransfers(final Set<TrackedContentEntry> entries, final List<Transfer> items, final String trackingId, final Set<String> seenPaths) throws IndyWorkflowException {
if (entries != null && !entries.isEmpty()) {
for (final TrackedContentEntry entry : entries) {
final String path = entry.getPath();
if (path == null || seenPaths.contains(path)) {
continue;
}
final StoreKey sk = entry.getStoreKey();
Transfer transfer = contentManager.getTransfer(sk, path, TransferOperation.DOWNLOAD);
if (transfer == null) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.warn("While creating Folo repo zip for: {}, cannot find: {} in: {}", trackingId, path, sk);
} else {
seenPaths.add(path);
items.add(transfer);
}
}
}
}
use of org.commonjava.indy.folo.model.TrackedContentEntry in project indy by Commonjava.
the class FoloAdminController method recalculateRecord.
public TrackedContentDTO recalculateRecord(final String id, final String baseUrl) throws IndyWorkflowException {
TrackingKey trackingKey = new TrackingKey(id);
TrackedContent record = recordManager.get(trackingKey);
AtomicBoolean failed = new AtomicBoolean(false);
Set<TrackedContentEntry> recalculatedUploads = recalculateEntrySet(record.getUploads(), id, failed);
Set<TrackedContentEntry> recalculatedDownloads = recalculateEntrySet(record.getDownloads(), id, failed);
if (failed.get()) {
throw new IndyWorkflowException("Failed to recalculate tracking record: %s. See Indy logs for more information", id);
}
TrackedContent recalculated = new TrackedContent(record.getKey(), recalculatedUploads, recalculatedDownloads);
recordManager.replaceTrackingRecord(recalculated);
return constructContentDTO(recalculated, baseUrl);
}
use of org.commonjava.indy.folo.model.TrackedContentEntry in project indy by Commonjava.
the class FoloAdminController method constructContentDTO.
private TrackedContentDTO constructContentDTO(final TrackedContent content, final String baseUrl) {
if (content == null) {
return null;
}
final Set<TrackedContentEntryDTO> uploads = new TreeSet<>();
for (TrackedContentEntry entry : content.getUploads()) {
uploads.add(constructContentEntryDTO(entry, baseUrl));
}
final Set<TrackedContentEntryDTO> downloads = new TreeSet<>();
for (TrackedContentEntry entry : content.getDownloads()) {
downloads.add(constructContentEntryDTO(entry, baseUrl));
}
return new TrackedContentDTO(content.getKey(), uploads, downloads);
}
use of org.commonjava.indy.folo.model.TrackedContentEntry in project indy by Commonjava.
the class FoloRecordCache method seal.
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.debug("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.indy.folo.model.TrackedContentEntry in project indy by Commonjava.
the class FoloRecordCache method inProgressByTrackingKey.
private <R> R inProgressByTrackingKey(final TrackingKey key, final BiFunction<QueryBuilder, CacheHandle<TrackedContentEntry, TrackedContentEntry>, R> operation) {
return inProgressRecordCache.execute((cache) -> {
QueryFactory queryFactory = Search.getQueryFactory(cache);
QueryBuilder qb = queryFactory.from(TrackedContentEntry.class).having("trackingKey.id").eq(key.getId()).toBuilder();
return operation.apply(qb, inProgressRecordCache);
});
}
Aggregations