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

YARN-9375. Use Configured in GpuDiscoverer and FpgaDiscoverer #1131

Merged
merged 1 commit into from
Aug 2, 2019
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,6 +28,7 @@
import java.util.stream.Collectors;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.util.Shell.ShellCommandExecutor;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
Expand All @@ -46,11 +47,10 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;

public class FpgaDiscoverer {
public class FpgaDiscoverer extends Configured {
private static final Logger LOG = LoggerFactory.getLogger(
FpgaDiscoverer.class);

private Configuration conf = null;
private AbstractFpgaVendorPlugin plugin = null;
private List<FpgaResourceAllocator.FpgaDevice> currentFpgaInfo = null;

Expand All @@ -64,11 +64,6 @@ void setScriptRunner(Function<String, Optional<String>> scriptRunner) {
this.scriptRunner = scriptRunner;
}

@VisibleForTesting
public void setConf(Configuration configuration) {
this.conf = configuration;
}

public List<FpgaDevice> getCurrentFpgaInfo() {
return currentFpgaInfo;
}
Expand All @@ -82,7 +77,7 @@ public boolean diagnose() {
}

public void initialize(Configuration config) throws YarnException {
this.conf = config;
setConf(config);
this.plugin.initPlugin(config);
// Try to diagnose FPGA
LOG.info("Trying to diagnose FPGA information ...");
Expand All @@ -100,11 +95,11 @@ public void initialize(Configuration config) throws YarnException {
public List<FpgaDevice> discover()
throws ResourceHandlerException {
List<FpgaDevice> list;
String allowed = this.conf.get(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES);
String allowed = getConf().get(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES);

String availableDevices = conf.get(
String availableDevices = getConf().get(
YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES);
String discoveryScript = conf.get(
String discoveryScript = getConf().get(
YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT);

FPGADiscoveryStrategy discoveryStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
Expand All @@ -45,7 +46,7 @@

@InterfaceAudience.Private
@InterfaceStability.Unstable
public class GpuDiscoverer {
public class GpuDiscoverer extends Configured {
public static final Logger LOG = LoggerFactory.getLogger(
GpuDiscoverer.class);
@VisibleForTesting
Expand All @@ -61,7 +62,6 @@ public class GpuDiscoverer {
private static final int MAX_EXEC_TIMEOUT_MS = 10 * 1000;
private static final int MAX_REPEATED_ERROR_ALLOWED = 10;

private Configuration conf = null;
private String pathOfGpuBinary = null;
private Map<String, String> environment = new HashMap<>();

Expand All @@ -71,7 +71,7 @@ public class GpuDiscoverer {
private List<GpuDevice> gpuDevicesFromUser;

private void validateConfOrThrowException() throws YarnException {
if (conf == null) {
if (getConf() == null) {
throw new YarnException("Please initialize (call initialize) before use "
+ GpuDiscoverer.class.getSimpleName());
}
Expand Down Expand Up @@ -144,7 +144,7 @@ synchronized GpuDeviceInformation getGpuDeviceInformation()
}

private boolean IsAutoDiscoveryEnabled() {
String allowedDevicesStr = conf.get(
String allowedDevicesStr = getConf().get(
YarnConfiguration.NM_GPU_ALLOWED_DEVICES,
YarnConfiguration.AUTOMATICALLY_DISCOVER_GPU_DEVICES);
return allowedDevicesStr.equals(
Expand Down Expand Up @@ -205,7 +205,7 @@ private List<GpuDevice> parseGpuDevicesFromAutoDiscoveredGpuInfo()
*/
private List<GpuDevice> parseGpuDevicesFromUserDefinedValues()
throws YarnException {
String devices = conf.get(
String devices = getConf().get(
YarnConfiguration.NM_GPU_ALLOWED_DEVICES,
YarnConfiguration.AUTOMATICALLY_DISCOVER_GPU_DEVICES);

Expand Down Expand Up @@ -249,7 +249,7 @@ private GpuDevice parseGpuDevice(String device, String[] splitByColon,

public synchronized void initialize(Configuration config)
throws YarnException {
this.conf = config;
setConf(config);
if (IsAutoDiscoveryEnabled()) {
numOfErrorExecutionSinceLastSucceed = 0;
lookUpAutoDiscoveryBinary(config);
Expand Down