Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SO-6308 FULL import remote job fetch issues (7x) #1345

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public String execute(ServiceProvider context) {
final Optional<RemoteJobEntry> existingJob = JobRequests.prepareSearch()
.one()
.filterById(id)
.setFields(RemoteJobEntry.Fields.ID, RemoteJobEntry.Fields.DELETED, RemoteJobEntry.Fields.STATE)
.build()
.execute(context)
.first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.b2international.snowowl.core.attachments.Attachment;
import com.b2international.snowowl.core.jobs.JobRequests;
import com.b2international.snowowl.core.jobs.RemoteJobEntry;
import com.b2international.snowowl.core.request.io.ImportResponse;
import com.b2international.snowowl.core.util.PlatformUtil;
import com.b2international.snowowl.snomed.common.SnomedTerminologyComponentConstants;
import com.b2international.snowowl.snomed.core.domain.Rf2ReleaseType;
Expand All @@ -36,6 +37,7 @@
import com.b2international.snowowl.test.commons.Services;
import com.b2international.snowowl.test.commons.SnomedContentRule;
import com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* @since 7.18.1
Expand Down Expand Up @@ -66,6 +68,9 @@ private void doImport(final String importFile, final String importUntil) {
.getSync(1, TimeUnit.MINUTES);
RemoteJobEntry job = JobRequests.waitForJob(Services.bus(), jobId, 2000 /* 2 seconds */);
assertTrue("Failed to import RF2 archive", job.isSuccessful());
ImportResponse response = job.getResultAs(Services.context().service(ObjectMapper.class), ImportResponse.class);
//assert that the previous import job didn't store all visited components
assertTrue("Import result of FULL RF2 import should NOT include any visited components", response.getVisitedComponents().isEmpty());
// assert that the version for importUntil is present in the system
String latestImportedEffectiveTime = CodeSystemVersionRestRequests.getLatestVersion(SnomedTerminologyComponentConstants.SNOMED_SHORT_NAME).getEffectiveDate();
assertEquals(importUntil, latestImportedEffectiveTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,9 @@ ImportResponse doImport(final BranchContext context, final File rf2Archive, fina
// if not a dryRun, perform import
if (!dryRun) {
// Import effective time slices in chronological order
boolean collectVisitedComponents = Rf2ReleaseType.DELTA == releaseType;
for (Rf2EffectiveTimeSlice slice : orderedEffectiveTimeSlices) {
slice.doImport(context, codeSystemUri, importconfig, visitedComponents);
slice.doImport(context, codeSystemUri, importconfig, visitedComponents, collectVisitedComponents);
}

// Update locales registered on the code system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public LongKeyMap<Set<String>> getMembersByReferencedComponent() {
}

@Override
public void doImport(BranchContext context, CodeSystemURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder<ComponentURI> visitedComponents) throws Exception {
public void doImport(BranchContext context, CodeSystemURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder<ComponentURI> visitedComponents, boolean collectVisitedComponents) throws Exception {
context.log().info(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ public void doImport(
final BranchContext context,
final CodeSystemURI codeSystemUri,
final Rf2ImportConfiguration importConfig,
final ImmutableSet.Builder<ComponentURI> visitedComponents) throws Exception {
final ImmutableSet.Builder<ComponentURI> visitedComponents,
boolean collectVisitedComponents) throws Exception {

final Stopwatch w = Stopwatch.createStarted();
final String importingMessage = isUnpublishedSlice() ? "Importing unpublished components" : String.format("Importing components from %s", getEffectiveTime());
Expand Down Expand Up @@ -210,7 +211,7 @@ public void doImport(

// Register container concept as visited component
final String conceptId = getConceptId(component);
visitedComponents.add(ComponentURI.of(codeSystemUri, SnomedTerminologyComponentConstants.CONCEPT_NUMBER, conceptId));
addVisitedComponent(visitedComponents, ComponentURI.of(codeSystemUri, SnomedTerminologyComponentConstants.CONCEPT_NUMBER, conceptId), collectVisitedComponents);
}
// add all members of this component to this batch as well
final Set<String> containerComponents = membersByReferencedComponent.remove(componentToImportL);
Expand All @@ -222,7 +223,7 @@ public void doImport(

// Register reference set as visited component
final String refSetId = containedComponent.getReferenceSetId();
visitedComponents.add(ComponentURI.of(codeSystemUri, SnomedTerminologyComponentConstants.REFSET_NUMBER, refSetId));
addVisitedComponent(visitedComponents, ComponentURI.of(codeSystemUri, SnomedTerminologyComponentConstants.REFSET_NUMBER, refSetId), collectVisitedComponents);
}
}
}
Expand Down Expand Up @@ -252,7 +253,13 @@ public void doImport(

context.log().info("{} in {}", commitMessage, w);
}


private void addVisitedComponent(ImmutableSet.Builder<ComponentURI> visitedComponents, ComponentURI component, boolean collectVisitedComponents) {
if (collectVisitedComponents) {
visitedComponents.add(component);
}
}

private LongSet collectAttributesWithRangeConstraint(final BranchContext context, final String rangeConstraint) {
final LongSet typeIds = PrimitiveSets.newLongOpenHashSet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public interface Rf2EffectiveTimeSlice {

LongKeyMap<Set<String>> getMembersByReferencedComponent();

void doImport(BranchContext context, CodeSystemURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder<ComponentURI> visitedComponents) throws Exception;
void doImport(BranchContext context, CodeSystemURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder<ComponentURI> visitedComponents, boolean collectVisitedComponents) throws Exception;

}
Loading