use of com.b2international.snowowl.core.events.util.Promise in project snow-owl by b2ihealthcare.
the class ValidationThreadPoolTest method test50JobsOfAllTypes.
@Test
public void test50JobsOfAllTypes() {
final IJobManager manager = Job.getJobManager();
final List<Promise<Object>> validationPromises = Lists.newArrayList();
validationPromises.add(pool.submit(CheckType.EXPENSIVE, createValidatableRunnable(CheckType.EXPENSIVE, manager)));
for (int i = 0; i < 10; i++) {
validationPromises.add(pool.submit(CheckType.FAST, createValidatableRunnable(CheckType.FAST, manager)));
validationPromises.add(pool.submit(CheckType.NORMAL, createValidatableRunnable(CheckType.NORMAL, manager)));
if (i % 3 == 0) {
validationPromises.add(pool.submit(CheckType.EXPENSIVE, createValidatableRunnable(CheckType.EXPENSIVE, manager)));
}
}
Promise.all(validationPromises).getSync();
}
use of com.b2international.snowowl.core.events.util.Promise in project snow-owl by b2ihealthcare.
the class ValidationThreadPoolTest method testConcurrentNormalJobsWithFastOnes.
@Test
public void testConcurrentNormalJobsWithFastOnes() {
final IJobManager manager = Job.getJobManager();
final List<Promise<Object>> validationPromises = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
validationPromises.add(pool.submit(CheckType.NORMAL, createValidatableRunnable(CheckType.NORMAL, manager)));
if (i % 2 == 0) {
validationPromises.add(pool.submit(CheckType.FAST, createValidatableRunnable(CheckType.FAST, manager)));
}
}
Promise.all(validationPromises).getSync();
}
use of com.b2international.snowowl.core.events.util.Promise in project snow-owl by b2ihealthcare.
the class ValidationThreadPoolTest method TestConcurrentNormalJobs.
@Test
public void TestConcurrentNormalJobs() {
final IJobManager manager = Job.getJobManager();
final Runnable fastRunnable = createValidatableRunnable(CheckType.NORMAL, manager);
final List<Promise<Object>> validationPromises = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
validationPromises.add(pool.submit(CheckType.NORMAL, fastRunnable));
}
Promise.all(validationPromises).getSync();
}
use of com.b2international.snowowl.core.events.util.Promise in project snow-owl by b2ihealthcare.
the class CodeSystemUpgradeRestService method upgrade.
@Operation(summary = "Start a Code System dependency upgrade (EXPERIMENTAL)", description = "Starts the upgrade process of a Code System to a newer extensionOf Code System dependency than the current extensionOf.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Upgrade created"), @ApiResponse(responseCode = "400", description = "Code System cannot be upgraded") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public Promise<ResponseEntity<Void>> upgrade(@RequestBody final UpgradeRestInput body) {
final UriComponentsBuilder uriBuilder = createURIBuilder();
final ResourceURI upgradeOf = new ResourceURI(body.getUpgradeOf());
final IEventBus bus = getBus();
return // TODO move this to generic resource controller
CodeSystemRequests.prepareGetCodeSystem(upgradeOf.getResourceId()).buildAsync().execute(bus).thenWith(codeSystem -> {
return CodeSystemRequests.prepareUpgrade(upgradeOf, new ResourceURI(body.getExtensionOf())).setResourceId(body.getCodeSystemId()).buildAsync().execute(bus);
}).then(upgradeCodeSystemId -> {
return ResponseEntity.created(uriBuilder.pathSegment(upgradeCodeSystemId).build().toUri()).build();
});
}
use of com.b2international.snowowl.core.events.util.Promise in project snow-owl by b2ihealthcare.
the class EclExpression method resolve.
public Promise<Set<String>> resolve(final BranchContext context) {
if (promise == null) {
RevisionSearcher searcher = context.service(RevisionSearcher.class);
boolean cached = context.optionalService(PathWithVersion.class).isPresent();
promise = resolveToExpression(context).then(expression -> {
// shortcut to extract IDs from the query itself if possible
if (SnomedEclEvaluationRequest.canExtractIds(expression)) {
return SnomedEclEvaluationRequest.extractIds(expression);
}
try {
return newHashSet(searcher.search(Query.select(String.class).from(SnomedConceptDocument.class).fields(SnomedConceptDocument.Fields.ID).where(expression).limit(Integer.MAX_VALUE).cached(cached).build()));
} catch (IOException e) {
throw new SnowowlRuntimeException(e);
}
});
}
return promise;
}
Aggregations