org.apache.flink.runtime.taskexecutor.SlotStatus Maven / Gradle / Ivy
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.flink.runtime.taskexecutor;
import org.apache.flink.api.common.JobID;
import org.apache.flink.runtime.clusterframework.types.AllocationID;
import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
import org.apache.flink.runtime.clusterframework.types.SlotID;
import org.apache.flink.runtime.resourcemanager.placementconstraint.SlotTag;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import static org.apache.flink.util.Preconditions.checkNotNull;
/**
* This describes the slot current status which located in TaskManager.
*/
public class SlotStatus implements Serializable {
private static final long serialVersionUID = 5099191707339664493L;
/** slotID to identify a slot */
private final SlotID slotID;
/** the resource profile of the slot */
private final ResourceProfile resourceProfile;
/** if the slot is allocated, allocationId identify its allocation; else, allocationId is null */
private final AllocationID allocationID;
/** The actual allocated resource */
private final ResourceProfile allocationResourceProfile;
/** if the slot is allocated, jobId identify which job this slot is allocated to; else, jobId is null */
private final JobID jobID;
/** tags of the slot */
private final List tags;
private final long version;
public SlotStatus(SlotID slotID, ResourceProfile resourceProfile) {
this(slotID, resourceProfile, null, null, null, Collections.emptyList(), 0L);
}
public SlotStatus(
SlotID slotID,
ResourceProfile resourceProfile,
JobID jobID,
AllocationID allocationID,
ResourceProfile allocationResourceProfile,
long version) {
this(slotID,
resourceProfile,
jobID,
allocationID,
allocationResourceProfile,
Collections.emptyList(),
version);
}
public SlotStatus(
SlotID slotID,
ResourceProfile resourceProfile,
JobID jobID,
AllocationID allocationID,
ResourceProfile allocationResourceProfile,
List tags,
long version) {
this.slotID = checkNotNull(slotID, "slotID cannot be null");
this.resourceProfile = checkNotNull(resourceProfile, "profile cannot be null");
this.allocationID = allocationID;
this.jobID = jobID;
this.allocationResourceProfile = allocationResourceProfile;
this.tags = tags;
this.version = version;
}
/**
* Get the unique identification of this slot
*
* @return The slot id
*/
public SlotID getSlotID() {
return slotID;
}
/**
* Get the resource profile of this slot
*
* @return The resource profile
*/
public ResourceProfile getResourceProfile() {
return resourceProfile;
}
/**
* Get the actual allocated resource in this slot
*
* @return The actual allocated resource if this slot is allocated, otherwise null
*/
public ResourceProfile getAllocationResourceProfile() {
return allocationResourceProfile;
}
/**
* Get the allocation id of this slot
*
* @return The allocation id if this slot is allocated, otherwise null
*/
public AllocationID getAllocationID() {
return allocationID;
}
/**
* Get the job id of the slot allocated for
*
* @return The job id if this slot is allocated, otherwise null
*/
public JobID getJobID() {
return jobID;
}
public List getTags() { return tags; }
public long getVersion() {
return version;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SlotStatus that = (SlotStatus) o;
if (!slotID.equals(that.slotID)) {
return false;
}
if (!resourceProfile.equals(that.resourceProfile)) {
return false;
}
if (allocationID != null ? !allocationID.equals(that.allocationID) : that.allocationID != null) {
return false;
}
if (allocationResourceProfile != null ? !allocationResourceProfile.equals(that.allocationResourceProfile)
: that.allocationResourceProfile != null) {
return false;
}
if (version != that.version) {
return false;
}
return jobID != null ? jobID.equals(that.jobID) : that.jobID == null;
}
@Override
public int hashCode() {
int result = slotID.hashCode();
result = 31 * result + resourceProfile.hashCode();
result = 31 * result + (allocationID != null ? allocationID.hashCode() : 0);
result = 31 * result + (jobID != null ? jobID.hashCode() : 0);
result = 31 * result + (allocationResourceProfile != null ? allocationResourceProfile.hashCode() : 0);
result = 31 * result + Long.hashCode(version);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy