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


Java AMRMClientAsync.createAMRMClientAsync方法代码示例

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


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

示例1: testAMRMClientAsyncShutDown

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void testAMRMClientAsyncShutDown() throws Exception {
  Configuration conf = new Configuration();
  TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);

  createAllocateResponse(new ArrayList<ContainerStatus>(),
    new ArrayList<Container>(), null);
  when(client.allocate(anyFloat())).thenThrow(
    new ApplicationAttemptNotFoundException("app not found, shut down"));

  AMRMClientAsync<ContainerRequest> asyncClient =
      AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();

  asyncClient.registerApplicationMaster("localhost", 1234, null);

  Thread.sleep(50);

  verify(client, times(1)).allocate(anyFloat());
  asyncClient.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestAMRMClientAsync.java

示例2: testAMRMClientAsyncShutDown

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void testAMRMClientAsyncShutDown() throws Exception {
  Configuration conf = new Configuration();
  TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);

  final AllocateResponse shutDownResponse = createAllocateResponse(
      new ArrayList<ContainerStatus>(), new ArrayList<Container>(), null);
  shutDownResponse.setAMCommand(AMCommand.AM_SHUTDOWN);
  when(client.allocate(anyFloat())).thenReturn(shutDownResponse);

  AMRMClientAsync<ContainerRequest> asyncClient =
      AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();

  asyncClient.registerApplicationMaster("localhost", 1234, null);

  Thread.sleep(50);

  verify(client, times(1)).allocate(anyFloat());
  asyncClient.stop();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:25,代码来源:TestAMRMClientAsync.java

示例3: setupRMConnection

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
private RegisterApplicationMasterResponse setupRMConnection(String hostname, int rpcPort) throws Exception {
  AMRMClientAsync.AbstractCallbackHandler allocListener =
      new RMCallbackHandler();
  amRMClient = AMRMClientAsync.createAMRMClientAsync(1000, allocListener);
  amRMClient.init(conf);
  amRMClient.start();
  // Register self with ResourceManager
  // This will start heartbeating to the RM
  return amRMClient.registerApplicationMaster(hostname, rpcPort, "");
}
 
开发者ID:Intel-bigdata,项目名称:TensorFlowOnYARN,代码行数:11,代码来源:ApplicationMaster.java

示例4: runHeartBeatThrowOutException

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
private void runHeartBeatThrowOutException(Exception ex) throws Exception{
  Configuration conf = new Configuration();
  TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
  when(client.allocate(anyFloat())).thenThrow(ex);

  AMRMClientAsync<ContainerRequest> asyncClient =
      AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();
  
  synchronized (callbackHandler.notifier) {
    asyncClient.registerApplicationMaster("localhost", 1234, null);
    while(callbackHandler.savedException == null) {
      try {
        callbackHandler.notifier.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  Assert.assertTrue(callbackHandler.savedException.getMessage().contains(
      ex.getMessage()));
  
  asyncClient.stop();
  // stopping should have joined all threads and completed all callbacks
  Assert.assertTrue(callbackHandler.callbackCount == 0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestAMRMClientAsync.java

示例5: testAMRMClientAsyncShutDownWithWaitFor

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void testAMRMClientAsyncShutDownWithWaitFor() throws Exception {
  Configuration conf = new Configuration();
  final TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
  when(client.allocate(anyFloat())).thenThrow(
    new ApplicationAttemptNotFoundException("app not found, shut down"));

  AMRMClientAsync<ContainerRequest> asyncClient =
      AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();

  Supplier<Boolean> checker = new Supplier<Boolean>() {
    @Override
    public Boolean get() {
      return callbackHandler.reboot;
    }
  };

  asyncClient.registerApplicationMaster("localhost", 1234, null);
  asyncClient.waitFor(checker);

  asyncClient.stop();
  // stopping should have joined all threads and completed all callbacks
  Assert.assertTrue(callbackHandler.callbackCount == 0);

  verify(client, times(1)).allocate(anyFloat());
  asyncClient.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:TestAMRMClientAsync.java

示例6: testCallAMRMClientAsyncStopFromCallbackHandler

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 5000)
public void testCallAMRMClientAsyncStopFromCallbackHandler()
    throws YarnException, IOException, InterruptedException {
  Configuration conf = new Configuration();
  TestCallbackHandler2 callbackHandler = new TestCallbackHandler2();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);

  List<ContainerStatus> completed = Arrays.asList(
      ContainerStatus.newInstance(newContainerId(0, 0, 0, 0),
          ContainerState.COMPLETE, "", 0));
  final AllocateResponse response = createAllocateResponse(completed,
      new ArrayList<Container>(), null);

  when(client.allocate(anyFloat())).thenReturn(response);

  AMRMClientAsync<ContainerRequest> asyncClient =
      AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
  callbackHandler.asynClient = asyncClient;
  asyncClient.init(conf);
  asyncClient.start();

  synchronized (callbackHandler.notifier) {
    asyncClient.registerApplicationMaster("localhost", 1234, null);
    while(callbackHandler.notify == false) {
      try {
        callbackHandler.notifier.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:TestAMRMClientAsync.java

示例7: testCallAMRMClientAsyncStopFromCallbackHandlerWithWaitFor

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 5000)
public void testCallAMRMClientAsyncStopFromCallbackHandlerWithWaitFor()
    throws YarnException, IOException, InterruptedException {
  Configuration conf = new Configuration();
  final TestCallbackHandler2 callbackHandler = new TestCallbackHandler2();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);

  List<ContainerStatus> completed = Arrays.asList(
      ContainerStatus.newInstance(newContainerId(0, 0, 0, 0),
          ContainerState.COMPLETE, "", 0));
  final AllocateResponse response = createAllocateResponse(completed,
      new ArrayList<Container>(), null);

  when(client.allocate(anyFloat())).thenReturn(response);

  AMRMClientAsync<ContainerRequest> asyncClient =
      AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
  callbackHandler.asynClient = asyncClient;
  asyncClient.init(conf);
  asyncClient.start();

  Supplier<Boolean> checker = new Supplier<Boolean>() {
    @Override
    public Boolean get() {
      return callbackHandler.notify;
    }
  };

  asyncClient.registerApplicationMaster("localhost", 1234, null);
  asyncClient.waitFor(checker);
  Assert.assertTrue(checker.get());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:TestAMRMClientAsync.java

示例8: createAndStartResourceManagerClient

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
protected AMRMClientAsync<AMRMClient.ContainerRequest> createAndStartResourceManagerClient(
		YarnConfiguration yarnConfiguration,
		int yarnHeartbeatIntervalMillis,
		@Nullable String webInterfaceUrl) throws Exception {
	AMRMClientAsync<AMRMClient.ContainerRequest> resourceManagerClient = AMRMClientAsync.createAMRMClientAsync(
		yarnHeartbeatIntervalMillis,
		this);

	resourceManagerClient.init(yarnConfiguration);
	resourceManagerClient.start();

	//TODO: change akka address to tcp host and port, the getAddress() interface should return a standard tcp address
	Tuple2<String, Integer> hostPort = parseHostPort(getAddress());

	final int restPort;

	if (webInterfaceUrl != null) {
		final int lastColon = webInterfaceUrl.lastIndexOf(':');

		if (lastColon == -1) {
			restPort = -1;
		} else {
			restPort = Integer.valueOf(webInterfaceUrl.substring(lastColon + 1));
		}
	} else {
		restPort = -1;
	}

	resourceManagerClient.registerApplicationMaster(hostPort.f0, restPort, webInterfaceUrl);

	return resourceManagerClient;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:YarnResourceManager.java

示例9: YarnFlinkResourceManager

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的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

示例10: startUp

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Override
protected void startUp() throws IOException {
 this.containerAllocation = new HashMap<ContainerId, ContainerTracker>();
  this.resourceManager = AMRMClientAsync.createAMRMClientAsync(1000, this);
  this.resourceManager.init(conf);
  this.resourceManager.start();

  RegisterApplicationMasterResponse registration;
  try {
    registration = resourceManager.registerApplicationMaster(
        parameters.getHostname(),
        parameters.getClientPort(),
        parameters.getTrackingUrl());
  } catch (Exception e) {
    LOG.error("Exception thrown registering application master", e);
    stop();
    return;
  }

  factory = new ContainerLaunchContextFactory(
      registration.getMaximumResourceCapability());
  for (ContainerLaunchParameters clp : parameters.getContainerLaunchParameters().values()) {
    ContainerTracker tracker = new ContainerTracker(clp);
    tracker.init(factory);
    trackers.add(tracker);
  }
  /*ContainerTracker prevTracker = trackers.get(0);
  int i=0;
  for(ContainerTracker t:trackers){
  	if(i>0)
  		prevTracker.addNextTracker(t);
  	i++;
  }
  trackers.get(0).init(factory);
  */
  this.hasRunningContainers = true;
}
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:38,代码来源:ApplicationMasterServiceImpl1.java

示例11: testAMRMClientAsyncException

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test(timeout=10000)
public void testAMRMClientAsyncException() throws Exception {
  Configuration conf = new Configuration();
  TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
  String exStr = "TestException";
  YarnException mockException = mock(YarnException.class);
  when(mockException.getMessage()).thenReturn(exStr);
  when(client.allocate(anyFloat())).thenThrow(mockException);

  AMRMClientAsync<ContainerRequest> asyncClient = 
      AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();
  
  synchronized (callbackHandler.notifier) {
    asyncClient.registerApplicationMaster("localhost", 1234, null);
    while(callbackHandler.savedException == null) {
      try {
        callbackHandler.notifier.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  
  Assert.assertTrue(callbackHandler.savedException.getMessage().contains(exStr));
  
  asyncClient.stop();
  // stopping should have joined all threads and completed all callbacks
  Assert.assertTrue(callbackHandler.callbackCount == 0);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:34,代码来源:TestAMRMClientAsync.java

示例12: testAMRMClientAsyncReboot

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test//(timeout=10000)
public void testAMRMClientAsyncReboot() throws Exception {
  Configuration conf = new Configuration();
  TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
  
  final AllocateResponse rebootResponse = createAllocateResponse(
      new ArrayList<ContainerStatus>(), new ArrayList<Container>(), null);
  rebootResponse.setAMCommand(AMCommand.AM_RESYNC);
  when(client.allocate(anyFloat())).thenReturn(rebootResponse);
  
  AMRMClientAsync<ContainerRequest> asyncClient = 
      AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();
  
  synchronized (callbackHandler.notifier) {
    asyncClient.registerApplicationMaster("localhost", 1234, null);
    while(callbackHandler.reboot == false) {
      try {
        callbackHandler.notifier.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  
  asyncClient.stop();
  // stopping should have joined all threads and completed all callbacks
  Assert.assertTrue(callbackHandler.callbackCount == 0);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:33,代码来源:TestAMRMClientAsync.java

示例13: run

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
public void run() throws YarnException, IOException {
	amRMClient = AMRMClientAsync.createAMRMClientAsync(1000, new RMCallbackHandler());
	amRMClient.init(conf);
	amRMClient.start();
	
	RegisterApplicationMasterResponse response;
	response = amRMClient.registerApplicationMaster(NetUtils.getHostname(), -1, "");
	LOG.info("ApplicationMaster is registered with response: {}", response.toString());
	
	Resource capacity = Records.newRecord(Resource.class);
	capacity.setMemory(128);
	Priority priority = Records.newRecord(Priority.class);
	priority.setPriority(0);
	for(int i = 1; i <= 5; i++) {
		ContainerRequest ask = new ContainerRequest(capacity,null, null,priority);
		amRMClient.addContainerRequest(ask);
		numOfContainers++;
	}
	
	try {
		Thread.sleep(120000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	
	amRMClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "Application complete!", null);
	amRMClient.stop();
	
}
 
开发者ID:HortonworksUniversity,项目名称:YARN_Rev2,代码行数:30,代码来源:ApplicationMaster.java

示例14: runHeartBeatThrowOutException

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
private void runHeartBeatThrowOutException(Exception ex) throws Exception{
  Configuration conf = new Configuration();
  TestCallbackHandler callbackHandler = new TestCallbackHandler();
  @SuppressWarnings("unchecked")
  AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
  when(client.allocate(anyFloat())).thenThrow(ex);

  AMRMClientAsync<ContainerRequest> asyncClient = 
      AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
  asyncClient.init(conf);
  asyncClient.start();
  
  synchronized (callbackHandler.notifier) {
    asyncClient.registerApplicationMaster("localhost", 1234, null);
    while(callbackHandler.savedException == null) {
      try {
        callbackHandler.notifier.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  Assert.assertTrue(callbackHandler.savedException.getMessage().contains(
      ex.getMessage()));
  
  asyncClient.stop();
  // stopping should have joined all threads and completed all callbacks
  Assert.assertTrue(callbackHandler.callbackCount == 0);
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:30,代码来源:TestAMRMClientAsync.java

示例15: run

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
public void run() throws Exception {
  int virtualCores = Integer.parseInt(cli.getOptionValue("virtualCores", "1"));

  AMRMClientAsync<ContainerRequest> rmClient = AMRMClientAsync.createAMRMClientAsync(100, this);
  rmClient.init(getConfiguration());
  rmClient.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(memory);
  capability.setVirtualCores(virtualCores);

  // Make container requests to ResourceManager
  for (int i = 0; i < numContainersToWaitFor; ++i)
    rmClient.addContainerRequest(new ContainerRequest(capability, null, null, priority));

  log.info("Waiting for " + numContainersToWaitFor + " containers to finish");
  while (!doneWithContainers())
    Thread.sleep(10000);

  log.info("SolrMaster application shutdown.");

  // Un-register with ResourceManager
  try {
    rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "", "");
  } catch (Exception exc) {
    // safe to ignore ... this usually fails anyway
  }
}
 
开发者ID:lucidworks,项目名称:yarn-proto,代码行数:37,代码来源:SolrMaster.java


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