use of gov.cms.ab2d.coverage.model.CoverageSearch in project ab2d by CMSgov.
the class CoverageServiceImplTest method submitSearches.
@DisplayName("Coverage period searches are successfully submitted")
@Test
void submitSearches() {
CoverageSearchEvent cs1 = coverageService.submitSearch(period1Jan.getId(), "testing").get();
CoverageSearchEvent cs1Copy = coverageSearchEventRepo.findById(cs1.getId()).get();
CoverageSearch coverageSearch = coverageSearchRepo.findFirstByOrderByCreatedAsc().get();
assertEquals(CoverageJobStatus.SUBMITTED, cs1Copy.getNewStatus());
// Make sure that coverage search and search event match
assertEquals(cs1Copy.getCoveragePeriod(), coverageSearch.getPeriod());
startSearchAndPullEvent();
}
use of gov.cms.ab2d.coverage.model.CoverageSearch in project ab2d by CMSgov.
the class InsertionJob method call.
public CoverageSearchEvent call() {
// Add in progress event as foreign key for all inserts
coverageService.submitSearch(period.getId(), "testing");
CoverageSearch search = new CoverageSearch();
search.setPeriod(period);
search.setAttempts(0);
search.setCreated(OffsetDateTime.now());
CoverageSearchEvent inProgress = coverageService.startSearch(search, "testing").get().getCoverageSearchEvent();
// Run inserts
// If number of experiments is greater than 1 then data will be erased after each experiment
List<Long> timings = performExperiments(period, inProgress, dataPoints, experiments);
// Average and print times of experiments
long averageTime = timings.stream().reduce(0L, Long::sum) / timings.size();
System.out.println("Average milliseconds " + averageTime);
System.out.println("Times " + timings.stream().map(Object::toString).collect(joining(", ")));
return inProgress;
}
use of gov.cms.ab2d.coverage.model.CoverageSearch in project ab2d by CMSgov.
the class CoverageServiceImpl method resubmitSearch.
@Override
public CoverageSearchEvent resubmitSearch(int periodId, int attempts, String failedDescription, String restartDescription, boolean prioritize) {
CoveragePeriod period = findCoveragePeriod(periodId);
updateStatus(period, failedDescription, CoverageJobStatus.FAILED, false);
// Add to queue of jobs to do
CoverageSearch search = new CoverageSearch();
search.setPeriod(period);
search.setAttempts(attempts);
// Force to front of the queue if necessary
if (prioritize) {
search.setCreated(OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC));
}
coverageSearchRepo.saveAndFlush(search);
return updateStatus(period, restartDescription, CoverageJobStatus.SUBMITTED);
}
use of gov.cms.ab2d.coverage.model.CoverageSearch in project ab2d by CMSgov.
the class CoverageServiceImpl method submitSearch.
@Override
public Optional<CoverageSearchEvent> submitSearch(int periodId, int attempts, String description) {
CoveragePeriod period = findCoveragePeriod(periodId);
CoverageJobStatus coverageJobStatus = period.getStatus();
if (coverageJobStatus == CoverageJobStatus.IN_PROGRESS || coverageJobStatus == CoverageJobStatus.SUBMITTED) {
return Optional.empty();
}
// Add to queue of jobs to do
CoverageSearch search = new CoverageSearch();
search.setPeriod(period);
search.setAttempts(attempts);
coverageSearchRepo.saveAndFlush(search);
return Optional.of(updateStatus(period, description, CoverageJobStatus.SUBMITTED));
}
use of gov.cms.ab2d.coverage.model.CoverageSearch in project ab2d by CMSgov.
the class CoverageServiceImplTest method verifyDBStructure.
@DisplayName("DB structure matches JPA")
@Test
void verifyDBStructure() {
CoverageSearchEvent cs1 = coverageService.submitSearch(period1Jan.getId(), "testing").get();
assertNotNull(cs1.getId());
CoverageSearchEvent csCopy = coverageSearchEventRepo.findById(cs1.getId()).get();
assertNotNull(csCopy.getCoveragePeriod());
assertNull(csCopy.getOldStatus());
assertNotNull(csCopy.getNewStatus());
assertNotNull(csCopy.getDescription());
assertEquals(cs1.getCoveragePeriod(), csCopy.getCoveragePeriod());
assertEquals(cs1.getDescription(), csCopy.getDescription());
assertEquals(cs1.getNewStatus(), csCopy.getNewStatus());
// Submitting a coverage search added row to coverage search table
Optional<CoverageSearch> search = coverageSearchRepo.findFirstByOrderByCreatedAsc();
assertTrue(search.isPresent());
assertNotNull(search.get().getCreated());
assertEquals(period1Jan, search.get().getPeriod());
}
Aggregations