use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfValidationTaskTest method missingHdfsSiteXML.
@Test
public void missingHdfsSiteXML() {
// Only prepare core-site.xml
String coreSite = Paths.get(sTestDir.toPath().toString(), "core-site.xml").toString();
ValidationTestUtils.writeXML(coreSite, ImmutableMap.of("key1", "value1"));
sConf.set(PropertyKey.UNDERFS_HDFS_CONFIGURATION, coreSite);
HdfsConfValidationTask task = new HdfsConfValidationTask("hdfs://namenode:9000/alluxio", sConf);
ValidationTaskResult result = task.loadHdfsConfig();
assertEquals(result.getState(), ValidationUtils.State.SKIPPED);
assertThat(result.getResult(), containsString("hdfs-site.xml is not configured"));
assertThat(result.getAdvice(), containsString("hdfs-site.xml"));
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfValidationTaskTest method cannotParseCoreSiteXml.
@Test
public void cannotParseCoreSiteXml() throws IOException {
String hdfsSite = Paths.get(sTestDir.toPath().toString(), "hdfs-site.xml").toString();
ValidationTestUtils.writeXML(hdfsSite, ImmutableMap.of("key2", "value2"));
RandomAccessFile hdfsFile = new RandomAccessFile(hdfsSite, "rw");
hdfsFile.setLength(hdfsFile.length() - 10);
String coreSite = Paths.get(sTestDir.toPath().toString(), "core-site.xml").toString();
ValidationTestUtils.writeXML(coreSite, ImmutableMap.of("key1", "value1"));
RandomAccessFile coreFile = new RandomAccessFile(coreSite, "rw");
coreFile.setLength(coreFile.length() - 10);
sConf.set(PropertyKey.UNDERFS_HDFS_CONFIGURATION, hdfsSite + HdfsConfValidationTask.SEPARATOR + coreSite);
HdfsConfValidationTask task = new HdfsConfValidationTask("hdfs://namenode:9000/alluxio", sConf);
ValidationTaskResult result = task.loadHdfsConfig();
assertEquals(ValidationUtils.State.FAILED, result.getState());
assertThat(result.getResult(), containsString(String.format("Failed to parse %s", hdfsSite)));
assertThat(result.getResult(), containsString(String.format("Failed to parse %s", coreSite)));
assertThat(result.getAdvice(), containsString(String.format("Failed to parse %s", hdfsSite)));
assertThat(result.getAdvice(), containsString(String.format("Failed to parse %s", coreSite)));
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfParityValidationTask method validateHdfsSettingParity.
private ValidationTaskResult validateHdfsSettingParity(Map<String, String> optionsMap) {
String serverHadoopConfDirPath;
if (optionsMap.containsKey(HADOOP_CONF_DIR_OPTION.getOpt())) {
serverHadoopConfDirPath = optionsMap.get(HADOOP_CONF_DIR_OPTION.getOpt());
} else {
serverHadoopConfDirPath = System.getenv(HADOOP_CONF_DIR_ENV_VAR);
}
if (serverHadoopConfDirPath == null) {
mMsg.append("Path to server-side hadoop configuration unspecified," + " skipping validation for HDFS properties.");
return new ValidationTaskResult(ValidationUtils.State.SKIPPED, getName(), mMsg.toString(), mAdvice.toString());
}
String serverCoreSiteFilePath = PathUtils.concatPath(serverHadoopConfDirPath, "/core-site.xml");
String serverHdfsSiteFilePath = PathUtils.concatPath(serverHadoopConfDirPath, "/hdfs-site.xml");
// Load client core-site and hdfs-site config
ValidationTaskResult loadConfig = loadHdfsConfig();
if (loadConfig.getState() != ValidationUtils.State.OK) {
// If failed to load config files, abort
return loadConfig;
}
boolean ok = compareConfigurations(serverCoreSiteFilePath, "core-site.xml", mCoreConf) && compareConfigurations(serverHdfsSiteFilePath, "hdfs-site.xml", mHdfsConf);
return new ValidationTaskResult(ok ? ValidationUtils.State.OK : ValidationUtils.State.FAILED, getName(), mMsg.toString(), mAdvice.toString());
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfValidationTask method checkNameservice.
protected ValidationTaskResult checkNameservice() {
ValidationUtils.State state;
String nsKey = "dfs.nameservices";
String nameservices = mCoreConf.get(nsKey);
if (nameservices == null) {
nameservices = mHdfsConf.get(nsKey);
}
if (nameservices == null) {
return new ValidationTaskResult(ValidationUtils.State.OK, getName(), "No nameservice " + "detected", "");
}
List<String> nsList = Arrays.stream(nameservices.split(",")).map(String::trim).collect(Collectors.toList());
try {
URI u = URI.create(mPath);
String uriHost = u.getHost().toLowerCase();
long nsCount = nsList.stream().filter(s -> uriHost.equals(s.toLowerCase())).count();
state = ValidationUtils.State.OK;
if (nsCount < 1) {
state = ValidationUtils.State.FAILED;
mAdvice.append(String.format("One or more nameservices (%s) were detected in the HDFS " + "configuration, but not used in the URI to connect to HDFS.", nameservices));
mMsg.append(String.format("Could not find any of the configured nameservices (%s) in the " + "given HDFS connection URI (%s)", nameservices, u));
}
} catch (IllegalArgumentException e) {
state = ValidationUtils.State.FAILED;
mMsg.append("HDFS path not parsable as a URI.");
mMsg.append(ValidationUtils.getErrorInfo(e));
mAdvice.append("Make sure the HDFS URI is in a valid format.");
}
return new ValidationTaskResult(state, getName(), mMsg.toString(), mAdvice.toString());
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsProxyUserValidationTaskTest method skipped.
@Test
public void skipped() {
mConf.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.NOSASL.getAuthName());
HdfsProxyUserValidationTask task = new HdfsProxyUserValidationTask("hdfs://namenode:9000/alluxio", mConf);
ValidationTaskResult result = task.validateImpl(ImmutableMap.of());
assertEquals(ValidationUtils.State.SKIPPED, result.getState());
}
Aggregations