Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINOR] Migrate RankValue to the package of the common class #265

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@

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
*/
public abstract class AbstractSelectStorageStrategy implements SelectStorageStrategy {
/**
* store remote path -> application count for assignment strategy
*/
protected final Map<String, LowestIOSampleCostSelectStorageStrategy.RankValue> remoteStoragePathRankValue;
protected final Map<String, RankValue> remoteStoragePathRankValue;
protected final int fileSize;

public AbstractSelectStorageStrategy(
Map<String, LowestIOSampleCostSelectStorageStrategy.RankValue> remoteStoragePathRankValue,
Map<String, RankValue> remoteStoragePathRankValue,
CoordinatorConf conf) {
this.remoteStoragePathRankValue = remoteStoragePathRankValue;
fileSize = conf.getInteger(CoordinatorConf.COORDINATOR_REMOTE_STORAGE_SCHEDULE_FILE_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
+ '}';
}
}
}
Original file line number Diff line number Diff line change
@@ -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 + '}';
}
}