use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class DatabaseValidationTask method getValidationWithResult.
@Override
Pair<ValidationTaskResult, String> getValidationWithResult() throws InterruptedException {
if (mInputTask == null) {
return new Pair<>(new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), "Did not have a pre-requisite task to obtain HMS client for database check", ""), null);
}
Pair<ValidationTaskResult, IMetaStoreClient> res = mInputTask.getValidationWithResult();
if (res.getFirst().getState() != ValidationUtils.State.OK) {
return new Pair<>(res.getFirst(), null);
}
IMetaStoreClient client = res.getSecond();
try {
Database database = client.getDatabase(mDbName);
return new Pair<>(new ValidationTaskResult(ValidationUtils.State.OK, getName(), String.format("Database (name: %s, description: %s)", database.getName(), database.getDescription()), ""), mDbName);
} catch (NoSuchObjectException e) {
return new Pair<>(new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), ValidationUtils.getErrorInfo(e), "Please make sure the given database name is valid " + "and existing in the target hive metastore"), null);
} catch (Throwable t) {
return new Pair<>(new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), ValidationUtils.getErrorInfo(t), "Failed to get database from remote hive metastore"), null);
} finally {
client.close();
}
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class TableValidationTask method getValidationWithResult.
@Override
Pair<ValidationTaskResult, String> getValidationWithResult() throws InterruptedException {
if (mInputTask == null) {
return new Pair<>(new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), "Did not have a pre-requisite task to obtain HMS client for table check", ""), null);
}
Pair<ValidationTaskResult, IMetaStoreClient> res = mInputTask.getValidationWithResult();
if (res.getFirst().getState() != ValidationUtils.State.OK) {
return new Pair<>(res.getFirst(), null);
}
IMetaStoreClient client = res.getSecond();
try {
if (mTables != null && !mTables.isEmpty()) {
return new Pair<>(getTableSchemaTest(client, Arrays.asList(mTables.split(","))), null);
} else {
return new Pair<>(getAllTableInfoTest(client), null);
}
} finally {
client.close();
}
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfValidationTask method validateImpl.
@Override
public ValidationTaskResult validateImpl(Map<String, String> optionsMap) {
if (!ValidationUtils.isHdfsScheme(mPath)) {
mMsg.append(String.format("UFS path %s is not HDFS. Skipping validation for HDFS properties.%n", mPath));
return new ValidationTaskResult(ValidationUtils.State.SKIPPED, getName(), mMsg.toString(), mAdvice.toString());
}
ValidationTaskResult loadConfig = loadHdfsConfig();
if (loadConfig.getState() != ValidationUtils.State.OK) {
// If failed to load config files, abort
return loadConfig;
}
// no conflicts between these two
ValidationTaskResult last = checkConflicts();
if (last.getState() == ValidationUtils.State.OK) {
last = checkNameservice();
}
return last;
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfValidationTaskTest method validConf.
@Test
public void validConf() {
String hdfsSite = Paths.get(sTestDir.toPath().toString(), "hdfs-site.xml").toString();
ValidationTestUtils.writeXML(hdfsSite, ImmutableMap.of("key1", "value1", "key3", "value3"));
String coreSite = Paths.get(sTestDir.toPath().toString(), "core-site.xml").toString();
ValidationTestUtils.writeXML(coreSite, ImmutableMap.of("key1", "value1", "key4", "value4"));
sConf.set(PropertyKey.UNDERFS_HDFS_CONFIGURATION, hdfsSite + HdfsConfValidationTask.SEPARATOR + coreSite);
HdfsConfValidationTask task = new HdfsConfValidationTask("hdfs://namenode:9000/alluxio", sConf);
ValidationTaskResult result = task.validateImpl(ImmutableMap.of());
assertEquals(ValidationUtils.State.OK, result.getState());
}
use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.
the class HdfsConfValidationTaskTest method missingCoreSiteXML.
@Test
public void missingCoreSiteXML() {
// Only prepare hdfs-site.xml
String hdfsSite = Paths.get(sTestDir.toPath().toString(), "hdfs-site.xml").toString();
ValidationTestUtils.writeXML(hdfsSite, ImmutableMap.of("key1", "value1"));
sConf.set(PropertyKey.UNDERFS_HDFS_CONFIGURATION, hdfsSite);
HdfsConfValidationTask task = new HdfsConfValidationTask("hdfs://namenode:9000/alluxio", sConf);
ValidationTaskResult result = task.loadHdfsConfig();
assertEquals(result.getState(), ValidationUtils.State.SKIPPED);
assertThat(result.getResult(), containsString("core-site.xml is not configured"));
assertThat(result.getAdvice(), containsString("core-site.xml"));
}
Aggregations