Skip to content

Commit

Permalink
Add runID to job meta
Browse files Browse the repository at this point in the history
Signed-off-by: wslulciuc <willy@datakin.com>
  • Loading branch information
wslulciuc committed Oct 14, 2020
1 parent a63a087 commit 12b02e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/main/java/marquez/api/JobResource.java
Expand Up @@ -84,6 +84,7 @@ public Response createOrUpdate(
@Valid JobMeta jobMeta)
throws MarquezServiceException {
throwIfNotExists(namespaceName);
throwIfNotExists(jobMeta.getRunId().orElse(null));

final Job job = jobService.createOrUpdate(namespaceName, jobName, jobMeta);
return Response.ok(job).build();
Expand Down Expand Up @@ -264,9 +265,11 @@ void throwIfExists(
}
}

void throwIfNotExists(@NonNull RunId runId) throws MarquezServiceException {
if (!jobService.runExists(runId)) {
throw new RunNotFoundException(runId);
void throwIfNotExists(@Nullable RunId runId) throws MarquezServiceException {
if (runId != null) {
if (!jobService.runExists(runId)) {
throw new RunNotFoundException(runId);
}
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/marquez/service/models/JobMeta.java
Expand Up @@ -35,6 +35,7 @@
import marquez.common.models.JobName;
import marquez.common.models.JobType;
import marquez.common.models.NamespaceName;
import marquez.common.models.RunId;

@EqualsAndHashCode
@ToString
Expand All @@ -45,20 +46,23 @@ public final class JobMeta {
@Nullable private final URL location;
@Getter private final ImmutableMap<String, String> context;
@Nullable private final String description;
@Nullable private final RunId runId;

public JobMeta(
@NonNull final JobType type,
@NonNull final ImmutableSet<DatasetId> inputs,
@NonNull final ImmutableSet<DatasetId> outputs,
@Nullable final URL location,
@Nullable final ImmutableMap<String, String> context,
@Nullable final String description) {
@Nullable final String description,
@Nullable final RunId runId) {
this.type = type;
this.inputs = inputs;
this.outputs = outputs;
this.location = location;
this.context = (context == null) ? ImmutableMap.of() : context;
this.description = description;
this.runId = runId;
}

public Optional<URL> getLocation() {
Expand All @@ -69,6 +73,10 @@ public Optional<String> getDescription() {
return Optional.ofNullable(description);
}

public Optional<RunId> getRunId() {
return Optional.ofNullable(runId);
}

public Version version(@NonNull NamespaceName namespaceName, @NonNull JobName jobName) {
final byte[] bytes =
VERSION_JOINER
Expand Down

0 comments on commit 12b02e4

Please sign in to comment.