private static HdfsApi getHdfsApi(ViewContext context, ConfigurationBuilder configurationBuilder) throws HdfsApiException {
    HdfsApi api = null;
    AuthConfigurationBuilder authConfigurationBuilder = new AuthConfigurationBuilder(context);
    Map<String, String> authParams = authConfigurationBuilder.build();
    configurationBuilder.setAuthParams(authParams);
    try {
      api = new HdfsApi(configurationBuilder, getHdfsUsername(context));
      LOG.info("HdfsApi connected OK");
    } catch (IOException e) {
      LOG.error("exception occurred while creating hdfsApi objcet : {}", e.getMessage(), e);
      String message = "HDFS040 Couldn't open connection to HDFS";
      LOG.error(message);
      throw new HdfsApiException(message, e);
    } catch (InterruptedException e) {
      LOG.error("exception occurred while creating hdfsApi objcet : {}", e.getMessage(), e);
      String message = "HDFS041 Couldn't open connection to HDFS";
      LOG.error(message);
      throw new HdfsApiException(message, e);
    }
    return api;
  }
Factory of HdfsApi for specific ViewContext
@param context ViewContext that contains connection credentials
@return HdfsApi object
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/HdfsUtil.java