Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mantisrx.master.jobcluster.job;
import io.mantisrx.common.Label;
import io.mantisrx.master.jobcluster.job.worker.JobWorker;
import io.mantisrx.runtime.JobSla;
import io.mantisrx.runtime.descriptor.SchedulingInfo;
import io.mantisrx.runtime.parameter.Parameter;
import io.mantisrx.server.master.domain.Costs;
import io.mantisrx.server.master.domain.DataFormatAdapter;
import io.mantisrx.server.master.domain.JobDefinition;
import io.mantisrx.server.master.domain.JobId;
import io.mantisrx.server.master.persistence.MantisJobStore;
import io.mantisrx.server.master.persistence.exceptions.InvalidJobException;
import io.mantisrx.server.master.persistence.exceptions.InvalidJobStateChangeException;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonCreator;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonFilter;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonIgnore;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonProperty;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@JsonFilter("topLevelFilter")
public class MantisJobMetadataImpl implements IMantisJobMetadata {
private static final Logger logger = LoggerFactory.getLogger(MantisJobMetadataImpl.class);
private final JobId jobId;
private final long submittedAt;
@Getter
private final long heartbeatIntervalSecs;
@Getter
private final long workerTimeoutSecs;
private long startedAt = DEFAULT_STARTED_AT_EPOCH;
private long endedAt = DEFAULT_STARTED_AT_EPOCH;
private JobState state;
private int nextWorkerNumberToUse;
private final JobDefinition jobDefinition;
private Costs jobCosts;
@JsonIgnore
private final Map stageMetadataMap = new HashMap<>();
@JsonIgnore
private final Map workerNumberToStageMap = new HashMap<>();
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown=true)
public MantisJobMetadataImpl(@JsonProperty("jobId") JobId jobId,
@JsonProperty("submittedAt") long submittedAt,
@JsonProperty("startedAt") long startedAt,
@JsonProperty("jobDefinition") JobDefinition jobDefinition,
@JsonProperty("state") JobState state,
@JsonProperty("nextWorkerNumberToUse") int nextWorkerNumberToUse,
@JsonProperty("heartbeatIntervalSecs") long heartbeatIntervalSecs,
@JsonProperty("workerTimeoutSecs") long workerTimeoutSecs) {
this.jobId = jobId;
this.submittedAt = submittedAt;
this.startedAt = startedAt;
this.state = state==null? JobState.Accepted : state;
this.nextWorkerNumberToUse = nextWorkerNumberToUse;
this.heartbeatIntervalSecs = heartbeatIntervalSecs;
this.workerTimeoutSecs = workerTimeoutSecs;
this.jobDefinition = jobDefinition;
}
@Override
public JobId getJobId() {
return jobId;
}
@Override
public String getClusterName() {
return this.jobDefinition.getName();
}
@JsonIgnore
@Override
public Instant getSubmittedAtInstant() {
return Instant.ofEpochMilli(submittedAt);
}
public long getSubmittedAt() {
return submittedAt;
}
@Override
public long getSubscriptionTimeoutSecs() {
return this.jobDefinition.getSubscriptionTimeoutSecs();
}
@Override
public int getNextWorkerNumberToUse() {
return nextWorkerNumberToUse;
}
public void setNextWorkerNumberToUse(int n, MantisJobStore store) throws Exception {
this.nextWorkerNumberToUse = n;
store.updateJob(this);
}
@Override
public JobState getState() {
return state;
}
@Override
public JobDefinition getJobDefinition() {
return this.jobDefinition;
}
@Override
public String getUser() {
return this.jobDefinition.getUser();
}
@Override
public Optional getSla() {
return Optional.ofNullable(this.jobDefinition.getJobSla());
}
@Override
public List getParameters() {
return this.jobDefinition.getParameters();
}
@Override
public List