Example usage for org.apache.hadoop.yarn.conf YarnConfiguration setSocketAddr

List of usage examples for org.apache.hadoop.yarn.conf YarnConfiguration setSocketAddr

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.conf YarnConfiguration setSocketAddr.

Prototype

public void setSocketAddr(String name, InetSocketAddress addr) 

Source Link

Document

Set the socket address for the name property as a host:port.

Usage

From source file:base.test.HelloWorld.java

License:Apache License

public static void main(String[] args) {
    if (args.length < 1) {
        System.err.println("Arguments format: <host:port of zookeeper server>");
        System.exit(1);/*from  w  w w .  j  a  v  a2s  .c  om*/
    }

    String zkStr = args[0];
    YarnConfiguration yarnConfiguration = new YarnConfiguration();
    yarnConfiguration.setSocketAddr("yarn.resourcemanager.address",
            new InetSocketAddress("192.168.80.103", 8032));
    final TwillRunnerService twillRunner = new YarnTwillRunnerService(yarnConfiguration, zkStr);
    twillRunner.start();

    String yarnClasspath = yarnConfiguration.get(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
            Joiner.on(",").join(YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH));
    List<String> applicationClassPaths = Lists.newArrayList();
    Iterables.addAll(applicationClassPaths, Splitter.on(",").split(yarnClasspath));
    final TwillController controller = twillRunner.prepare(new HelloWorldRunnable())
            .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
            .withApplicationClassPaths(applicationClassPaths)
            .withBundlerClassAcceptor(new HadoopClassExcluder()).start();

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                Futures.getUnchecked(controller.terminate());
            } finally {
                twillRunner.stop();
            }
        }
    });

    try {
        controller.awaitTerminated();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}