当前位置: 首页>>代码示例>>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;未经允许,请勿转载。