当前位置: 首页>>代码示例>>Java>>正文


Java NMClient.createNMClient方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.client.api.NMClient.createNMClient方法的典型用法代码示例。如果您正苦于以下问题:Java NMClient.createNMClient方法的具体用法?Java NMClient.createNMClient怎么用?Java NMClient.createNMClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.client.api.NMClient的用法示例。


在下文中一共展示了NMClient.createNMClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SolrMaster

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public SolrMaster(CommandLine cli) throws Exception {
  this.cli = cli;
  Configuration hadoopConf = new Configuration();
  if (cli.hasOption("conf")) {
    hadoopConf.addResource(new Path(cli.getOptionValue("conf")));
    hadoopConf.reloadConfiguration();
  }
  conf = new YarnConfiguration(hadoopConf);

  nmClient = NMClient.createNMClient();
  nmClient.init(conf);
  nmClient.start();
  numContainersToWaitFor = Integer.parseInt(cli.getOptionValue("nodes"));
  memory = Integer.parseInt(cli.getOptionValue("memory", "512"));
  port = Integer.parseInt(cli.getOptionValue("port"));
  nextPort = port;

  SecureRandom random = new SecureRandom();
  this.randomStopKey = new BigInteger(130, random).toString(32);

  this.inetAddresses = getMyInetAddresses();
}
 
开发者ID:lucidworks,项目名称:yarn-proto,代码行数:23,代码来源:SolrMaster.java

示例2: StormAMRMClient

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public StormAMRMClient(ApplicationAttemptId appAttemptId,
                       @SuppressWarnings("rawtypes") Map storm_conf,
                       YarnConfiguration hadoopConf) {
  this.appAttemptId = appAttemptId;
  this.storm_conf = storm_conf;
  this.hadoopConf = hadoopConf;
  Integer pri = Utils.getInt(storm_conf.get(Config.MASTER_CONTAINER_PRIORITY));
  this.DEFAULT_PRIORITY.setPriority(pri);
  this.containers = new TreeSet<Container>();
  numSupervisors = new AtomicInteger(0);

  // start am nm client
  nmClient = (NMClientImpl) NMClient.createNMClient();
  nmClient.init(hadoopConf);
  nmClient.start();
}
 
开发者ID:yahoo,项目名称:storm-yarn,代码行数:17,代码来源:StormAMRMClient.java

示例3: testAMRMClientWithContainerResourceChange

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testAMRMClientWithContainerResourceChange()
    throws YarnException, IOException {
  AMRMClient<ContainerRequest> amClient = null;
  try {
    // start am rm client
    amClient = AMRMClient.createAMRMClient();
    Assert.assertNotNull(amClient);
    // asserting we are using the singleton instance cache
    Assert.assertSame(
        NMTokenCache.getSingleton(), amClient.getNMTokenCache());
    amClient.init(conf);
    amClient.start();
    assertEquals(STATE.STARTED, amClient.getServiceState());
    // start am nm client
    NMClientImpl nmClient = (NMClientImpl) NMClient.createNMClient();
    Assert.assertNotNull(nmClient);
    // asserting we are using the singleton instance cache
    Assert.assertSame(
        NMTokenCache.getSingleton(), nmClient.getNMTokenCache());
    nmClient.init(conf);
    nmClient.start();
    assertEquals(STATE.STARTED, nmClient.getServiceState());
    // am rm client register the application master with RM
    amClient.registerApplicationMaster("Host", 10000, "");
    // allocate three containers and make sure they are in RUNNING state
    List<Container> containers =
        allocateAndStartContainers(amClient, nmClient, 3);
    // perform container resource increase and decrease tests
    doContainerResourceChange(amClient, containers);
    // unregister and finish up the test
    amClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED,
        null, null);
  } finally {
    if (amClient != null && amClient.getServiceState() == STATE.STARTED) {
      amClient.stop();
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:40,代码来源:TestAMRMClient.java

示例4: launch

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
@Override
public void launch(int n, List<String> command, List<String> hosts,
    boolean verbose) throws Exception {
  final List<String> chmod = new ArrayList<String>();
  chmod.add("chmod");
  chmod.add("a+rx");
  chmod.add(System.getenv(Environment.LOG_DIRS.name()));
  final ProcessBuilder pb = new ProcessBuilder(chmod);
  pb.redirectOutput(Redirect.INHERIT);
  pb.redirectError(Redirect.INHERIT);
  pb.start();
  redirect(command); // TODO clone before mutating the command
  rmClient.init(conf);
  rmClient.start();
  final NMClient nmClient = NMClient.createNMClient();
  nmClient.init(conf);
  nmClient.start();
  rmClient.registerApplicationMaster("", 0, "");
  for (int i = 0; i < n; ++i) {
    final ContainerRequest request = new ContainerRequest(
        Resource.newInstance(256, 1), null, null, Priority.newInstance(0));
    rmClient.addContainerRequest(request);
  }
  int responseId = 0;
  for (int containers = 0; containers < n;) {
    final AllocateResponse response = rmClient.allocate(responseId++);
    for (final Container container : response.getAllocatedContainers()) {
      final ContainerLaunchContext ctx = ContainerLaunchContext
          .newInstance(null, null, command, null, null, null);
      nmClient.startContainer(container, ctx);
    }
    containers += response.getAllocatedContainers().size();
    try {
      Thread.sleep(100);
    } catch (final InterruptedException e) {
    }
  }
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:39,代码来源:Launcher.java

示例5: ApplicationMaster

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public ApplicationMaster() {
    this.allocatedContainerMap = new HashMap<String, Container>();
    this.sendQueue = new ArrayBlockingQueue<JSONObject>(512);
    this.configuration = new YarnConfiguration();
    this.defaultLocalRes = new HashMap<String, LocalResource>();
    this.nmClient = NMClient.createNMClient();
    this.nmClient.init(this.configuration);
    this.nmClient.start();
}
 
开发者ID:kazuki,项目名称:hadoop-yarn-appmaster-bridge,代码行数:10,代码来源:ApplicationMaster.java

示例6: start

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public void start() {
    if (client != null) {
        return;
    }

    client = NMClient.createNMClient("Elasticsearch-YARN");
    YarnCompat.setNMTokenCache(client, tokenCache);
    client.init(cfg);
    client.start();
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:11,代码来源:NodeMasterRpc.java

示例7: createAndStartNodeManagerClient

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
protected NMClient createAndStartNodeManagerClient(YarnConfiguration yarnConfiguration) {
	// create the client to communicate with the node managers
	NMClient nodeManagerClient = NMClient.createNMClient();
	nodeManagerClient.init(yarnConfiguration);
	nodeManagerClient.start();
	nodeManagerClient.cleanupRunningContainersOnStop(true);
	return nodeManagerClient;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:YarnResourceManager.java

示例8: YarnFlinkResourceManager

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public YarnFlinkResourceManager(
	Configuration flinkConfig,
	YarnConfiguration yarnConfig,
	LeaderRetrievalService leaderRetrievalService,
	String applicationMasterHostName,
	String webInterfaceURL,
	ContaineredTaskManagerParameters taskManagerParameters,
	ContainerLaunchContext taskManagerLaunchContext,
	int yarnHeartbeatIntervalMillis,
	int maxFailedContainers,
	int numInitialTaskManagers,
	YarnResourceManagerCallbackHandler callbackHandler) {

	this(
		flinkConfig,
		yarnConfig,
		leaderRetrievalService,
		applicationMasterHostName,
		webInterfaceURL,
		taskManagerParameters,
		taskManagerLaunchContext,
		yarnHeartbeatIntervalMillis,
		maxFailedContainers,
		numInitialTaskManagers,
		callbackHandler,
		AMRMClientAsync.createAMRMClientAsync(yarnHeartbeatIntervalMillis, callbackHandler),
		NMClient.createNMClient());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:29,代码来源:YarnFlinkResourceManager.java

示例9: StormAMRMClient

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public StormAMRMClient(ApplicationAttemptId appAttemptID, @SuppressWarnings("rawtypes") Map storm_conf,
		YarnConfiguration hadoopConf) {
	this.appAttemptId = appAttemptID;
    this.storm_conf = storm_conf;
    this.hadoopConf = hadoopConf;
    Integer pri = Utils.getInt(storm_conf.get(Config.MASTER_CONTAINER_PRIORITY));
    this.DEFAULT_PRIORITY.setPriority(pri);
    this.containers = new TreeSet<Container>();
    numSupervisors = new AtomicInteger(0);

    // start am nm client
    nmClient = (NMClientImpl) NMClient.createNMClient();
    nmClient.init(hadoopConf);
    nmClient.start();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:16,代码来源:StormAMRMClient.java

示例10: run

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public boolean run() throws IOException, YarnException {
  // Initialize clients to RM and NMs.
  LOG.info("ApplicationMaster::run");
  LOG.error("command: " + this.command);
  AMRMClientAsync.CallbackHandler rmListener = new RMCallbackHandler();
  resourceManager = AMRMClientAsync.createAMRMClientAsync(1000, rmListener);
  resourceManager.init(conf);
  resourceManager.start();

  nodeManager = NMClient.createNMClient();
  nodeManager.init(conf);
  nodeManager.start();

  // Register with RM
  resourceManager.registerApplicationMaster(appMasterHostname, appMasterRpcPort, appMasterTrackingUrl);


  // Ask RM to give us a bunch of containers
  for (int i = 0; i < totalContainerCount; i++) {
    ContainerRequest containerReq = setupContainerReqForRM();
    resourceManager.addContainerRequest(containerReq);
  }
  requestedContainerCount.addAndGet(totalContainerCount);

  while (!done) {
    try {
      Thread.sleep(200);
    } catch (InterruptedException ex) {
    }
  }// while

  // Un-register with ResourceManager
  resourceManager.unregisterApplicationMaster( FinalApplicationStatus.SUCCEEDED, "", "");
  return true;
}
 
开发者ID:DemandCube,项目名称:yarn-app,代码行数:36,代码来源:AbstractApplicationMaster.java

示例11: run

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public boolean run() throws IOException, YarnException {
  // Initialize clients to RM and NMs.
  LOG.info("ApplicationMaster::run");
  AMRMClientAsync.CallbackHandler rmListener = new RMCallbackHandler();
  resourceManager = AMRMClientAsync.createAMRMClientAsync(1000, rmListener);
  resourceManager.init(conf);
  resourceManager.start();
  
  nodeManager = NMClient.createNMClient();
  nodeManager.init(conf);
  nodeManager.start();
  
  // Register with RM
  resourceManager.registerApplicationMaster(appMasterHostname, appMasterRpcPort,
      appMasterTrackingUrl);

  Log.info("total container count: "+Integer.toString(totalContainerCount));
  
  // Ask RM to give us a bunch of containers
  //for (int i = 0; i < totalContainerCount; i++) {
    ContainerRequest containerReq = setupContainerReqForRM();
    resourceManager.addContainerRequest(containerReq);
  //}
  requestedContainerCount.addAndGet(totalContainerCount);

  while (!done) {
    try {
      Thread.sleep(200);
    } catch (InterruptedException ex) {
    }
  }// while

  // Un-register with ResourceManager
  resourceManager.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "", "");
  return true;
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:37,代码来源:AbstractApplicationMaster.java

示例12: onInit

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
@Inject
public void onInit(VMConfig vmConfig) throws Exception {
  logger.info("Start init(VMConfig vmConfig)");
  this.vmConfig = vmConfig;
  try {
    this.yarnConfig = vmConfig.getHadoopProperties();
    conf = new YarnConfiguration() ;
    vmConfig.overrideHadoopConfiguration(conf);
    
    amrmClient = AMRMClient.createAMRMClient();
    amrmClientAsync = AMRMClientAsync.createAMRMClientAsync(amrmClient, 1000, new AMRMCallbackHandler());
    amrmClientAsync.init(conf);
    amrmClientAsync.start();
    
    nmClient = NMClient.createNMClient();
    nmClient.init(conf);
    nmClient.start();
    // Register with RM
    String appHostName = InetAddress.getLocalHost().getHostAddress()  ;

    RegisterApplicationMasterResponse registerResponse = amrmClientAsync.registerApplicationMaster(appHostName, 0, "");
    System.out.println("amrmClientAsync.registerApplicationMaster");
  } catch(Throwable t) {
    logger.error("Error: " , t);
    t.printStackTrace();
  }
  logger.info("Finish init(VMConfig vmConfig)");
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:29,代码来源:YarnManager.java

示例13: ApplicationMasterAsync

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public ApplicationMasterAsync(String command, int numContainersToWaitFor) {
    this.command = command;
    configuration = new YarnConfiguration();
    this.numContainersToWaitFor = numContainersToWaitFor;
    nmClient = NMClient.createNMClient();
    nmClient.init(configuration);
    nmClient.start();
}
 
开发者ID:hortonworks,项目名称:simple-yarn-app,代码行数:9,代码来源:ApplicationMasterAsync.java

示例14: Hadoop21YarnNMClient

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public Hadoop21YarnNMClient(Configuration configuration) {
  this.nmClient = NMClient.createNMClient();
  nmClient.init(configuration);
}
 
开发者ID:apache,项目名称:twill,代码行数:5,代码来源:Hadoop21YarnNMClient.java

示例15: main

import org.apache.hadoop.yarn.client.api.NMClient; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

    String command = args[0];

    int argi = 0;

    for (argi=1; argi<args.length - 1; argi++) {
      command += " " + args[argi];
    }

    final int n = Integer.valueOf(args[argi]);

    // Initialize clients to ResourceManager and NodeManagers
    Configuration conf = new YarnConfiguration();

    AMRMClient<ContainerRequest> rmClient = AMRMClient.createAMRMClient();
    rmClient.init(conf);
    rmClient.start();

    NMClient nmClient = NMClient.createNMClient();
    nmClient.init(conf);
    nmClient.start();

    // Register with ResourceManager
    rmClient.registerApplicationMaster("", 0, "");
    
    // Priority for worker containers - priorities are intra-application
    Priority priority = Records.newRecord(Priority.class);
    priority.setPriority(0);

    // Resource requirements for worker containers
    Resource capability = Records.newRecord(Resource.class);
    capability.setMemory(128);
    capability.setVirtualCores(1);

    // Make container requests to ResourceManager
    for (int i=1; i <= n; i++) {
      ContainerRequest containerAsk = new ContainerRequest(capability, null, null, priority);
      System.out.println("=> Container Request " + i);
      rmClient.addContainerRequest(containerAsk);
    }

    // Obtain allocated containers and launch 
    int allocatedContainers = 0;
    while (allocatedContainers < n) {
      AllocateResponse response = rmClient.allocate(0);
      for (Container container : response.getAllocatedContainers()) {
        ++allocatedContainers;

        // Launch container by create ContainerLaunchContext
        ContainerLaunchContext ctx = 
            Records.newRecord(ContainerLaunchContext.class);
        ctx.setCommands(Collections.singletonList(
                command + 
                " >" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdouterr_am" + 
                " 2>&1"
                ));
        System.out.println("=> Launching Container " + allocatedContainers);
        nmClient.startContainer(container, ctx);
      }
      Thread.sleep(100);
    }

    // Now work with containers
    for (int container = 0; container < n; container++) {
      rmClient.allocate(0);
    }

    // Un-register with ResourceManager
    rmClient.unregisterApplicationMaster(
        FinalApplicationStatus.SUCCEEDED, "", "");
  }
 
开发者ID:nvijayap,项目名称:hadoop-yarn,代码行数:73,代码来源:ApplicationMaster.java


注:本文中的org.apache.hadoop.yarn.client.api.NMClient.createNMClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。