shuai-xu commented on a change in pull request #7227: [FLINK-11059] [runtime] do not add releasing failed slot to free slots URL: https://github.com/apache/flink/pull/7227#discussion_r293215772
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/OfferedSlot.java ########## @@ -0,0 +1,79 @@ +/* + * 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.jobmaster; + +import org.apache.flink.runtime.clusterframework.types.AllocationID; + +import java.io.Serializable; +import java.util.Objects; + +import static org.apache.flink.util.Preconditions.checkArgument; +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * A snapshot of the slots on a TaskManager in SlotPool of the JobMaster. + */ +public class OfferedSlot implements Serializable { + + private static final long serialVersionUID = 1L; + + private final int slotIndex; + + private final AllocationID allocationId; + + public OfferedSlot(int index, AllocationID allocationId) { + checkArgument(index >= 0); + this.slotIndex = index; + this.allocationId = checkNotNull(allocationId); + } + + public AllocationID getAllocationId() { + return allocationId; + } + + public int getSlotIndex() { + return slotIndex; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + OfferedSlot that = (OfferedSlot) o; + return slotIndex == that.slotIndex && allocationId.equals(allocationId); + } + + @Override + public int hashCode() { + return Objects.hash(slotIndex, allocationId); + } Review comment: hashCode() is not used actually, equals() is needed by tests assertThat( , contains()); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
