use of org.commonjava.indy.koji.model.KojiMultiRepairResult in project indy by Commonjava.
the class KojiRepairManager method repairAllPathMasks.
public KojiMultiRepairResult repairAllPathMasks(final String user) throws KojiRepairException, IndyWorkflowException {
KojiMultiRepairResult result = new KojiMultiRepairResult();
if (opLock.tryLock()) {
try {
List<RemoteRepository> kojiRemotes = getAllKojiRemotes();
DrainingExecutorCompletionService<KojiRepairResult> repairService = new DrainingExecutorCompletionService<>(repairExecutor);
detectOverloadVoid(() -> kojiRemotes.forEach(r -> repairService.submit(() -> {
logger.info("Attempting to repair path masks in Koji remote: {}", r.getKey());
KojiRepairRequest request = new KojiRepairRequest(r.getKey(), false);
try {
return repairPathMask(request, user, true);
} catch (KojiRepairException e) {
logger.error("Failed to execute repair for: " + r.getKey(), e);
}
return null;
})));
List<KojiRepairResult> results = new ArrayList<>();
try {
repairService.drain(r -> {
if (r != null) {
results.add(r);
}
});
} catch (InterruptedException | ExecutionException e) {
logger.error("Failed to repair path masks.", e);
}
result.setResults(results);
} catch (IndyDataException e) {
throw new KojiRepairException("Failed to list Koji remote repositories for repair. Reason: %s", e, e.getMessage());
} finally {
opLock.unlock();
}
} else {
throw new KojiRepairException("Koji repair manager is busy.");
}
return result;
}
use of org.commonjava.indy.koji.model.KojiMultiRepairResult in project indy by Commonjava.
the class KojiRepairManager method repairAllMetadataTimeout.
public KojiMultiRepairResult repairAllMetadataTimeout(final String user, boolean isDryRun) throws KojiRepairException, IndyWorkflowException {
KojiMultiRepairResult result = new KojiMultiRepairResult();
if (opLock.tryLock()) {
try {
List<RemoteRepository> kojiRemotes = getAllKojiRemotes();
DrainingExecutorCompletionService<KojiRepairResult> repairService = new DrainingExecutorCompletionService<>(repairExecutor);
detectOverloadVoid(() -> kojiRemotes.forEach(r -> repairService.submit(() -> {
logger.info("Attempting to repair path masks in Koji remote: {}", r.getKey());
KojiRepairRequest request = new KojiRepairRequest(r.getKey(), isDryRun);
try {
return repairMetadataTimeout(request, user, true);
} catch (KojiRepairException e) {
logger.error("Failed to execute repair for: " + r.getKey(), e);
}
return null;
})));
List<KojiRepairResult> results = new ArrayList<>();
try {
repairService.drain(r -> {
if (r != null) {
results.add(r);
}
});
} catch (InterruptedException | ExecutionException e) {
logger.error("Failed to repair metadata timeout.", e);
}
result.setResults(results);
} catch (IndyDataException e) {
throw new KojiRepairException("Failed to list Koji remote repositories for repair. Reason: %s", e, e.getMessage());
} finally {
opLock.unlock();
}
} else {
throw new KojiRepairException("Koji repair manager is busy.");
}
return result;
}
Aggregations