Search in sources :

Example 1 with ValidationTaskResult

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();
    }
}
Also used : Database(org.apache.hadoop.hive.metastore.api.Database) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient) ValidationTaskResult(alluxio.cli.ValidationTaskResult) Pair(alluxio.collections.Pair)

Example 2 with ValidationTaskResult

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();
    }
}
Also used : IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient) ValidationTaskResult(alluxio.cli.ValidationTaskResult) Pair(alluxio.collections.Pair)

Example 3 with ValidationTaskResult

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;
}
Also used : ValidationTaskResult(alluxio.cli.ValidationTaskResult)

Example 4 with ValidationTaskResult

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());
}
Also used : StringContains.containsString(org.hamcrest.core.StringContains.containsString) ValidationTaskResult(alluxio.cli.ValidationTaskResult) Test(org.junit.Test)

Example 5 with ValidationTaskResult

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"));
}
Also used : StringContains.containsString(org.hamcrest.core.StringContains.containsString) ValidationTaskResult(alluxio.cli.ValidationTaskResult) Test(org.junit.Test)

Aggregations

ValidationTaskResult (alluxio.cli.ValidationTaskResult)28 Test (org.junit.Test)19 StringContains.containsString (org.hamcrest.core.StringContains.containsString)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Pair (alluxio.collections.Pair)4 IOException (java.io.IOException)3 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)3 List (java.util.List)2 AbstractValidationTask (alluxio.cli.AbstractValidationTask)1 ApplicableUfsType (alluxio.cli.ApplicableUfsType)1 ValidationUtils (alluxio.cli.ValidationUtils)1 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 PropertyKey (alluxio.conf.PropertyKey)1 InvalidPathException (alluxio.exception.InvalidPathException)1 ValidationResult (alluxio.hub.proto.ValidationResult)1 BaseHubTest (alluxio.hub.test.BaseHubTest)1 PathUtils (alluxio.util.io.PathUtils)1 RandomAccessFile (java.io.RandomAccessFile)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 URI (java.net.URI)1