當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration.addDefaultResource方法代碼示例

本文整理匯總了Java中org.apache.hadoop.conf.Configuration.addDefaultResource方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.addDefaultResource方法的具體用法?Java Configuration.addDefaultResource怎麽用?Java Configuration.addDefaultResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.conf.Configuration的用法示例。


在下文中一共展示了Configuration.addDefaultResource方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addNewConfigResource

import org.apache.hadoop.conf.Configuration; //導入方法依賴的package包/類
private void addNewConfigResource(String rsrcName, String keyGroup,
    String groups, String keyHosts, String hosts)
        throws FileNotFoundException, UnsupportedEncodingException {
  // location for temp resource should be in CLASSPATH
  Configuration conf = new Configuration();
  URL url = conf.getResource("hdfs-site.xml");

  String urlPath = URLDecoder.decode(url.getPath().toString(), "UTF-8");
  Path p = new Path(urlPath);
  Path dir = p.getParent();
  tempResource = dir.toString() + "/" + rsrcName;

  String newResource =
  "<configuration>"+
  "<property><name>" + keyGroup + "</name><value>"+groups+"</value></property>" +
  "<property><name>" + keyHosts + "</name><value>"+hosts+"</value></property>" +
  "</configuration>";
  PrintWriter writer = new PrintWriter(new FileOutputStream(tempResource));
  writer.println(newResource);
  writer.close();

  Configuration.addDefaultResource(rsrcName);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:TestRefreshUserMappings.java

示例2: setUpResourceManager

import org.apache.hadoop.conf.Configuration; //導入方法依賴的package包/類
/**
 * Start resource manager server
 */

@BeforeClass
public static void setUpResourceManager() throws IOException,
        InterruptedException {
  Configuration.addDefaultResource("config-with-security.xml");
  Configuration configuration = new YarnConfiguration();
  resourceManager = new ResourceManager() {
    @Override
    protected void doSecureLogin() throws IOException {
    }
  };
  resourceManager.init(configuration);
  new Thread() {
    public void run() {
      resourceManager.start();
    }
  }.start();
  int waitCount = 0;
  while (resourceManager.getServiceState() == STATE.INITED
          && waitCount++ < 10) {
    LOG.info("Waiting for RM to start...");
    Thread.sleep(1000);
  }
  if (resourceManager.getServiceState() != STATE.STARTED) {
    throw new IOException("ResourceManager failed to start. Final state is "
            + resourceManager.getServiceState());
  }
  LOG.info("ResourceManager RMAdmin address: "
          + configuration.get(YarnConfiguration.RM_ADMIN_ADDRESS));

  client = new ResourceManagerAdministrationProtocolPBClientImpl(1L,
          getProtocolAddress(configuration), configuration);

}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:38,代碼來源:TestResourceManagerAdministrationProtocolPBClientImpl.java

示例3: loadResources

import org.apache.hadoop.conf.Configuration; //導入方法依賴的package包/類
/**
 * Adds all the deprecated keys. Loads mapred-default.xml and mapred-site.xml
 */
public static void loadResources() {
  addDeprecatedKeys();
  Configuration.addDefaultResource("mapred-default.xml");
  Configuration.addDefaultResource("mapred-site.xml");
  Configuration.addDefaultResource("yarn-default.xml");
  Configuration.addDefaultResource("yarn-site.xml");
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:11,代碼來源:ConfigUtil.java

示例4: run

import org.apache.hadoop.conf.Configuration; //導入方法依賴的package包/類
@Override
public int run(String[] argv) throws Exception {
  List<String> args = new LinkedList<>(Arrays.asList(argv));
  String keytabName = popOptionWithArgument(ARG_KEYTAB, args);
  if (keytabName != null) {
    keytab = new File(keytabName);
  }
  principal = popOptionWithArgument(ARG_PRINCIPAL, args);
  String outf = popOptionWithArgument(ARG_OUTPUT, args);
  String mkl = popOptionWithArgument(ARG_KEYLEN, args);
  if (mkl != null) {
    minKeyLength = Integer.parseInt(mkl);
  }
  securityRequired = popOption(ARG_SECURE, args);
  nofail = popOption(ARG_NOFAIL, args);
  jaas = popOption(ARG_JAAS, args);
  nologin = popOption(ARG_NOLOGIN, args);
  checkShortName = popOption(ARG_VERIFYSHORTNAME, args);

  // look for list of resources
  String resource;
  while (null != (resource = popOptionWithArgument(ARG_RESOURCE, args))) {
    // loading a resource
    LOG.info("Loading resource {}", resource);
    try (InputStream in =
             getClass().getClassLoader().getResourceAsStream(resource)) {
      if (verify(in != null, CAT_CONFIG, "No resource %s", resource)) {
        Configuration.addDefaultResource(resource);
      }
    }
  }
  // look for any leftovers
  if (!args.isEmpty()) {
    println("Unknown arguments in command:");
    for (String s : args) {
      println("  \"%s\"", s);
    }
    println();
    println(usage());
    return -1;
  }
  if (outf != null) {
    println("Printing output to %s", outf);
    out = new PrintWriter(new File(outf), "UTF-8");
  }
  execute();
  return probeHasFailed ? KDIAG_FAILURE : 0;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:49,代碼來源:KDiag.java

示例5: setUp

import org.apache.hadoop.conf.Configuration; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  Configuration.addDefaultResource("hdfs-site.malformed.xml");
  config = new Configuration();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:6,代碼來源:TestMalformedURLs.java


注:本文中的org.apache.hadoop.conf.Configuration.addDefaultResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。