diff --git a/coordinator/src/main/java/org/apache/uniffle/coordinator/AbstractSelectStorageStrategy.java b/coordinator/src/main/java/org/apache/uniffle/coordinator/AbstractSelectStorageStrategy.java index d76ceea336..9025ddb44f 100644 --- a/coordinator/src/main/java/org/apache/uniffle/coordinator/AbstractSelectStorageStrategy.java +++ b/coordinator/src/main/java/org/apache/uniffle/coordinator/AbstractSelectStorageStrategy.java @@ -28,8 +28,6 @@ import org.apache.uniffle.common.exception.RssException; -import static org.apache.uniffle.coordinator.LowestIOSampleCostSelectStorageStrategy.RankValue; - /** * This is a simple implementation class, which provides some methods to check whether the path is normal */ @@ -37,11 +35,11 @@ public abstract class AbstractSelectStorageStrategy implements SelectStorageStra /** * store remote path -> application count for assignment strategy */ - protected final Map remoteStoragePathRankValue; + protected final Map remoteStoragePathRankValue; protected final int fileSize; public AbstractSelectStorageStrategy( - Map remoteStoragePathRankValue, + Map remoteStoragePathRankValue, CoordinatorConf conf) { this.remoteStoragePathRankValue = remoteStoragePathRankValue; fileSize = conf.getInteger(CoordinatorConf.COORDINATOR_REMOTE_STORAGE_SCHEDULE_FILE_SIZE); diff --git a/coordinator/src/main/java/org/apache/uniffle/coordinator/AppBalanceSelectStorageStrategy.java b/coordinator/src/main/java/org/apache/uniffle/coordinator/AppBalanceSelectStorageStrategy.java index 764b854fff..4f6f653573 100644 --- a/coordinator/src/main/java/org/apache/uniffle/coordinator/AppBalanceSelectStorageStrategy.java +++ b/coordinator/src/main/java/org/apache/uniffle/coordinator/AppBalanceSelectStorageStrategy.java @@ -35,7 +35,6 @@ import org.apache.uniffle.common.RemoteStorageInfo; import org.apache.uniffle.common.filesystem.HadoopFilesystemProvider; -import org.apache.uniffle.coordinator.LowestIOSampleCostSelectStorageStrategy.RankValue; /** * AppBalanceSelectStorageStrategy will consider the number of apps allocated on each remote path is balanced. diff --git a/coordinator/src/main/java/org/apache/uniffle/coordinator/ApplicationManager.java b/coordinator/src/main/java/org/apache/uniffle/coordinator/ApplicationManager.java index 0b79b5067b..71561af98e 100644 --- a/coordinator/src/main/java/org/apache/uniffle/coordinator/ApplicationManager.java +++ b/coordinator/src/main/java/org/apache/uniffle/coordinator/ApplicationManager.java @@ -38,7 +38,6 @@ import org.apache.uniffle.common.RemoteStorageInfo; import org.apache.uniffle.common.util.Constants; import org.apache.uniffle.common.util.ThreadUtils; -import org.apache.uniffle.coordinator.LowestIOSampleCostSelectStorageStrategy.RankValue; public class ApplicationManager { diff --git a/coordinator/src/main/java/org/apache/uniffle/coordinator/LowestIOSampleCostSelectStorageStrategy.java b/coordinator/src/main/java/org/apache/uniffle/coordinator/LowestIOSampleCostSelectStorageStrategy.java index 8917233408..551b8f4cf2 100644 --- a/coordinator/src/main/java/org/apache/uniffle/coordinator/LowestIOSampleCostSelectStorageStrategy.java +++ b/coordinator/src/main/java/org/apache/uniffle/coordinator/LowestIOSampleCostSelectStorageStrategy.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; @@ -134,57 +133,4 @@ public synchronized RemoteStorageInfo pickStorage(String appId) { LOG.warn("No remote storage is available, we will default to the first."); return availableRemoteStorageInfo.values().iterator().next(); } - - static class RankValue { - AtomicLong costTime; - AtomicInteger appNum; - AtomicBoolean isHealthy; - - RankValue(int appNum) { - this.costTime = new AtomicLong(0); - this.appNum = new AtomicInteger(appNum); - this.isHealthy = new AtomicBoolean(true); - } - - RankValue(long costTime, int appNum) { - this.costTime = new AtomicLong(costTime); - this.appNum = new AtomicInteger(appNum); - this.isHealthy = new AtomicBoolean(true); - } - - public AtomicLong getCostTime() { - return costTime; - } - - public AtomicInteger getAppNum() { - return appNum; - } - - public AtomicBoolean getHealthy() { - return isHealthy; - } - - public void setCostTime(AtomicLong readAndWriteTime) { - this.costTime = readAndWriteTime; - } - - public void setAppNum(AtomicInteger appNum) { - this.appNum = appNum; - } - - public void setHealthy(AtomicBoolean isHealthy) { - this.isHealthy = isHealthy; - if (!isHealthy.get()) { - this.costTime.set(Long.MAX_VALUE); - } - } - - @Override - public String toString() { - return "RankValue{" - + "costTime=" + costTime - + ", appNum=" + appNum - + '}'; - } - } } diff --git a/coordinator/src/main/java/org/apache/uniffle/coordinator/RankValue.java b/coordinator/src/main/java/org/apache/uniffle/coordinator/RankValue.java new file mode 100644 index 0000000000..349698b16b --- /dev/null +++ b/coordinator/src/main/java/org/apache/uniffle/coordinator/RankValue.java @@ -0,0 +1,74 @@ +/* + * 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.uniffle.coordinator; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +/** + * The basis for app to select remote storage ranking + */ +public class RankValue { + AtomicLong costTime; + AtomicInteger appNum; + AtomicBoolean isHealthy; + + public RankValue(int appNum) { + this.costTime = new AtomicLong(0); + this.appNum = new AtomicInteger(appNum); + this.isHealthy = new AtomicBoolean(true); + } + + public RankValue(long costTime, int appNum) { + this.costTime = new AtomicLong(costTime); + this.appNum = new AtomicInteger(appNum); + this.isHealthy = new AtomicBoolean(true); + } + + public AtomicLong getCostTime() { + return costTime; + } + + public AtomicInteger getAppNum() { + return appNum; + } + + public AtomicBoolean getHealthy() { + return isHealthy; + } + + public void setCostTime(AtomicLong readAndWriteTime) { + this.costTime = readAndWriteTime; + } + + public void setHealthy(AtomicBoolean isHealthy) { + this.isHealthy = isHealthy; + if (!isHealthy.get()) { + this.costTime.set(Long.MAX_VALUE); + } + } + + @Override + public String toString() { + return "RankValue{" + + "costTime=" + costTime + + ", appNum=" + appNum + + ", isHealthy=" + isHealthy + '}'; + } +}