@Test public void minorVersionAccepted() throws Exception { PowerMockito.mockStatic(ShellUtils.class); String[] cmd = new String[]{"hadoop", "version"}; BDDMockito.given(ShellUtils.execCommand(cmd)).willReturn("Hadoop 2.6.2"); sConf.set(PropertyKey.UNDERFS_VERSION, "2.6"); HdfsVersionValidationTask task = new HdfsVersionValidationTask(sConf); ValidationTaskResult result = task.validateImpl(ImmutableMap.of()); assertEquals(ValidationUtils.State.OK, result.getState()); }
@Override public ValidationTaskResult validateImpl(Map<String, String> optionMap) throws InterruptedException { String hadoopVersion; try { hadoopVersion = getHadoopVersion(); } catch (IOException e) { return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Failed to get hadoop version:%n%s.", ValidationUtils.getErrorInfo(e)), "Please check if hadoop is on your PATH."); } String version = mConf.get(PropertyKey.UNDERFS_VERSION); if (hadoopVersion.contains(version)) { return new ValidationTaskResult(ValidationUtils.State.OK, getName(), String.format("Hadoop version %s contains UFS version defined in alluxio %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), ""); } return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Hadoop version %s does not match %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), String.format("Please configure %s to match the HDFS version.", PropertyKey.UNDERFS_VERSION.toString())); }
HdfsVersionValidationTask extends AbstractValidationTask { @Override public ValidationTaskResult validateImpl(Map<String, String> optionMap) throws InterruptedException { String hadoopVersion; try { hadoopVersion = getHadoopVersion(); } catch (IOException e) { return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Failed to get hadoop version:%n%s.", ValidationUtils.getErrorInfo(e)), "Please check if hadoop is on your PATH."); } String version = mConf.get(PropertyKey.UNDERFS_VERSION); if (hadoopVersion.contains(version)) { return new ValidationTaskResult(ValidationUtils.State.OK, getName(), String.format("Hadoop version %s contains UFS version defined in alluxio %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), ""); } return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Hadoop version %s does not match %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), String.format("Please configure %s to match the HDFS version.", PropertyKey.UNDERFS_VERSION.toString())); } }
HdfsVersionValidationTask extends AbstractValidationTask { @Override public ValidationTaskResult validateImpl(Map<String, String> optionMap) throws InterruptedException { String hadoopVersion; try { hadoopVersion = getHadoopVersion(); } catch (IOException e) { return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Failed to get hadoop version:%n%s.", ValidationUtils.getErrorInfo(e)), "Please check if hadoop is on your PATH."); } String version = mConf.get(PropertyKey.UNDERFS_VERSION); if (hadoopVersion.contains(version)) { return new ValidationTaskResult(ValidationUtils.State.OK, getName(), String.format("Hadoop version %s contains UFS version defined in alluxio %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), ""); } return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Hadoop version %s does not match %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), String.format("Please configure %s to match the HDFS version.", PropertyKey.UNDERFS_VERSION.toString())); } HdfsVersionValidationTask(AlluxioConfiguration conf); }
HdfsVersionValidationTask extends AbstractValidationTask { @Override public ValidationTaskResult validateImpl(Map<String, String> optionMap) throws InterruptedException { String hadoopVersion; try { hadoopVersion = getHadoopVersion(); } catch (IOException e) { return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Failed to get hadoop version:%n%s.", ValidationUtils.getErrorInfo(e)), "Please check if hadoop is on your PATH."); } String version = mConf.get(PropertyKey.UNDERFS_VERSION); if (hadoopVersion.contains(version)) { return new ValidationTaskResult(ValidationUtils.State.OK, getName(), String.format("Hadoop version %s contains UFS version defined in alluxio %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), ""); } return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Hadoop version %s does not match %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), String.format("Please configure %s to match the HDFS version.", PropertyKey.UNDERFS_VERSION.toString())); } HdfsVersionValidationTask(AlluxioConfiguration conf); @Override String getName(); @Override ValidationTaskResult validateImpl(Map<String, String> optionMap); }
HdfsVersionValidationTask extends AbstractValidationTask { @Override public ValidationTaskResult validateImpl(Map<String, String> optionMap) throws InterruptedException { String hadoopVersion; try { hadoopVersion = getHadoopVersion(); } catch (IOException e) { return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Failed to get hadoop version:%n%s.", ValidationUtils.getErrorInfo(e)), "Please check if hadoop is on your PATH."); } String version = mConf.get(PropertyKey.UNDERFS_VERSION); if (hadoopVersion.contains(version)) { return new ValidationTaskResult(ValidationUtils.State.OK, getName(), String.format("Hadoop version %s contains UFS version defined in alluxio %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), ""); } return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(), String.format("Hadoop version %s does not match %s=%s.", hadoopVersion, PropertyKey.UNDERFS_VERSION.toString(), version), String.format("Please configure %s to match the HDFS version.", PropertyKey.UNDERFS_VERSION.toString())); } HdfsVersionValidationTask(AlluxioConfiguration conf); @Override String getName(); @Override ValidationTaskResult validateImpl(Map<String, String> optionMap);  }