diff --git a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestApplyWhen.java b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestApplyWhen.java index 1d433c9d4e..dada4b93e5 100644 --- a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestApplyWhen.java +++ b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestApplyWhen.java @@ -1171,8 +1171,6 @@ public void testCoexistenceUncontrollableJustFits() { assertEquals(3, problem.getSimulationFacade().countSimulationRestarts()); } - - @Test public void testCoexistenceExternalResource() { Interval period = Interval.betweenClosedOpen(Duration.of(0, Duration.SECONDS), Duration.of(25, Duration.SECONDS)); diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/SchedulerAppDriver.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/SchedulerAppDriver.java index 22fa976077..3f87b46791 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/SchedulerAppDriver.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/SchedulerAppDriver.java @@ -61,7 +61,7 @@ public static void main(final String[] args) { final var schedulerService = new CachedSchedulerService(stores.results()); final var scheduleAction = new ScheduleAction(specificationService, schedulerService); - final var generateSchedulingLibAction = new GenerateSchedulingLibAction(merlinService, merlinService); + final var generateSchedulingLibAction = new GenerateSchedulingLibAction(merlinService); //establish bindings to the service layers final var bindings = new SchedulerBindings( diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/ActivityTemplateJsonParser.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/ActivityTemplateJsonParser.java index 25ccb01a0b..9f39ec076f 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/ActivityTemplateJsonParser.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/ActivityTemplateJsonParser.java @@ -11,7 +11,7 @@ import gov.nasa.jpl.aerie.json.SchemaCache; import gov.nasa.jpl.aerie.scheduler.server.models.ActivityType; import gov.nasa.jpl.aerie.scheduler.server.models.SchedulingDSL; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; import static gov.nasa.jpl.aerie.constraints.json.ConstraintParsers.profileExpressionP; import static gov.nasa.jpl.aerie.constraints.json.ConstraintParsers.structExpressionF; @@ -20,7 +20,7 @@ public class ActivityTemplateJsonParser implements JsonParser activityTypesByName = new HashMap<>(); - public ActivityTemplateJsonParser(MissionModelService.MissionModelTypes activityTypes){ + public ActivityTemplateJsonParser(MerlinService.MissionModelTypes activityTypes){ activityTypes.activityTypes().forEach((actType)-> activityTypesByName.put(actType.name(), actType)); } diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/models/SchedulingDSL.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/models/SchedulingDSL.java index 8fef7b3b97..3f235bc5a2 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/models/SchedulingDSL.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/models/SchedulingDSL.java @@ -12,7 +12,7 @@ import gov.nasa.jpl.aerie.scheduler.TimeUtility; import gov.nasa.jpl.aerie.scheduler.constraints.timeexpressions.TimeAnchor; import gov.nasa.jpl.aerie.scheduler.server.http.ActivityTemplateJsonParser; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; import org.apache.commons.lang3.tuple.Pair; import java.util.List; @@ -57,7 +57,7 @@ public class SchedulingDSL { $ -> tuple($.duration(), $.occurrence())); private static JsonObjectParser recurrenceGoalDefinitionP( - MissionModelService.MissionModelTypes activityTypes) + MerlinService.MissionModelTypes activityTypes) { return productP .field("activityTemplate", new ActivityTemplateJsonParser(activityTypes)) @@ -112,7 +112,7 @@ private static JsonObjectParser recurren (TimingConstraint.ActivityTimingConstraintFlexibleRange $) -> tuple($.lowerBound(), $.upperBound(), $.singleton())); private static final JsonObjectParser coexistenceGoalDefinitionP( - MissionModelService.MissionModelTypes activityTypes) + MerlinService.MissionModelTypes activityTypes) { return productP @@ -146,7 +146,7 @@ private static final JsonObjectParser c } private static final JsonObjectParser cardinalityGoalDefinitionP( - MissionModelService.MissionModelTypes activityTypes) { + MerlinService.MissionModelTypes activityTypes) { return productP .field("activityTemplate", new ActivityTemplateJsonParser(activityTypes)) @@ -195,7 +195,7 @@ private static JsonObjectParser goalApplyWhenF(fina } - private static JsonParser goalSpecifierF(MissionModelService.MissionModelTypes missionModelTypes) { + private static JsonParser goalSpecifierF(MerlinService.MissionModelTypes missionModelTypes) { return recursiveP(self -> SumParsers.sumP("kind", GoalSpecifier.class, List.of( SumParsers.variant( "ActivityRecurrenceGoal", @@ -243,7 +243,7 @@ private static JsonObjectParser conditionAndF(f globalSchedulingConditionP) ))); - public static final JsonParser schedulingJsonP(MissionModelService.MissionModelTypes missionModelTypes){ + public static final JsonParser schedulingJsonP(MerlinService.MissionModelTypes missionModelTypes){ return goalSpecifierF(missionModelTypes); } diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/ConstraintsTypescriptCodeGenerationHelper.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/ConstraintsTypescriptCodeGenerationHelper.java index 55b0920c94..79469321c4 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/ConstraintsTypescriptCodeGenerationHelper.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/ConstraintsTypescriptCodeGenerationHelper.java @@ -9,7 +9,7 @@ public final class ConstraintsTypescriptCodeGenerationHelper { private ConstraintsTypescriptCodeGenerationHelper() { } - public static Map activityTypes(final MissionModelService.MissionModelTypes missionModelTypes) { + public static Map activityTypes(final MerlinService.MissionModelTypes missionModelTypes) { return missionModelTypes .activityTypes() .stream() @@ -27,7 +27,7 @@ public static Map activity .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } - public static Map resources(final MissionModelService.MissionModelTypes missionModelTypes) { + public static Map resources(final MerlinService.MissionModelTypes missionModelTypes) { return missionModelTypes .resourceTypes() .stream() diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GenerateSchedulingLibAction.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GenerateSchedulingLibAction.java index 06cb4fd5ad..d1c61dfaef 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GenerateSchedulingLibAction.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GenerateSchedulingLibAction.java @@ -14,11 +14,10 @@ import gov.nasa.jpl.aerie.scheduler.server.models.PlanId; public record GenerateSchedulingLibAction( - MissionModelService missionModelService, - PlanService.ReaderRole planService + MerlinService.ReaderRole merlinService ) { public GenerateSchedulingLibAction { - Objects.requireNonNull(planService); + Objects.requireNonNull(merlinService); } /** @@ -46,10 +45,10 @@ public Response run(final MissionModelId missionModelId, final Optional final var temporalPolyfillTypes = getTypescriptResource("constraints/TemporalPolyfillTypes.ts"); - var missionModelTypes = missionModelService.getMissionModelTypes(missionModelId); + var missionModelTypes = merlinService.getMissionModelTypes(missionModelId); if(planId.isPresent()) { - final var allResourceTypes = planService.getResourceTypes(planId.get()); - missionModelTypes = new MissionModelService.MissionModelTypes(missionModelTypes.activityTypes(), allResourceTypes); + final var allResourceTypes = merlinService.getResourceTypes(planId.get()); + missionModelTypes = new MerlinService.MissionModelTypes(missionModelTypes.activityTypes(), allResourceTypes); } final var generatedSchedulerCode = TypescriptCodeGenerationService.generateTypescriptTypesFromMissionModel(missionModelTypes); @@ -66,7 +65,7 @@ public Response run(final MissionModelId missionModelId, final Optional "file:///mission-model-generated-code.ts", generatedConstraintsCode, "file:///%s".formatted(temporalPolyfillTypes.basename), temporalPolyfillTypes.source )); - } catch (final IOException | MissionModelService.MissionModelServiceException | PlanServiceException | + } catch (final IOException | MerlinServiceException | NoSuchPlanException | NoSuchMissionModelException e) { return new Response.Failure(e.getMessage()); } diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GraphQLMerlinService.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GraphQLMerlinService.java index 6c77d6d210..eb4a9638e4 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GraphQLMerlinService.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/GraphQLMerlinService.java @@ -93,9 +93,7 @@ * * @param merlinGraphqlURI endpoint of the merlin graphql service that should be used to access all plan data */ -public record GraphQLMerlinService(URI merlinGraphqlURI, String hasuraGraphQlAdminSecret) implements PlanService.OwnerRole, - MissionModelService -{ +public record GraphQLMerlinService(URI merlinGraphqlURI, String hasuraGraphQlAdminSecret) implements MerlinService.OwnerRole { /** * timeout for http graphql requests issued to aerie @@ -136,7 +134,7 @@ public record DatasetIds(DatasetId datasetId, SimulationDatasetId simulationData * @param gqlStr the graphQL query or mutation to send to aerie * @return the json response returned by aerie, or an empty optional in case of io errors */ - protected Optional postRequest(final String gqlStr) throws IOException, PlanServiceException { + protected Optional postRequest(final String gqlStr) throws IOException, MerlinServiceException { try { //TODO: (mem optimization) use streams here to avoid several copies of strings final var reqBody = Json.createObjectBuilder().add("query", gqlStr).build(); @@ -157,7 +155,7 @@ protected Optional postRequest(final String gqlStr) throws IOExcepti } final var respBody = Json.createReader(httpResp.body()).readObject(); if (respBody.containsKey("errors")) { - throw new PlanServiceException(respBody.toString()); + throw new MerlinServiceException(respBody.toString()); } return Optional.of(respBody); } catch (final InterruptedException e) { @@ -168,7 +166,9 @@ protected Optional postRequest(final String gqlStr) throws IOExcepti } } - protected Optional postRequest(final String query, final JsonObject variables) throws IOException, PlanServiceException { + protected Optional postRequest(final String query, final JsonObject variables) throws IOException, + MerlinServiceException + { try { //TODO: (mem optimization) use streams here to avoid several copies of strings final var reqBody = Json @@ -193,7 +193,7 @@ protected Optional postRequest(final String query, final JsonObject } final var respBody = Json.createReader(httpResp.body()).readObject(); if (respBody.containsKey("errors")) { - throw new PlanServiceException(respBody.toString()); + throw new MerlinServiceException(respBody.toString()); } return Optional.of(respBody); } catch (final InterruptedException e) { @@ -211,7 +211,7 @@ protected Optional postRequest(final String query, final JsonObject * {@inheritDoc} */ @Override - public long getPlanRevision(final PlanId planId) throws IOException, NoSuchPlanException, PlanServiceException { + public long getPlanRevision(final PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException { final var query = """ query GetPlanRevision($id: Int!) { plan_by_pk(id: $id) { @@ -236,7 +236,7 @@ query GetPlanRevision($id: Int!) { */ @Override public PlanMetadata getPlanMetadata(final PlanId planId) - throws IOException, NoSuchPlanException, PlanServiceException + throws IOException, NoSuchPlanException, MerlinServiceException { final var request = ( "query getPlanMetadata { " @@ -302,7 +302,7 @@ public PlanMetadata getPlanMetadata(final PlanId planId) */ @Override public MerlinPlan getPlanActivityDirectives(final PlanMetadata planMetadata, final Problem problem) - throws IOException, NoSuchPlanException, PlanServiceException, InvalidJsonException, InstantiationException + throws IOException, NoSuchPlanException, MerlinServiceException, InvalidJsonException, InstantiationException { final var merlinPlan = new MerlinPlan(); final var request = @@ -362,7 +362,7 @@ public Pair> creat final Plan plan, final Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException + throws IOException, NoSuchPlanException, MerlinServiceException { final var planName = getNextPlanName(); final var planId = createEmptyPlan( @@ -378,7 +378,7 @@ public Pair> creat */ @Override public PlanId createEmptyPlan(final String name, final long modelId, final Instant startTime, final Duration duration) - throws IOException, NoSuchPlanException, PlanServiceException + throws IOException, NoSuchPlanException, MerlinServiceException { final var requestFormat = ( "mutation createEmptyPlan { insert_plan_one( object: { " @@ -415,7 +415,7 @@ public Map updatePlanActivityD final Plan plan, final Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException + throws IOException, NoSuchPlanException, MerlinServiceException { final var ids = new HashMap(); //creation are done in batch as that's what the scheduler does the most @@ -441,7 +441,7 @@ public Map updatePlanActivityD ); final var activityDirectiveId = idsFromInitialPlan.get(activity.getId()); if (!activityDirectiveFromSchedulingDirective.equals(actFromInitialPlan.get())) { - throw new PlanServiceException("The scheduler should not be updating activity instances"); + throw new MerlinServiceException("The scheduler should not be updating activity instances"); //updateActivityDirective(planId, schedulerActIntoMerlinAct, activityDirectiveId, activityToGoalId.get(activity)); } ids.put(activity, activityDirectiveId); @@ -453,7 +453,7 @@ public Map updatePlanActivityD final var actsFromNewPlan = plan.getActivitiesById(); for (final var idActInInitialPlan : idsFromInitialPlan.entrySet()) { if (!actsFromNewPlan.containsKey(idActInInitialPlan.getKey())) { - throw new PlanServiceException("The scheduler should not be deleting activity instances"); + throw new MerlinServiceException("The scheduler should not be deleting activity instances"); //deleteActivityDirective(idActInInitialPlan.getValue()); } } @@ -468,7 +468,7 @@ public Map updatePlanActivityD * {@inheritDoc} */ @Override - public void ensurePlanExists(final PlanId planId) throws IOException, NoSuchPlanException, PlanServiceException { + public void ensurePlanExists(final PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException { final Supplier exceptionFactory = () -> new NoSuchPlanException(planId); final var request = "query ensurePlanExists { plan_by_pk( id: %s ) { id } }" .formatted(planId.id()); @@ -495,7 +495,9 @@ public void ensurePlanExists(final PlanId planId) throws IOException, NoSuchPlan */ //TODO: (error cleanup) more diverse exceptions for failed operations @Override - public void clearPlanActivityDirectives(final PlanId planId) throws IOException, NoSuchPlanException, PlanServiceException { + public void clearPlanActivityDirectives(final PlanId planId) throws IOException, NoSuchPlanException, + MerlinServiceException + { ensurePlanExists(planId); final var request = ( "mutation clearPlanActivities {" @@ -522,7 +524,7 @@ public Map createAllPlanActivi final Plan plan, final Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException + throws IOException, NoSuchPlanException, MerlinServiceException { return createActivityDirectives(planId, plan.getActivitiesByTime(), activityToGoalId); } @@ -532,7 +534,7 @@ public Map createActivityDirec final List orderedActivities, final Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException + throws IOException, NoSuchPlanException, MerlinServiceException { ensurePlanExists(planId); final var query = """ @@ -605,8 +607,8 @@ mutation createAllPlanActivityDirectives($activities: [activity_directive_insert } @Override - public MissionModelTypes getMissionModelTypes(final PlanId planId) - throws IOException, MissionModelServiceException + public MerlinService.MissionModelTypes getMissionModelTypes(final PlanId planId) + throws IOException, MerlinServiceException { final var request = """ query GetActivityTypesForPlan { @@ -626,11 +628,8 @@ public MissionModelTypes getMissionModelTypes(final PlanId planId) } """.formatted(planId.id()); final JsonObject response; - try { - response = postRequest(request).get(); - } catch (PlanServiceException e) { - throw new MissionModelServiceException("Failed to get mission model types for plan id %s".formatted(planId), e); - } + response = postRequest(request).get(); + final var activityTypesJsonArray = response.getJsonObject("data") .getJsonObject("plan_by_pk") @@ -643,7 +642,7 @@ public MissionModelTypes getMissionModelTypes(final PlanId planId) .getJsonObject("mission_model") .getInt("id")); - return new MissionModelTypes(activityTypes, getResourceTypes(missionModelId)); + return new MerlinService.MissionModelTypes(activityTypes, getResourceTypes(missionModelId)); } private static List parseActivityTypes(final JsonArray activityTypesJsonArray) { @@ -684,8 +683,8 @@ private static List parseActivityTypes(final JsonArray activityTyp } @Override - public MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) - throws IOException, MissionModelServiceException, NoSuchMissionModelException + public MerlinService.MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) + throws IOException, NoSuchMissionModelException, MerlinServiceException { final var request = """ query GetActivityTypesFromMissionModel{ @@ -702,11 +701,7 @@ public MissionModelTypes getMissionModelTypes(final MissionModelId missionModelI } """.formatted(missionModelId.id()); final JsonObject response; - try { - response = postRequest(request).get(); - } catch (PlanServiceException e) { - throw new MissionModelServiceException("Failed to get mission model types for model id %s".formatted(missionModelId), e); - } + response = postRequest(request).get(); final var data = response.getJsonObject("data"); if (data.get("mission_model_by_pk").getValueType().equals(JsonValue.ValueType.NULL)) throw new NoSuchMissionModelException(missionModelId); final var activityTypesJsonArray = data @@ -714,11 +709,11 @@ public MissionModelTypes getMissionModelTypes(final MissionModelId missionModelI .getJsonArray("activity_types"); final var activityTypes = parseActivityTypes(activityTypesJsonArray); - return new MissionModelTypes(activityTypes, getResourceTypes(missionModelId)); + return new MerlinService.MissionModelTypes(activityTypes, getResourceTypes(missionModelId)); } public Collection getResourceTypes(final MissionModelId missionModelId) - throws IOException, MissionModelServiceException + throws IOException, MerlinServiceException { final var request = """ query GetResourceTypes { @@ -729,11 +724,7 @@ public Collection getResourceTypes(final MissionModelId missionMod } """.formatted(missionModelId.id()); final JsonObject response; - try { - response = postRequest(request).get(); - } catch (PlanServiceException e) { - throw new MissionModelServiceException("Failed to get mission model types for model id %s".formatted(missionModelId), e); - } + response = postRequest(request).get(); final var data = response.getJsonObject("data"); final var resourceTypesJsonArray = data.getJsonArray("resourceTypes"); @@ -756,12 +747,12 @@ public Collection getResourceTypes(final MissionModelId missionMod * @return * @throws IOException * @throws MissionModelServiceException - * @throws PlanServiceException + * @throws MerlinServiceException * @throws NoSuchPlanException */ @Override public Collection getResourceTypes(final PlanId planId) - throws IOException, MissionModelServiceException, PlanServiceException, NoSuchPlanException + throws IOException, MerlinServiceException, NoSuchPlanException { final var missionModelId = this.getPlanMetadata(planId).modelId(); final var missionModelResourceTypes = getResourceTypes(new MissionModelId(missionModelId)); @@ -776,7 +767,7 @@ public Collection getResourceTypes(final PlanId planId) return allResourceTypes; } - public SimulationId getSimulationId(PlanId planId) throws PlanServiceException, IOException { + public SimulationId getSimulationId(PlanId planId) throws MerlinServiceException, IOException { final var request = """ query { simulation(where: {plan_id: {_eq: %d}}) { @@ -794,7 +785,8 @@ public SimulationId getSimulationId(PlanId planId) throws PlanServiceException, @Override public DatasetId storeSimulationResults(final PlanMetadata planMetadata, final SimulationResults results, - final Map simulationActivityDirectiveIdToMerlinActivityDirectiveId) throws PlanServiceException, IOException + final Map simulationActivityDirectiveIdToMerlinActivityDirectiveId) throws + MerlinServiceException, IOException { final var simulationId = getSimulationId(planMetadata.planId()); final var datasetIds = createSimulationDataset(simulationId, planMetadata); @@ -812,7 +804,7 @@ public DatasetId storeSimulationResults(final PlanMetadata planMetadata, } private Map getSimulatedActivities(SimulationDatasetId datasetId, Instant startSimulation) - throws PlanServiceException, IOException, InvalidJsonException + throws MerlinServiceException, IOException, InvalidJsonException { final var request = """ query{ @@ -839,7 +831,7 @@ private Map getSimulatedActivities(Simul return parseSimulatedActivities(data, startSimulation); } - private ProfileSet getProfileTypes(DatasetId datasetId) throws PlanServiceException, IOException { + private ProfileSet getProfileTypes(DatasetId datasetId) throws MerlinServiceException, IOException { final var request = """ query{ profile(where: {dataset_id: {_eq: %d}}){ @@ -854,7 +846,7 @@ private ProfileSet getProfileTypes(DatasetId datasetId) throws PlanServiceExcept return parseProfiles(data); } - private ProfileSet getProfilesWithSegments(DatasetId datasetId) throws PlanServiceException, IOException { + private ProfileSet getProfilesWithSegments(DatasetId datasetId) throws MerlinServiceException, IOException { final var request = """ query{ profile(where: {dataset_id: {_eq: %d}}){ @@ -875,7 +867,8 @@ private ProfileSet getProfilesWithSegments(DatasetId datasetId) throws PlanServi return parseProfiles(data); } - private Map getSpans(DatasetId datasetId, Instant startTime) throws PlanServiceException, IOException { + private Map getSpans(DatasetId datasetId, Instant startTime) throws + MerlinServiceException, IOException { final var request = """ query{ span(where: {duration: {_is_null: true}, dataset_id: {_eq: %d}}) { @@ -895,7 +888,7 @@ private Map getSpans(DatasetId datasetI @Override public Optional getSimulationResults(PlanMetadata planMetadata) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { final var simulationDatasetId = getSuitableSimulationResults(planMetadata); if(simulationDatasetId.isEmpty()) return Optional.empty(); @@ -934,7 +927,7 @@ public Optional getSimulationResults(PlanMetadata planMetadat } public Optional> getExternalDatasets(final PlanId planId) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { final var datasets = new ArrayList(); final var request = """ @@ -962,7 +955,7 @@ public Optional> getExternalDatasets(final PlanId planId) @Override public ExternalProfiles getExternalProfiles(final PlanId planId) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { final Map realProfiles = new HashMap<>(); final Map discreteProfiles = new HashMap<>(); @@ -1029,12 +1022,12 @@ private Map parseUnfinishedActivities(J return unfinishedActivities; } - private UnwrappedProfileSet unwrapProfiles(final ProfileSet profileSet) throws PlanServiceException { + private UnwrappedProfileSet unwrapProfiles(final ProfileSet profileSet) throws MerlinServiceException { return new UnwrappedProfileSet(unwrapProfiles(profileSet.realProfiles()), unwrapProfiles(profileSet.discreteProfiles())); } private HashMap>>> unwrapProfiles(Map>>>> profiles) - throws PlanServiceException + throws MerlinServiceException { final var unwrapped = new HashMap>>>(); for(final var profile: profiles.entrySet()) { @@ -1158,7 +1151,7 @@ private Map parseSimulatedActivities(Jso * @param planMetadata the plan metadata containing the planning horizon and plan revision * @return optionally a simulation dataset id */ - public Optional getSuitableSimulationResults(PlanMetadata planMetadata) throws PlanServiceException, IOException { + public Optional getSuitableSimulationResults(PlanMetadata planMetadata) throws MerlinServiceException, IOException { final var request = """ { @@ -1198,7 +1191,7 @@ public Optional getSuitableSimulationResults(PlanMetadata planMetada } private SimulationId createSimulation(final PlanId planId, final Map arguments) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { final var request = """ mutation { @@ -1219,7 +1212,7 @@ private SimulationId createSimulation(final PlanId planId, final Map Duration sumDurations(final List>> private HashMap postResourceProfiles(DatasetId datasetId, final Map>>>> realProfiles, final Map>>>> discreteProfiles) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { final var req = """ mutation($profiles: [profile_insert_input!]!) { @@ -1338,7 +1331,7 @@ private HashMap postResourceProfiles(DatasetId datasetId, final var id = dataReturned.asJsonObject().getInt("id"); final var nameResourceReturned = dataReturned.asJsonObject().getString("name"); if(!nameResourceReturned.equals(resource)){ - throw new PlanServiceException("Resource do not match"); + throw new MerlinServiceException("Resource do not match"); } profileRecords.put(resource, new ProfileRecord( id, @@ -1355,7 +1348,7 @@ private void postProfileSegments( final DatasetId datasetId, final Map records, final ProfileSet profileSet - ) throws PlanServiceException, IOException + ) throws MerlinServiceException, IOException { final var realProfiles = profileSet.realProfiles(); final var discreteProfiles = profileSet.discreteProfiles(); @@ -1381,7 +1374,7 @@ private void postProfileSegment( final ProfileRecord profileRecord, final List>> segments, final JsonParser dynamicsP - ) throws PlanServiceException, IOException + ) throws MerlinServiceException, IOException { final var req = """ mutation($profileSegments:[profile_segment_insert_input!]!) { @@ -1422,19 +1415,19 @@ private void postProfileSegment( final JsonObject response; try { response = postRequest(req, arguments).get(); - } catch (PlanServiceException e) { - throw new PlanServiceException(e.toString()); + } catch (MerlinServiceException e) { + throw new MerlinServiceException(e.toString()); } final var affected_rows = response.getJsonObject("data").getJsonObject("insert_profile_segment").getInt("affected_rows"); if(affected_rows!=segments.size()) { - throw new PlanServiceException("not the same size"); + throw new MerlinServiceException("not the same size"); } } private void postRealProfileSegments(final DatasetId datasetId, final ProfileRecord profileRecord, final List>> segments) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { postProfileSegment(datasetId, profileRecord, segments, realDynamicsP); } @@ -1442,14 +1435,14 @@ private void postRealProfileSegments(final DatasetId datasetId, private void postDiscreteProfileSegments(final DatasetId datasetId, final ProfileRecord profileRecord, final List>> segments) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { postProfileSegment(datasetId, profileRecord, segments, serializedValueP); } private void insertSimulationTopics( DatasetId datasetId, - final List> topics) throws PlanServiceException, IOException + final List> topics) throws MerlinServiceException, IOException { final var req = """ mutation($topics:[topic_insert_input!]!) { @@ -1477,7 +1470,7 @@ private void insertSimulationTopics( private void insertSimulationEvents( DatasetId datasetId, - Map>>> eventPoints) throws PlanServiceException, IOException + Map>>> eventPoints) throws MerlinServiceException, IOException { final var req = """ mutation($events:[event_insert_input!]!){ @@ -1532,7 +1525,7 @@ private void postActivities( final Map unfinishedActivities, final Instant simulationStart, final Map simulationActivityDirectiveIdToMerlinActivityDirectiveId - ) throws PlanServiceException, IOException + ) throws MerlinServiceException, IOException { final var simulatedActivityRecords = simulatedActivities.entrySet().stream() .collect(Collectors.toMap( @@ -1557,7 +1550,7 @@ public void updateSimulatedActivityParentsAction( final DatasetId datasetId, final Map simulatedActivities, final Map simIdToPgId -) throws PlanServiceException, IOException +) throws MerlinServiceException, IOException { final var req = """ mutation($updates:[span_updates!]!) { @@ -1596,7 +1589,7 @@ public void updateSimulatedActivityParentsAction( affected_rows = response.getJsonObject("data").getJsonObject("update_span_many").getInt("affected_rows"); } if(affected_rows != updateCounter) { - throw new PlanServiceException("not the same size"); + throw new MerlinServiceException("not the same size"); } } @@ -1631,7 +1624,7 @@ private static SpanRecord unfinishedActivityToRecord(final UnfinishedActivity ac public HashMap postSpans(final DatasetId datasetId, final Map spans, final Instant simulationStart - ) throws PlanServiceException, IOException + ) throws MerlinServiceException, IOException { final var req = """ mutation($spans:[span_insert_input!]!) { diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/PlanService.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MerlinService.java similarity index 81% rename from scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/PlanService.java rename to scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MerlinService.java index e02a9ce165..c6aea10d5f 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/PlanService.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MerlinService.java @@ -9,12 +9,15 @@ import gov.nasa.jpl.aerie.scheduler.model.SchedulingActivityDirective; import gov.nasa.jpl.aerie.scheduler.model.SchedulingActivityDirectiveId; import gov.nasa.jpl.aerie.scheduler.server.exceptions.NoSuchActivityInstanceException; +import gov.nasa.jpl.aerie.scheduler.server.exceptions.NoSuchMissionModelException; import gov.nasa.jpl.aerie.scheduler.server.exceptions.NoSuchPlanException; import gov.nasa.jpl.aerie.scheduler.server.http.InvalidJsonException; +import gov.nasa.jpl.aerie.scheduler.server.models.ActivityType; import gov.nasa.jpl.aerie.scheduler.server.models.DatasetId; import gov.nasa.jpl.aerie.scheduler.server.models.ExternalProfiles; import gov.nasa.jpl.aerie.scheduler.server.models.GoalId; import gov.nasa.jpl.aerie.scheduler.server.models.MerlinPlan; +import gov.nasa.jpl.aerie.scheduler.server.models.MissionModelId; import gov.nasa.jpl.aerie.scheduler.server.models.PlanId; import gov.nasa.jpl.aerie.scheduler.server.models.PlanMetadata; import gov.nasa.jpl.aerie.scheduler.server.models.ResourceType; @@ -26,8 +29,17 @@ import java.util.Map; import java.util.Optional; -public interface PlanService { +public interface MerlinService { + record MissionModelTypes(Collection activityTypes, Collection resourceTypes) {} + interface ReaderRole { + + MerlinService.MissionModelTypes getMissionModelTypes(final PlanId planId) + throws IOException, MerlinServiceException; + MerlinService.MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) + throws IOException, MerlinServiceException, + NoSuchMissionModelException; + /** * fetch current revision number of the target plan stored in aerie * @@ -36,7 +48,7 @@ interface ReaderRole { * @throws NoSuchPlanException when the plan container does not exist in aerie */ long getPlanRevision(final PlanId planId) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * fetch current metadata of the target plan (not the activity instance content) @@ -46,7 +58,7 @@ long getPlanRevision(final PlanId planId) * @throws NoSuchPlanException when the plan container does not exist in aerie */ PlanMetadata getPlanMetadata(final PlanId planId) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * create an in-memory snapshot of the target plan's activity contents from aerie @@ -57,7 +69,7 @@ PlanMetadata getPlanMetadata(final PlanId planId) * @throws NoSuchPlanException when the plan container does not exist in aerie */ MerlinPlan getPlanActivityDirectives(final PlanMetadata planMetadata, final Problem mission) - throws IOException, NoSuchPlanException, PlanServiceException, InvalidJsonException, InstantiationException; + throws IOException, NoSuchPlanException, MerlinServiceException, InvalidJsonException, InstantiationException; /** * confirms that the specified plan exists in the aerie database, throwing exception if not @@ -67,7 +79,7 @@ MerlinPlan getPlanActivityDirectives(final PlanMetadata planMetadata, final Prob */ //TODO: (defensive) should combine such checks into the mutations they are guarding, but not possible in graphql? void ensurePlanExists(final PlanId planId) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * Gets existing simulation results for current plan if they exist and are suitable for scheduling purposes (current revision, covers the entire planning horizon) @@ -75,28 +87,27 @@ void ensurePlanExists(final PlanId planId) * @param planMetadata the plan metadata * @return simulation results, optionally */ - Optional getSimulationResults(PlanMetadata planMetadata) throws PlanServiceException, IOException, InvalidJsonException; + Optional getSimulationResults(PlanMetadata planMetadata) throws MerlinServiceException, IOException, InvalidJsonException; /** * Gets external profiles associated to a plan, including segments * @param planId the plan id - * @throws PlanServiceException + * @throws MerlinServiceException * @throws IOException */ ExternalProfiles getExternalProfiles(final PlanId planId) - throws PlanServiceException, IOException; + throws MerlinServiceException, IOException; /** * Gets resource types associated to a plan, those coming from the mission model as well as those coming from external dataset resources * @param planId the plan id * @throws IOException - * @throws MissionModelService.MissionModelServiceException - * @throws PlanServiceException + * @throws MerlinServiceException * @throws NoSuchPlanException */ Collection getResourceTypes(final PlanId planId) - throws IOException, MissionModelService.MissionModelServiceException, PlanServiceException, NoSuchPlanException; + throws IOException, MerlinServiceException, NoSuchPlanException; } interface WriterRole { @@ -115,7 +126,7 @@ Pair> createNewPla final Plan plan, final Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * create a new empty plan container based on specifications @@ -130,7 +141,7 @@ Pair> createNewPla * @throws NoSuchPlanException when the plan container could not be found in aerie after creation */ PlanId createEmptyPlan(final String name, final long modelId, final Instant startTime, final Duration duration) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * synchronize the in-memory plan back over to aerie data stores via update operations @@ -149,7 +160,7 @@ Map updatePlanActivityDirectiv Plan plan, Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException, NoSuchActivityInstanceException; + throws IOException, NoSuchPlanException, MerlinServiceException, NoSuchActivityInstanceException; /** * delete all the activity instances stored in the target plan container @@ -160,7 +171,7 @@ Map updatePlanActivityDirectiv * @throws NoSuchPlanException when the plan container does not exist in aerie */ void clearPlanActivityDirectives(final PlanId planId) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * create activity instances in the target plan container for each activity in the input plan @@ -179,7 +190,7 @@ Map createAllPlanActivityDirec final Plan plan, final Map activityToGoalId ) - throws IOException, NoSuchPlanException, PlanServiceException; + throws IOException, NoSuchPlanException, MerlinServiceException; /** * Stores the simulation results produced during scheduling @@ -189,11 +200,12 @@ Map createAllPlanActivityDirec * @param simulationActivityDirectiveIdToMerlinActivityDirectiveId the translation between activity ids in the * local simulation and the merlin activity ids * @return - * @throws PlanServiceException + * @throws MerlinServiceException * @throws IOException */ DatasetId storeSimulationResults(final PlanMetadata planMetadata, final SimulationResults results, - final Map simulationActivityDirectiveIdToMerlinActivityDirectiveId) throws PlanServiceException, IOException; + final Map simulationActivityDirectiveIdToMerlinActivityDirectiveId) throws + MerlinServiceException, IOException; } interface OwnerRole extends ReaderRole, WriterRole {} diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MerlinServiceException.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MerlinServiceException.java new file mode 100644 index 0000000000..55f37bd35c --- /dev/null +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MerlinServiceException.java @@ -0,0 +1,7 @@ +package gov.nasa.jpl.aerie.scheduler.server.services; + +public class MerlinServiceException extends Exception { + MerlinServiceException(final String message) { + super(message); + } +} diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MissionModelService.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MissionModelService.java deleted file mode 100644 index 330067b283..0000000000 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/MissionModelService.java +++ /dev/null @@ -1,30 +0,0 @@ -package gov.nasa.jpl.aerie.scheduler.server.services; - -import gov.nasa.jpl.aerie.scheduler.server.models.ActivityType; -import gov.nasa.jpl.aerie.scheduler.server.exceptions.NoSuchMissionModelException; -import gov.nasa.jpl.aerie.scheduler.server.models.MissionModelId; -import gov.nasa.jpl.aerie.scheduler.server.models.PlanId; -import gov.nasa.jpl.aerie.scheduler.server.models.ResourceType; - -import java.io.IOException; -import java.util.Collection; - -public interface MissionModelService { - MissionModelTypes getMissionModelTypes(final PlanId planId) - throws IOException, MissionModelServiceException; - MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) - throws IOException, MissionModelServiceException, - NoSuchMissionModelException; - - class MissionModelServiceException extends Exception { - MissionModelServiceException(final String message) { - super(message); - } - - public MissionModelServiceException(final String message, final Throwable cause) { - super(message, cause); - } - } - - record MissionModelTypes(Collection activityTypes, Collection resourceTypes) {} -} diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/PlanServiceException.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/PlanServiceException.java deleted file mode 100644 index 955db8cccc..0000000000 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/PlanServiceException.java +++ /dev/null @@ -1,7 +0,0 @@ -package gov.nasa.jpl.aerie.scheduler.server.services; - -public class PlanServiceException extends Exception { - PlanServiceException(final String message) { - super(message); - } -} diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java index f27f80ed24..ab93b554a6 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java @@ -17,7 +17,7 @@ public final class TypescriptCodeGenerationService { private TypescriptCodeGenerationService() { } - public static String generateTypescriptTypesFromMissionModel(final MissionModelService.MissionModelTypes missionModelTypes) { + public static String generateTypescriptTypesFromMissionModel(final MerlinService.MissionModelTypes missionModelTypes) { final var activityTypeCodes = new ArrayList(); for (final var activityType : missionModelTypes.activityTypes()) { activityTypeCodes.add(getActivityTypeInformation(activityType)); diff --git a/scheduler-server/src/testFixtures/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTestFixtures.java b/scheduler-server/src/testFixtures/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTestFixtures.java index 50689f1136..c64557a89a 100644 --- a/scheduler-server/src/testFixtures/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTestFixtures.java +++ b/scheduler-server/src/testFixtures/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTestFixtures.java @@ -10,8 +10,8 @@ public final class TypescriptCodeGenerationServiceTestFixtures { - public static final MissionModelService.MissionModelTypes MISSION_MODEL_TYPES = - new MissionModelService.MissionModelTypes( + public static final MerlinService.MissionModelTypes MISSION_MODEL_TYPES = + new MerlinService.MissionModelTypes( List.of( new ActivityType( "SampleActivity1", diff --git a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java index 0cc7cbd3df..f1682b818b 100644 --- a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java +++ b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java @@ -63,7 +63,6 @@ public static void main(String[] args) throws Exception { final var specificationService = new LocalSpecificationService(stores.specifications()); final var scheduleAgent = new SynchronousSchedulerAgent(specificationService, - merlinService, merlinService, config.merlinFileStore(), config.missionRuleJarPath(), diff --git a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationService.java b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationService.java index db877e6ee7..3703e48db1 100644 --- a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationService.java +++ b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationService.java @@ -8,7 +8,8 @@ import gov.nasa.jpl.aerie.scheduler.server.models.SchedulingCompilationError; import gov.nasa.jpl.aerie.scheduler.server.models.SchedulingDSL; import gov.nasa.jpl.aerie.scheduler.server.services.ConstraintsTypescriptCodeGenerationHelper; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinServiceException; import gov.nasa.jpl.aerie.scheduler.server.services.TypescriptCodeGenerationService; import javax.json.Json; @@ -49,48 +50,48 @@ public void close() { this.nodeProcess.destroy(); } - public SchedulingDSLCompilationResult compileGlobalSchedulingCondition(final MissionModelService missionModelService, final PlanId planId, final String conditionTypescript, final + public SchedulingDSLCompilationResult compileGlobalSchedulingCondition(final MerlinService.ReaderRole merlinService, final PlanId planId, final String conditionTypescript, final Collection additionalResourceTypes) { try{ - final var missionModelTypes = missionModelService.getMissionModelTypes(planId); + final var missionModelTypes = merlinService.getMissionModelTypes(planId); final var aggregatedResourceTypes = new ArrayList<>(missionModelTypes.resourceTypes()); aggregatedResourceTypes.addAll(additionalResourceTypes); - final var planTypes = new MissionModelService.MissionModelTypes(missionModelTypes.activityTypes(), aggregatedResourceTypes); + final var planTypes = new MerlinService.MissionModelTypes(missionModelTypes.activityTypes(), aggregatedResourceTypes); return compile(planTypes, conditionTypescript, SchedulingDSL.conditionSpecifierP, "GlobalSchedulingCondition"); - } catch (IOException | MissionModelService.MissionModelServiceException e) { + } catch (IOException | MerlinServiceException e) { throw new Error(e); } } public SchedulingDSLCompilationResult compileSchedulingGoalDSL( - final MissionModelService missionModelService, + final MerlinService.ReaderRole merlinService, final PlanId planId, final String goalTypescript){ - return compileSchedulingGoalDSL(missionModelService, planId, goalTypescript, List.of()); + return compileSchedulingGoalDSL(merlinService, planId, goalTypescript, List.of()); } /** * NOTE: This method is not re-entrant (assumes only one call to this method is running at any given time) */ public SchedulingDSLCompilationResult compileSchedulingGoalDSL( - final MissionModelService missionModelService, + final MerlinService.ReaderRole merlinService, final PlanId planId, final String goalTypescript, final Collection additionalResourceTypes) { try { - final var missionModelTypes = missionModelService.getMissionModelTypes(planId); + final var missionModelTypes = merlinService.getMissionModelTypes(planId); final var aggregatedResourceTypes = new ArrayList<>(missionModelTypes.resourceTypes()); aggregatedResourceTypes.addAll(additionalResourceTypes); - final var augmentedMissionModelTypes = new MissionModelService.MissionModelTypes(missionModelTypes.activityTypes(), aggregatedResourceTypes); + final var augmentedMissionModelTypes = new MerlinService.MissionModelTypes(missionModelTypes.activityTypes(), aggregatedResourceTypes); return compile(augmentedMissionModelTypes, goalTypescript, SchedulingDSL.schedulingJsonP(augmentedMissionModelTypes), "Goal"); - } catch (IOException | MissionModelService.MissionModelServiceException e) { + } catch (IOException | MerlinServiceException e) { throw new Error(e); } } private SchedulingDSLCompilationResult compile( - final MissionModelService.MissionModelTypes missionModelTypes, + final MerlinService.MissionModelTypes missionModelTypes, final String goalTypescript, final JsonParser parser, final String expectedReturnType) diff --git a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SynchronousSchedulerAgent.java b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SynchronousSchedulerAgent.java index 4f69996dd7..5d055ba59f 100644 --- a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SynchronousSchedulerAgent.java +++ b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/services/SynchronousSchedulerAgent.java @@ -59,9 +59,8 @@ import gov.nasa.jpl.aerie.scheduler.server.models.SchedulingDSL; import gov.nasa.jpl.aerie.scheduler.server.models.Specification; import gov.nasa.jpl.aerie.scheduler.server.remotes.postgres.GoalBuilder; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; -import gov.nasa.jpl.aerie.scheduler.server.services.PlanService; -import gov.nasa.jpl.aerie.scheduler.server.services.PlanServiceException; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinServiceException; import gov.nasa.jpl.aerie.scheduler.server.services.RevisionData; import gov.nasa.jpl.aerie.scheduler.server.services.ScheduleRequest; import gov.nasa.jpl.aerie.scheduler.server.services.ScheduleResults; @@ -75,8 +74,7 @@ /** * agent that handles posed scheduling requests by blocking the requester thread until scheduling is complete * - * @param planService interface for querying plan details from merlin - * @param missionModelService interface for querying mission model details from merlin + * @param merlinService interface for querying plan and mission model details from merlin * @param modelJarsDir path to parent directory for mission model jars (interim backdoor jar file access) * @param goalsJarPath path to jar file to load scheduling goals from (interim solution for user input goals) * @param outputMode how the scheduling output should be returned to aerie (eg overwrite or new container) @@ -84,8 +82,7 @@ //TODO: will eventually need scheduling goal service arg to pull goals from scheduler's own data store public record SynchronousSchedulerAgent( SpecificationService specificationService, - PlanService.OwnerRole planService, - MissionModelService missionModelService, + MerlinService.OwnerRole merlinService, Path modelJarsDir, Path goalsJarPath, PlanOutputMode outputMode, @@ -94,8 +91,7 @@ public record SynchronousSchedulerAgent( implements SchedulerAgent { public SynchronousSchedulerAgent { - Objects.requireNonNull(planService); - Objects.requireNonNull(missionModelService); + Objects.requireNonNull(merlinService); Objects.requireNonNull(modelJarsDir); Objects.requireNonNull(goalsJarPath); Objects.requireNonNull(schedulingDSLCompilationService); @@ -117,7 +113,7 @@ public void schedule(final ScheduleRequest request, final ResultsProtocol.Writer //TODO: maybe some kind of high level db transaction wrapping entire read/update of target plan revision final var specification = specificationService.getSpecification(request.specificationId()); - final var planMetadata = planService.getPlanMetadata(specification.planId()); + final var planMetadata = merlinService.getPlanMetadata(specification.planId()); ensureRequestIsCurrent(request); ensurePlanRevisionMatch(specification, planMetadata.planRev()); //create scheduler problem seeded with initial plan @@ -145,7 +141,7 @@ public void schedule(final ScheduleRequest request, final ResultsProtocol.Writer specification.globalSchedulingConditions().forEach($ -> { if (!$.enabled()) return; final var result = schedulingDSLCompilationService.compileGlobalSchedulingCondition( - missionModelService, + merlinService, planMetadata.planId(), $.source().source(), externalProfiles.resourceTypes()); @@ -179,7 +175,7 @@ public void schedule(final ScheduleRequest request, final ResultsProtocol.Writer for (final var goalRecord : specification.goalsByPriority()) { if (!goalRecord.enabled()) continue; final var result = compileGoalDefinition( - missionModelService, + merlinService, planMetadata.planId(), goalRecord.definition(), schedulingDSLCompilationService, @@ -235,7 +231,7 @@ public void schedule(final ScheduleRequest request, final ResultsProtocol.Writer solutionPlan, activityToGoalId ); - final var planMetadataAfterChanges = planService.getPlanMetadata(specification.planId()); + final var planMetadataAfterChanges = merlinService.getPlanMetadata(specification.planId()); final var datasetId = storeSimulationResults(planningHorizon, simulationFacade, planMetadataAfterChanges, instancesToIds); //collect results and notify subscribers of success final var results = collectResults(solutionPlan, instancesToIds, goals); @@ -264,7 +260,7 @@ public void schedule(final ScheduleRequest request, final ResultsProtocol.Writer .message(e.toString()) .data(ResponseSerializers.serializeNoSuchPlanException(e)) .trace(e)); - } catch (final PlanServiceException e) { + } catch (final MerlinServiceException e) { writer.failWith(b -> b .type("PLAN_SERVICE_EXCEPTION") .message(e.toString()) @@ -279,21 +275,21 @@ public void schedule(final ScheduleRequest request, final ResultsProtocol.Writer private Optional loadSimulationResults(final PlanMetadata planMetadata){ try { - return planService.getSimulationResults(planMetadata); - } catch (PlanServiceException | IOException | InvalidJsonException e) { + return merlinService.getSimulationResults(planMetadata); + } catch (MerlinServiceException | IOException | InvalidJsonException e) { throw new ResultsProtocolFailure(e); } } private ExternalProfiles loadExternalProfiles(final PlanId planId) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { - return planService.getExternalProfiles(planId); + return merlinService.getExternalProfiles(planId); } private Optional storeSimulationResults(PlanningHorizon planningHorizon, SimulationFacade simulationFacade, PlanMetadata planMetadata, final Map schedDirectiveToMerlinId) - throws PlanServiceException, IOException + throws MerlinServiceException, IOException { //finish simulation until end of horizon before posting results try { @@ -312,9 +308,9 @@ private Optional storeSimulationResults(PlanningHorizon planningHoriz Map.Entry::getValue, (a) -> schedID_to_MerlinID.get(a.getKey()))); if(simID_to_MerlinID.values().containsAll(schedDirectiveToMerlinId.values()) && schedDirectiveToMerlinId.values().containsAll(simID_to_MerlinID.values())){ - return Optional.of(planService.storeSimulationResults(planMetadata, - simulationFacade.getLatestDriverSimulationResults(), - simID_to_MerlinID)); + return Optional.of(merlinService.storeSimulationResults(planMetadata, + simulationFacade.getLatestDriverSimulationResults(), + simID_to_MerlinID)); } else{ //schedule in simulation is inconsistent with current state of the plan (user probably disabled simulation for some of the goals) return Optional.empty(); @@ -322,14 +318,14 @@ private Optional storeSimulationResults(PlanningHorizon planningHoriz } private static SchedulingDSLCompilationService.SchedulingDSLCompilationResult compileGoalDefinition( - final MissionModelService missionModelService, + final MerlinService.ReaderRole merlinService, final PlanId planId, final GoalSource goalDefinition, final SchedulingDSLCompilationService schedulingDSLCompilationService, final Collection additionalResourceTypes) { return schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, planId, goalDefinition.source(), additionalResourceTypes @@ -350,9 +346,9 @@ private void ensurePlanRevisionMatch(final Specification specification, final lo * @throws ResultsProtocolFailure when the requested plan cannot be found, or aerie could not be reached */ private long getMerlinPlanRev(final PlanId planId) - throws PlanServiceException, NoSuchPlanException, IOException + throws MerlinServiceException, NoSuchPlanException, IOException { - return planService.getPlanRevision(planId); + return merlinService.getPlanRevision(planId); } /** * confirms that specification revision still matches that expected by the scheduling request @@ -411,7 +407,7 @@ private Solver createScheduler(final PlanMetadata planMetadata, final Problem pr private PlanComponents loadInitialPlan(final PlanMetadata planMetadata, final Problem problem) { //TODO: maybe paranoid check if plan rev has changed since original metadata? try { - final var merlinPlan = planService.getPlanActivityDirectives(planMetadata, problem); + final var merlinPlan = merlinService.getPlanActivityDirectives(planMetadata, problem); final Map schedulingIdToDirectiveId = new HashMap<>(); final var plan = new PlanInMemory(); final var activityTypes = problem.getActivityTypes().stream().collect(Collectors.toMap(ActivityType::getName, at -> at)); @@ -574,10 +570,10 @@ private Map storeFinalPlan( try { switch (this.outputMode) { case CreateNewOutputPlan -> { - return planService.createNewPlanWithActivityDirectives(planMetadata, newPlan, goalToActivity).getValue(); + return merlinService.createNewPlanWithActivityDirectives(planMetadata, newPlan, goalToActivity).getValue(); } case UpdateInputPlanWithNewActivities -> { - return planService.updatePlanActivityDirectives( + return merlinService.updatePlanActivityDirectives( planMetadata.planId(), idsFromInitialPlan, initialPlan, diff --git a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/MockMerlinService.java b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/MockMerlinService.java index fd779c2ae9..bd5b005f66 100644 --- a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/MockMerlinService.java +++ b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/MockMerlinService.java @@ -20,8 +20,7 @@ import gov.nasa.jpl.aerie.scheduler.server.models.PlanId; import gov.nasa.jpl.aerie.scheduler.server.models.PlanMetadata; import gov.nasa.jpl.aerie.scheduler.server.models.ResourceType; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; -import gov.nasa.jpl.aerie.scheduler.server.services.PlanService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; import org.apache.commons.lang3.tuple.Pair; import java.nio.file.Path; @@ -33,7 +32,7 @@ import java.util.Map; import java.util.Optional; -class MockMerlinService implements MissionModelService, PlanService.OwnerRole { +class MockMerlinService implements MerlinService.OwnerRole { private Optional planningHorizon; private ExternalProfiles externalProfiles = new ExternalProfiles(Map.of(), Map.of(), List.of()); @@ -42,7 +41,7 @@ public void setExternalDataset(ExternalProfiles externalProfiles) { this.externalProfiles = externalProfiles; } - record MissionModelInfo(Path libPath, Path modelPath, String modelName, MissionModelTypes types, Map config) {} + record MissionModelInfo(Path libPath, Path modelPath, String modelName, MerlinService.MissionModelTypes types, Map config) {} private Optional missionModelInfo = Optional.empty(); private MerlinPlan initialPlan; @@ -185,14 +184,14 @@ public DatasetId storeSimulationResults( } @Override - public MissionModelTypes getMissionModelTypes(final PlanId planId) + public MerlinService.MissionModelTypes getMissionModelTypes(final PlanId planId) { if (this.missionModelInfo.isEmpty()) throw new RuntimeException("Make sure to call setMissionModel before running a test"); return this.missionModelInfo.get().types(); } @Override - public MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) + public MerlinService.MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) { if (this.missionModelInfo.isEmpty()) throw new RuntimeException("Make sure to call setMissionModel before running a test"); return this.missionModelInfo.get().types(); diff --git a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationServiceTests.java b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationServiceTests.java index 99a8f6c724..3333ba940e 100644 --- a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationServiceTests.java +++ b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingDSLCompilationServiceTests.java @@ -22,20 +22,31 @@ import gov.nasa.jpl.aerie.constraints.tree.StructExpressionAt; import gov.nasa.jpl.aerie.constraints.tree.ValueAt; import gov.nasa.jpl.aerie.constraints.tree.WindowsFromSpans; +import gov.nasa.jpl.aerie.merlin.driver.SimulationResults; import gov.nasa.jpl.aerie.merlin.protocol.types.Duration; +import gov.nasa.jpl.aerie.merlin.protocol.types.InstantiationException; import gov.nasa.jpl.aerie.merlin.protocol.types.SerializedValue; import gov.nasa.jpl.aerie.scheduler.TimeUtility; import gov.nasa.jpl.aerie.scheduler.constraints.timeexpressions.TimeAnchor; +import gov.nasa.jpl.aerie.scheduler.model.Problem; +import gov.nasa.jpl.aerie.scheduler.server.exceptions.NoSuchPlanException; +import gov.nasa.jpl.aerie.scheduler.server.http.InvalidJsonException; +import gov.nasa.jpl.aerie.scheduler.server.models.ExternalProfiles; +import gov.nasa.jpl.aerie.scheduler.server.models.MerlinPlan; import gov.nasa.jpl.aerie.scheduler.server.models.MissionModelId; import gov.nasa.jpl.aerie.scheduler.server.models.PlanId; +import gov.nasa.jpl.aerie.scheduler.server.models.PlanMetadata; +import gov.nasa.jpl.aerie.scheduler.server.models.ResourceType; import gov.nasa.jpl.aerie.scheduler.server.models.SchedulingDSL; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinServiceException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import java.io.IOException; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; @@ -51,18 +62,61 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class SchedulingDSLCompilationServiceTests { private static final PlanId PLAN_ID = new PlanId(1L); - private static final MissionModelService missionModelService = new MissionModelService() { + private static final MerlinService.ReaderRole merlinService = new MerlinService.ReaderRole() { @Override - public MissionModelTypes getMissionModelTypes(final PlanId missionModelId) + public MerlinService.MissionModelTypes getMissionModelTypes(final PlanId missionModelId) { return MISSION_MODEL_TYPES; } @Override - public MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) + public MerlinService.MissionModelTypes getMissionModelTypes(final MissionModelId missionModelId) { return MISSION_MODEL_TYPES; } + + @Override + public long getPlanRevision(final PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException { + return 0; + } + + @Override + public PlanMetadata getPlanMetadata(final PlanId planId) + throws IOException, NoSuchPlanException, MerlinServiceException + { + return null; + } + + @Override + public MerlinPlan getPlanActivityDirectives(final PlanMetadata planMetadata, final Problem mission) + throws IOException, NoSuchPlanException, MerlinServiceException, InvalidJsonException, InstantiationException + { + return null; + } + + @Override + public void ensurePlanExists(final PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException { + + } + + @Override + public Optional getSimulationResults(final PlanMetadata planMetadata) + throws MerlinServiceException, IOException, InvalidJsonException + { + return Optional.empty(); + } + + @Override + public ExternalProfiles getExternalProfiles(final PlanId planId) throws MerlinServiceException, IOException { + return null; + } + + @Override + public Collection getResourceTypes(final PlanId planId) + throws IOException, MerlinServiceException, NoSuchPlanException + { + return null; + } }; SchedulingDSLCompilationService schedulingDSLCompilationService; @@ -80,7 +134,7 @@ void tearDown() { void testSchedulingDSL_mutex() { final var result = schedulingDSLCompilationService.compileGlobalSchedulingCondition( - missionModelService, + merlinService, PLAN_ID, """ export default function myCondition() { return GlobalSchedulingCondition.mutex([ActivityTypes.SampleActivity2], [ActivityTypes.SampleActivity1]) @@ -165,7 +219,7 @@ private static StructExpressionAt getSampleActivity3PresetParameters() { void testSchedulingDSL_basic() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -197,7 +251,7 @@ export default function myGoal() { void testSchedulingDSL_recurrence_activityFinder() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -232,7 +286,7 @@ export default function myGoal() { void testSchedulingDSL_partial() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -264,7 +318,7 @@ export default function myGoal() { void testSchedulingDSL_helper_function() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return myHelper(ActivityTemplates.SampleActivity1({ @@ -299,7 +353,7 @@ function myHelper(activityTemplate) { void testSchedulingDSL_variable_not_defined() { final SchedulingDSLCompilationService.SchedulingDSLCompilationResult.Error actualErrors; actualErrors = (SchedulingDSLCompilationService.SchedulingDSLCompilationResult.Error) schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { const x = 4 - 2 @@ -327,7 +381,7 @@ function myHelper(activityTemplate) { void testSchedulingDSL_applyWhen() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -366,7 +420,7 @@ export default function myGoal() { void testSchedulingDSL_wrong_return_type() { final SchedulingDSLCompilationService.SchedulingDSLCompilationResult.Error actualErrors; actualErrors = (SchedulingDSLCompilationService.SchedulingDSLCompilationResult.Error) schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return 5 @@ -383,7 +437,7 @@ export default function myGoal() { void testSchedulingDSL_temporal() { final SchedulingDSLCompilationService.SchedulingDSLCompilationResult result; result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default () => Goal.ActivityRecurrenceGoal({ @@ -416,7 +470,7 @@ export default () => Goal.ActivityRecurrenceGoal({ void testHugeGoal() { // This test is intended to create a Goal that is bigger than the node subprocess's standard input buffer final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -448,7 +502,7 @@ export default function myGoal() { @Test void testCoexistenceGoalActivityExpression() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function() { return Goal.CoexistenceGoal({ @@ -486,7 +540,7 @@ export default function() { @Test void testCoexistenceGoalFlexibleTimingConstraint() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function() { return Goal.CoexistenceGoal({ @@ -530,7 +584,7 @@ export default function() { @Test void testCoexistenceGoalActivityFinder() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function() { return Goal.CoexistenceGoal({ @@ -571,7 +625,7 @@ export default function() { @Test void testCoexistenceGoalParameterReference() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function() { return Goal.CoexistenceGoal({ @@ -618,7 +672,7 @@ export default function() { @Test void testCoexistenceGoalParameterReferenceValueAt() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function() { return Goal.CoexistenceGoal({ @@ -665,7 +719,7 @@ export default function() { @Test void strictTypeCheckingTest_astNode() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ interface FakeGoal { @@ -698,7 +752,7 @@ export default function() { @Test void strictTypeCheckingTest_transition() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function() { @@ -727,7 +781,7 @@ export default function() { void testSchedulingDSL_emptyActivityCorrect() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -756,7 +810,7 @@ export default function myGoal() { void testSchedulingDSL_emptyActivityBogus() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -780,7 +834,7 @@ else if (result instanceof SchedulingDSLCompilationService.SchedulingDSLCompilat @Test void testCoexistenceGoalStateConstraint() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ const micro = (m: number) => Temporal.Duration.from({microseconds: m}); @@ -820,7 +874,7 @@ export default function() { @Test void testCoexistenceGoalReferenceWindowDuration() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ const micro = (m: number) => Temporal.Duration.from({microseconds: m}); @@ -860,7 +914,7 @@ export default function() { @Test void testWindowsExpression() { final var result = schedulingDSLCompilationService.compileGlobalSchedulingCondition( - missionModelService, + merlinService, PLAN_ID, """ export default function() { @@ -884,7 +938,7 @@ export default function() { @Test void testAndGoal(){ final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -929,7 +983,7 @@ export default function myGoal() { @Test void testOrGoal(){ final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default function myGoal() { return Goal.ActivityRecurrenceGoal({ @@ -974,7 +1028,7 @@ export default function myGoal() { @Test void testActivityPreset() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default (): Goal => { return Goal.ActivityRecurrenceGoal({ @@ -1002,7 +1056,7 @@ export default (): Goal => { void testSchedulingDSLMutatingPreset() { final var result1 = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default (): Goal => { let preset = ActivityPresets.SampleActivity2["my preset"]; @@ -1028,7 +1082,7 @@ export default (): Goal => { } final var result2 = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default (): Goal => { let preset = { @@ -1061,7 +1115,7 @@ export default (): Goal => { @Test void testPresetWithEnum() { final var result = schedulingDSLCompilationService.compileSchedulingGoalDSL( - missionModelService, + merlinService, PLAN_ID, """ export default (): Goal => { return Goal.ActivityRecurrenceGoal({ diff --git a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java index e2a386eaca..825388ea1f 100644 --- a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java +++ b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java @@ -22,14 +22,11 @@ import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.MINUTE; import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.MINUTES; import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.SECOND; -import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.ZERO; import static org.junit.jupiter.api.Assertions.*; import gov.nasa.jpl.aerie.constraints.model.DiscreteProfile; import gov.nasa.jpl.aerie.constraints.time.Interval; import gov.nasa.jpl.aerie.constraints.time.Segment; -import gov.nasa.jpl.aerie.constraints.tree.DiscreteResource; -import gov.nasa.jpl.aerie.foomissionmodel.mappers.FooValueMappers; import gov.nasa.jpl.aerie.merlin.driver.ActivityDirective; import gov.nasa.jpl.aerie.merlin.driver.ActivityDirectiveId; import gov.nasa.jpl.aerie.merlin.driver.MissionModelLoader; @@ -40,7 +37,6 @@ import gov.nasa.jpl.aerie.merlin.protocol.types.SerializedValue; import gov.nasa.jpl.aerie.merlin.protocol.types.ValueSchema; import gov.nasa.jpl.aerie.scheduler.TimeUtility; -import gov.nasa.jpl.aerie.scheduler.model.ActivityType; import gov.nasa.jpl.aerie.scheduler.model.PlanningHorizon; import gov.nasa.jpl.aerie.scheduler.server.config.PlanOutputMode; import gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers; @@ -55,7 +51,7 @@ import gov.nasa.jpl.aerie.scheduler.server.models.Specification; import gov.nasa.jpl.aerie.scheduler.server.models.SpecificationId; import gov.nasa.jpl.aerie.scheduler.server.models.Timestamp; -import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService; +import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService; import gov.nasa.jpl.aerie.scheduler.server.services.RevisionData; import gov.nasa.jpl.aerie.scheduler.server.services.ScheduleRequest; import gov.nasa.jpl.aerie.scheduler.server.services.ScheduleResults; @@ -2027,7 +2023,6 @@ private SchedulingRunResults runScheduler( final var agent = new SynchronousSchedulerAgent( specificationService, mockMerlinService, - mockMerlinService, desc.libPath(), Path.of(""), PlanOutputMode.UpdateInputPlanWithNewActivities, @@ -2047,7 +2042,7 @@ private SchedulingRunResults runScheduler( record SchedulingRunResults(ScheduleResults scheduleResults, Collection updatedPlan, Plan plan, Map idToAct) {} - static MissionModelService.MissionModelTypes loadMissionModelTypesFromJar( + static MerlinService.MissionModelTypes loadMissionModelTypesFromJar( final String jarPath, final Map configuration) throws MissionModelLoader.MissionModelLoadException @@ -2081,7 +2076,7 @@ static MissionModelService.MissionModelTypes loadMissionModelTypesFromJar( resourceTypes.add(new ResourceType(name, resource.getOutputType().getSchema())); } - return new MissionModelService.MissionModelTypes(activityTypes, resourceTypes); + return new MerlinService.MissionModelTypes(activityTypes, resourceTypes); } @Test