Record Class GraphQLMerlinDatabaseService
java.lang.Object
java.lang.Record
gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService
- Record Components:
merlinGraphqlURI- endpoint of the merlin graphql service that should be used to access all plan data
- All Implemented Interfaces:
MerlinDatabaseService.OwnerRole,MerlinDatabaseService.ReaderRole,MerlinDatabaseService.WriterRole
public record GraphQLMerlinDatabaseService(URI merlinGraphqlURI, String hasuraGraphQlAdminSecret)
extends Record
implements MerlinDatabaseService.OwnerRole
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordstatic final record -
Constructor Summary
ConstructorsConstructorDescriptionGraphQLMerlinDatabaseService(URI merlinGraphqlURI, String hasuraGraphQlAdminSecret) Creates an instance of aGraphQLMerlinDatabaseServicerecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearPlanActivityDirectives(PlanId planId) delete all the activity instances stored in the target plan container the plan revision will change!Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.types.ActivityDirectiveId> createAllPlanActivityDirectives(PlanId planId, gov.nasa.jpl.aerie.scheduler.model.Plan plan, Map<gov.nasa.jpl.aerie.scheduler.model.SchedulingActivity, gov.nasa.jpl.aerie.scheduler.model.GoalId> activityToGoalId, gov.nasa.jpl.aerie.merlin.protocol.model.SchedulerModel schedulerModel) create activity instances in the target plan container for each activity in the input plan does not attempt to resolve id clashes or do activity instance updates the plan revision will change!createEmptyPlan(String name, long modelId, Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration duration) create a new empty plan container based on specifications does not attach a scheduling specification to the plan!org.apache.commons.lang3.tuple.Pair<PlanId, Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.types.ActivityDirectiveId>> createNewPlanWithActivityDirectives(PlanMetadata planMetadata, gov.nasa.jpl.aerie.scheduler.model.Plan plan, Map<gov.nasa.jpl.aerie.scheduler.model.SchedulingActivity, gov.nasa.jpl.aerie.scheduler.model.GoalId> activityToGoalId, gov.nasa.jpl.aerie.merlin.protocol.model.SchedulerModel schedulerModel) create an entirely new plan container in aerie and synchronize the in-memory plan to it does not mutate the original plan, so metadata remains valid for the original planvoidensurePlanExists(PlanId planId) confirms that the specified plan exists in the aerie database, throwing exception if notfinal booleanIndicates whether some other object is "equal to" this one.Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.scheduler.model.GoalId> getActivityIdToGoalIdMap(PlanId planId) getExternalDatasets(PlanId planId) getExternalEvents(PlanId planId, Instant horizonStart) getExternalProfiles(PlanId planId) Gets external profiles associated to a plan, including segmentsgetMissionModelTypes(PlanId planId) getMissionModelTypes(gov.nasa.jpl.aerie.types.MissionModelId missionModelId) generate a name for the next created plan container using current timestamp currently, does not actually verify that the name is unique within aerie databasegetPlanActivityDirectives(PlanMetadata planMetadata, gov.nasa.jpl.aerie.scheduler.model.Problem problem) create an in-memory snapshot of the target plan's activity contents from aeriegetPlanMetadata(PlanId planId) fetch current metadata of the target plan (not the activity instance content)longgetPlanRevision(PlanId planId) fetch current revision number of the target plan stored in aeriegetResourceTypes(PlanId planId) Gets resource types associated to a plan, those coming from the mission model as well as those coming from external dataset resourcesgetResourceTypes(gov.nasa.jpl.aerie.types.MissionModelId missionModelId) gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService.SimulationIdgetSimulationId(PlanId planId) Optional<org.apache.commons.lang3.tuple.Pair<gov.nasa.jpl.aerie.merlin.driver.SimulationResults, DatasetId>> getSimulationResults(PlanMetadata planMetadata) Gets existing simulation results for current plan if they exist and are suitable for scheduling purposes (current revision, covers the entire planning horizon) These simulation results do not include events and topics.getSuitableSimulationResults(PlanMetadata planMetadata) Returns the simulation dataset id if the simulation - covers the entire planning horizon - corresponds to the plan revisionfinal inthashCode()Returns a hash code value for this object.Returns the value of thehasuraGraphQlAdminSecretrecord component.Returns the value of themerlinGraphqlURIrecord component.protected Optional<javax.json.JsonObject> postRequest(String query, javax.json.JsonObject variables) voidpostSpans(DatasetId datasetId, Map<gov.nasa.jpl.aerie.types.ActivityInstanceId, gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService.SpanRecord> spans, Instant simulationStart, Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.types.ActivityDirectiveId> uploadIdMap) serialize the given string in a manner that can be used as a graphql argument valuestoreSimulationResults(PlanMetadata planMetadata, gov.nasa.jpl.aerie.merlin.driver.SimulationResults results, Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.types.ActivityDirectiveId> uploadIdMap) Stores the simulation results produced during schedulingfinal StringtoString()Returns a string representation of this record class.Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.types.ActivityDirectiveId> updatePlanActivityDirectives(PlanId planId, MerlinPlan initialPlan, gov.nasa.jpl.aerie.scheduler.model.Plan plan, Map<gov.nasa.jpl.aerie.scheduler.model.SchedulingActivity, gov.nasa.jpl.aerie.scheduler.model.GoalId> activityToGoalId, gov.nasa.jpl.aerie.merlin.protocol.model.SchedulerModel schedulerModel) synchronize the in-memory plan back over to aerie data stores via update operations the plan revision will change!voidupdateSimulatedActivityParentsAction(DatasetId datasetId, Map<gov.nasa.jpl.aerie.types.ActivityInstanceId, gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService.SpanRecord> simulatedActivities)
-
Constructor Details
-
GraphQLMerlinDatabaseService
Creates an instance of aGraphQLMerlinDatabaseServicerecord class.- Parameters:
merlinGraphqlURI- the value for themerlinGraphqlURIrecord componenthasuraGraphQlAdminSecret- the value for thehasuraGraphQlAdminSecretrecord component
-
-
Method Details
-
postRequest
protected Optional<javax.json.JsonObject> postRequest(String query, javax.json.JsonObject variables) throws IOException, MerlinServiceException - Throws:
IOExceptionMerlinServiceException
-
getPlanRevision
public long getPlanRevision(PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException fetch current revision number of the target plan stored in aerie- Specified by:
getPlanRevisionin interfaceMerlinDatabaseService.ReaderRole- Parameters:
planId- identifier of the plan container whose details should be fetched- Returns:
- the current revision number of the plan as stored in aerie
- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceException
-
getPlanMetadata
public PlanMetadata getPlanMetadata(PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException fetch current metadata of the target plan (not the activity instance content) retrieves the metadata via a single atomic graphql query- Specified by:
getPlanMetadatain interfaceMerlinDatabaseService.ReaderRole- Parameters:
planId- identifier of the plan container whose details should be fetched- Returns:
- metadata about the plan that is useful to the scheduler, including current plan revision
- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceException
-
getPlanActivityDirectives
public MerlinPlan getPlanActivityDirectives(PlanMetadata planMetadata, gov.nasa.jpl.aerie.scheduler.model.Problem problem) throws IOException, NoSuchPlanException, MerlinServiceException, InvalidJsonException, gov.nasa.jpl.aerie.merlin.protocol.types.InstantiationException create an in-memory snapshot of the target plan's activity contents from aerie- Specified by:
getPlanActivityDirectivesin interfaceMerlinDatabaseService.ReaderRole- Parameters:
planMetadata- identifying details of the plan to fetch content forproblem- the mission model that the plan adheres to- Returns:
- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceExceptionInvalidJsonExceptiongov.nasa.jpl.aerie.merlin.protocol.types.InstantiationException
-
getNextPlanName
generate a name for the next created plan container using current timestamp currently, does not actually verify that the name is unique within aerie database- Returns:
- a name for the next created plan container
-
createNewPlanWithActivityDirectives
public org.apache.commons.lang3.tuple.Pair<PlanId,Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, createNewPlanWithActivityDirectivesgov.nasa.jpl.aerie.types.ActivityDirectiveId>> (PlanMetadata planMetadata, gov.nasa.jpl.aerie.scheduler.model.Plan plan, Map<gov.nasa.jpl.aerie.scheduler.model.SchedulingActivity, gov.nasa.jpl.aerie.scheduler.model.GoalId> activityToGoalId, gov.nasa.jpl.aerie.merlin.protocol.model.SchedulerModel schedulerModel) throws IOException, NoSuchPlanException, MerlinServiceExceptioncreate an entirely new plan container in aerie and synchronize the in-memory plan to it does not mutate the original plan, so metadata remains valid for the original plan- Specified by:
createNewPlanWithActivityDirectivesin interfaceMerlinDatabaseService.WriterRole- Parameters:
planMetadata- identifying details of a plan to emulate in creating new container. id is ignored.plan- plan with all activity instances that should be stored to target merlin plan container- Returns:
- Throws:
NoSuchPlanException- when the plan container could not be found in aerie after creationIOExceptionMerlinServiceException
-
createEmptyPlan
public PlanId createEmptyPlan(String name, long modelId, Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration duration) throws IOException, NoSuchPlanException, MerlinServiceException create a new empty plan container based on specifications does not attach a scheduling specification to the plan!- Specified by:
createEmptyPlanin interfaceMerlinDatabaseService.WriterRole- Parameters:
name- the human legible label for the new plan container to createmodelId- the database identifier of the mission model to associate with the planstartTime- the absolute start time of the new plan containerduration- the duration of the new plan container- Returns:
- the database id of the newly created aerie plan container
- Throws:
NoSuchPlanException- when the plan container could not be found in aerie after creationIOExceptionMerlinServiceException
-
updatePlanActivityDirectives
public Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId,gov.nasa.jpl.aerie.types.ActivityDirectiveId> updatePlanActivityDirectives(PlanId planId, MerlinPlan initialPlan, gov.nasa.jpl.aerie.scheduler.model.Plan plan, Map<gov.nasa.jpl.aerie.scheduler.model.SchedulingActivity, gov.nasa.jpl.aerie.scheduler.model.GoalId> activityToGoalId, gov.nasa.jpl.aerie.merlin.protocol.model.SchedulerModel schedulerModel) throws IOException, NoSuchPlanException, MerlinServiceExceptionsynchronize the in-memory plan back over to aerie data stores via update operations the plan revision will change!- Specified by:
updatePlanActivityDirectivesin interfaceMerlinDatabaseService.WriterRole- Parameters:
planId- aerie database identifier of the target plan to synchronize intoplan- plan with all activity instances that should be stored to target merlin plan container- Returns:
- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceException
-
ensurePlanExists
public void ensurePlanExists(PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException confirms that the specified plan exists in the aerie database, throwing exception if not- Specified by:
ensurePlanExistsin interfaceMerlinDatabaseService.ReaderRole- Parameters:
planId- the target plan database identifier- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceException
-
clearPlanActivityDirectives
public void clearPlanActivityDirectives(PlanId planId) throws IOException, NoSuchPlanException, MerlinServiceException delete all the activity instances stored in the target plan container the plan revision will change!- Specified by:
clearPlanActivityDirectivesin interfaceMerlinDatabaseService.WriterRole- Parameters:
planId- the database id of the plan container to clear- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceException
-
createAllPlanActivityDirectives
public Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId,gov.nasa.jpl.aerie.types.ActivityDirectiveId> createAllPlanActivityDirectives(PlanId planId, gov.nasa.jpl.aerie.scheduler.model.Plan plan, Map<gov.nasa.jpl.aerie.scheduler.model.SchedulingActivity, gov.nasa.jpl.aerie.scheduler.model.GoalId> activityToGoalId, gov.nasa.jpl.aerie.merlin.protocol.model.SchedulerModel schedulerModel) throws IOException, NoSuchPlanException, MerlinServiceExceptioncreate activity instances in the target plan container for each activity in the input plan does not attempt to resolve id clashes or do activity instance updates the plan revision will change!- Specified by:
createAllPlanActivityDirectivesin interfaceMerlinDatabaseService.WriterRole- Parameters:
planId- the database id of the plan container to populate with new activity instancesplan- the plan from which to copy all activity instances into aerie- Returns:
- Throws:
NoSuchPlanException- when the plan container does not exist in aerieIOExceptionMerlinServiceException
-
getMissionModelTypes
public MerlinDatabaseService.MissionModelTypes getMissionModelTypes(PlanId planId) throws IOException, MerlinServiceException - Specified by:
getMissionModelTypesin interfaceMerlinDatabaseService.ReaderRole- Throws:
IOExceptionMerlinServiceException
-
getMissionModelTypes
public MerlinDatabaseService.MissionModelTypes getMissionModelTypes(gov.nasa.jpl.aerie.types.MissionModelId missionModelId) throws IOException, NoSuchMissionModelException, MerlinServiceException - Specified by:
getMissionModelTypesin interfaceMerlinDatabaseService.ReaderRole- Throws:
IOExceptionNoSuchMissionModelExceptionMerlinServiceException
-
getResourceTypes
public Collection<ResourceType> getResourceTypes(gov.nasa.jpl.aerie.types.MissionModelId missionModelId) throws IOException, MerlinServiceException - Throws:
IOExceptionMerlinServiceException
-
getResourceTypes
public Collection<ResourceType> getResourceTypes(PlanId planId) throws IOException, MerlinServiceException, NoSuchPlanException Gets resource types associated to a plan, those coming from the mission model as well as those coming from external dataset resources- Specified by:
getResourceTypesin interfaceMerlinDatabaseService.ReaderRole- Parameters:
planId- the plan id- Returns:
- Throws:
IOExceptionMerlinServiceExceptionNoSuchPlanException
-
getActivityIdToGoalIdMap
public Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId,gov.nasa.jpl.aerie.scheduler.model.GoalId> getActivityIdToGoalIdMap(PlanId planId) throws MerlinServiceException, IOException - Specified by:
getActivityIdToGoalIdMapin interfaceMerlinDatabaseService.ReaderRole- Throws:
MerlinServiceExceptionIOException
-
getSimulationId
public gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService.SimulationId getSimulationId(PlanId planId) throws MerlinServiceException, IOException - Throws:
MerlinServiceExceptionIOException
-
storeSimulationResults
public DatasetId storeSimulationResults(PlanMetadata planMetadata, gov.nasa.jpl.aerie.merlin.driver.SimulationResults results, Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, gov.nasa.jpl.aerie.types.ActivityDirectiveId> uploadIdMap) throws MerlinServiceException, IOExceptionDescription copied from interface:MerlinDatabaseService.WriterRoleStores the simulation results produced during scheduling- Specified by:
storeSimulationResultsin interfaceMerlinDatabaseService.WriterRole- Parameters:
planMetadata- the plan metadataresults- the simulation results- Throws:
MerlinServiceExceptionIOException
-
getSimulationResults
public Optional<org.apache.commons.lang3.tuple.Pair<gov.nasa.jpl.aerie.merlin.driver.SimulationResults,DatasetId>> getSimulationResults(PlanMetadata planMetadata) throws MerlinServiceException, IOException Description copied from interface:MerlinDatabaseService.ReaderRoleGets existing simulation results for current plan if they exist and are suitable for scheduling purposes (current revision, covers the entire planning horizon) These simulation results do not include events and topics.- Specified by:
getSimulationResultsin interfaceMerlinDatabaseService.ReaderRole- Parameters:
planMetadata- the plan metadata- Returns:
- optionally: simulation results and its dataset id
- Throws:
MerlinServiceExceptionIOException
-
getExternalDatasets
public Optional<List<GraphQLMerlinDatabaseService.DatasetMetadata>> getExternalDatasets(PlanId planId) throws MerlinServiceException, IOException - Throws:
MerlinServiceExceptionIOException
-
getExternalProfiles
public ExternalProfiles getExternalProfiles(PlanId planId) throws MerlinServiceException, IOException Description copied from interface:MerlinDatabaseService.ReaderRoleGets external profiles associated to a plan, including segments- Specified by:
getExternalProfilesin interfaceMerlinDatabaseService.ReaderRole- Parameters:
planId- the plan id- Throws:
MerlinServiceExceptionIOException
-
getExternalEvents
public Map<String,List<gov.nasa.ammos.aerie.procedural.timeline.payloads.ExternalEvent>> getExternalEvents(PlanId planId, Instant horizonStart) throws MerlinServiceException, IOException, InvalidEntityException - Specified by:
getExternalEventsin interfaceMerlinDatabaseService.ReaderRole- Throws:
MerlinServiceExceptionIOExceptionInvalidEntityException
-
getSuitableSimulationResults
public Optional<GraphQLMerlinDatabaseService.DatasetIds> getSuitableSimulationResults(PlanMetadata planMetadata) throws MerlinServiceException, IOException Returns the simulation dataset id if the simulation - covers the entire planning horizon - corresponds to the plan revision- Parameters:
planMetadata- the plan metadata containing the planning horizon and plan revision- Returns:
- optionally a simulation dataset id
- Throws:
MerlinServiceExceptionIOException
-
updateSimulatedActivityParentsAction
public void updateSimulatedActivityParentsAction(DatasetId datasetId, Map<gov.nasa.jpl.aerie.types.ActivityInstanceId, gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService.SpanRecord> simulatedActivities) throws MerlinServiceException, IOException- Throws:
MerlinServiceExceptionIOException
-
postSpans
public void postSpans(DatasetId datasetId, Map<gov.nasa.jpl.aerie.types.ActivityInstanceId, gov.nasa.jpl.aerie.scheduler.server.services.GraphQLMerlinDatabaseService.SpanRecord> spans, Instant simulationStart, Map<gov.nasa.jpl.aerie.types.ActivityDirectiveId, throws MerlinServiceException, IOExceptiongov.nasa.jpl.aerie.types.ActivityDirectiveId> uploadIdMap) - Throws:
MerlinServiceExceptionIOException
-
serializeForGql
serialize the given string in a manner that can be used as a graphql argument value- Parameters:
s- the string to serialize- Returns:
- a serialization of the object suitable for use as a graphql value
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
merlinGraphqlURI
Returns the value of themerlinGraphqlURIrecord component.- Returns:
- the value of the
merlinGraphqlURIrecord component
-
hasuraGraphQlAdminSecret
Returns the value of thehasuraGraphQlAdminSecretrecord component.- Returns:
- the value of the
hasuraGraphQlAdminSecretrecord component
-