Skip to content

Commit

Permalink
use reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
smallzhongfeng committed Mar 20, 2023
1 parent 23f9dab commit 6828c0b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Sets;

import org.apache.uniffle.common.util.UnitConverter;
Expand Down Expand Up @@ -645,4 +646,8 @@ public String getEnv(String key) {
return System.getenv(key);
}

@VisibleForTesting
public Map<String, Object> getSettings() {
return settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.uniffle.test;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand All @@ -36,6 +37,7 @@
import org.apache.uniffle.common.ShuffleRegisterInfo;
import org.apache.uniffle.common.ShuffleServerInfo;
import org.apache.uniffle.common.config.RssBaseConf;
import org.apache.uniffle.common.config.RssConf;
import org.apache.uniffle.common.rpc.StatusCode;
import org.apache.uniffle.common.storage.StorageInfo;
import org.apache.uniffle.common.storage.StorageMedia;
Expand Down Expand Up @@ -128,15 +130,16 @@ public void getShuffleAssignmentsTest() throws Exception {
// the server's tags will be [ss_v4, GRPC_NETTY] and [ss_v4, GRPC], respectively.
// We need to remove the first machine's tag from GRPC_NETTY to GRPC
shuffleServers.get(0).stopServer();
ShuffleServerConf shuffleServerConf = shuffleServers.get(0).getShuffleServerConf();
shuffleServerConf.setInteger("rss.rpc.server.port", SHUFFLE_SERVER_PORT + 3);
shuffleServerConf.setInteger("rss.jetty.http.port", 18089);
shuffleServerConf.setInteger(ShuffleServerConf.NETTY_SERVER_PORT, -3);
shuffleServerConf.set(ShuffleServerConf.STORAGE_MEDIA_PROVIDER_ENV_KEY, "RSS_ENV_KEY");
String baseDir = shuffleServerConf.get(ShuffleServerConf.RSS_STORAGE_BASE_PATH).get(0);
RssConf shuffleServerConf = shuffleServers.get(0).getShuffleServerConf();
Map<String, Object> originConf = shuffleServerConf.getSettings();
Class<RssConf> clazz = RssConf.class;
Field field = clazz.getDeclaredField("settings");
field.setAccessible(true);
originConf.remove(ShuffleServerConf.NETTY_SERVER_PORT.key());
field.set(shuffleServerConf, originConf);
String storageTypeJsonSource = String.format("{\"%s\": \"ssd\"}", baseDir);
withEnvironmentVariables("RSS_ENV_KEY", storageTypeJsonSource).execute(() -> {
ShuffleServer ss = new ShuffleServer(shuffleServerConf);
ShuffleServer ss = new ShuffleServer((ShuffleServerConf) shuffleServerConf);
ss.start();
shuffleServers.set(0, ss);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ public class ShuffleServerConf extends RssBaseConf {
public static final ConfigOption<Integer> NETTY_SERVER_PORT = ConfigOptions
.key("rss.server.netty.port")
.intType()
.checkValue(ConfigUtils.POSITIVE_INTEGER_VALIDATOR_2, "netty port must be positive")
.defaultValue(-1)
.withDescription("Shuffle netty server port");

Expand Down

0 comments on commit 6828c0b

Please sign in to comment.