|
107 | 107 | import io.mantisrx.master.jobcluster.proto.JobClusterProto.KillJobRequest; |
108 | 108 | import io.mantisrx.master.jobcluster.proto.JobProto; |
109 | 109 | import io.mantisrx.runtime.JobConstraints; |
| 110 | +import io.mantisrx.runtime.JobSla; |
110 | 111 | import io.mantisrx.runtime.descriptor.StageSchedulingInfo; |
111 | 112 | import io.mantisrx.server.core.JobCompletedReason; |
112 | 113 | import io.mantisrx.server.master.ConstraintsEvaluators; |
|
127 | 128 | import io.mantisrx.shaded.com.google.common.collect.Lists; |
128 | 129 | import java.time.Duration; |
129 | 130 | import java.time.Instant; |
130 | | -import java.util.*; |
131 | | -import java.util.concurrent.*; |
| 131 | +import java.util.ArrayList; |
| 132 | +import java.util.Collections; |
| 133 | +import java.util.HashMap; |
| 134 | +import java.util.HashSet; |
| 135 | +import java.util.Iterator; |
| 136 | +import java.util.List; |
| 137 | +import java.util.Map; |
| 138 | +import java.util.Objects; |
| 139 | +import java.util.Optional; |
| 140 | +import java.util.Set; |
| 141 | +import java.util.TreeSet; |
| 142 | +import java.util.concurrent.CompletionStage; |
| 143 | +import java.util.concurrent.ConcurrentHashMap; |
| 144 | +import java.util.concurrent.ConcurrentMap; |
132 | 145 | import java.util.stream.Collectors; |
133 | 146 | import org.slf4j.Logger; |
134 | 147 | import org.slf4j.LoggerFactory; |
@@ -1235,6 +1248,7 @@ public void onJobClusterEnable(final EnableJobClusterRequest req) { |
1235 | 1248 |
|
1236 | 1249 | //start SLA timer |
1237 | 1250 | setBookkeepingTimer(BOOKKEEPING_INTERVAL_SECS); |
| 1251 | + |
1238 | 1252 | eventPublisher.publishAuditEvent( |
1239 | 1253 | new LifecycleEventsProto.AuditEvent(LifecycleEventsProto.AuditEvent.AuditEventType.JOB_CLUSTER_ENABLED, |
1240 | 1254 | this.jobClusterMetadata.getJobClusterDefinition().getName(), name + " enabled") |
@@ -1440,11 +1454,32 @@ private JobDefinition getResolvedJobDefinition(final String user, final Optional |
1440 | 1454 | // for request inheriting from non-terminal jobs, it has been sent to job actor instead. |
1441 | 1455 | Optional<JobDefinition> jobDefnOp = cloneJobDefinitionForQuickSubmitFromArchivedJobs( |
1442 | 1456 | jobManager.getCompletedJobsList(), empty(), jobStore); |
1443 | | - if(jobDefnOp.isPresent()) { |
| 1457 | + if (jobDefnOp.isPresent()) { |
1444 | 1458 | logger.info("Inherited scheduling Info and parameters from previous job"); |
1445 | 1459 | resolvedJobDefn = jobDefnOp.get(); |
1446 | | - } else { |
1447 | | - throw new Exception("Job Definition could not retrieved from a previous submission (There may not be a previous submission)"); |
| 1460 | + } else if (this.jobClusterMetadata != null |
| 1461 | + && this.jobClusterMetadata.getJobClusterDefinition() != null && |
| 1462 | + this.jobClusterMetadata.getJobClusterDefinition().getJobClusterConfig() != null) { |
| 1463 | + logger.info("No previous job definition found. Fall back to cluster definition: {}", this.name); |
| 1464 | + IJobClusterDefinition clusterDefinition = this.jobClusterMetadata.getJobClusterDefinition(); |
| 1465 | + JobClusterConfig clusterConfig = |
| 1466 | + this.jobClusterMetadata.getJobClusterDefinition().getJobClusterConfig(); |
| 1467 | + |
| 1468 | + resolvedJobDefn = new JobDefinition.Builder() |
| 1469 | + .withJobSla(new JobSla.Builder().build()) |
| 1470 | + .withArtifactName(clusterConfig.getArtifactName()) |
| 1471 | + .withVersion(clusterConfig.getVersion()) |
| 1472 | + .withLabels(clusterDefinition.getLabels()) |
| 1473 | + .withName(this.name) |
| 1474 | + .withParameters(clusterDefinition.getParameters()) |
| 1475 | + .withSchedulingInfo(clusterConfig.getSchedulingInfo()) |
| 1476 | + .withUser(user) |
| 1477 | + .build(); |
| 1478 | + logger.info("Built job definition from cluster definition: {}", resolvedJobDefn); |
| 1479 | + } |
| 1480 | + else { |
| 1481 | + throw new Exception("Job Definition could not retrieved from a previous submission (There may " |
| 1482 | + + "not be a previous submission)"); |
1448 | 1483 | } |
1449 | 1484 | } |
1450 | 1485 |
|
|
0 commit comments