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


Java AMRMClientAsync类代码示例

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


AMRMClientAsync类属于org.apache.hadoop.yarn.client.api.async包,在下文中一共展示了AMRMClientAsync类的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: TestingYarnFlinkResourceManager

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入依赖的package包/类
public TestingYarnFlinkResourceManager(
	Configuration flinkConfig,
	YarnConfiguration yarnConfig,
	LeaderRetrievalService leaderRetrievalService,
	String applicationMasterHostName,
	String webInterfaceURL,
	ContaineredTaskManagerParameters taskManagerParameters,
	ContainerLaunchContext taskManagerLaunchContext,
	int yarnHeartbeatIntervalMillis,
	int maxFailedContainers,
	int numInitialTaskManagers,
	YarnResourceManagerCallbackHandler callbackHandler,
	AMRMClientAsync<AMRMClient.ContainerRequest> resourceManagerClient,
	NMClient nodeManagerClient) {
	super(flinkConfig, yarnConfig, leaderRetrievalService, applicationMasterHostName, webInterfaceURL, taskManagerParameters, taskManagerLaunchContext, yarnHeartbeatIntervalMillis, maxFailedContainers, numInitialTaskManagers, callbackHandler, resourceManagerClient, nodeManagerClient);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:TestingYarnFlinkResourceManager.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: mockAMRMClientAsync

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private void mockAMRMClientAsync() throws YarnException, IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
  amRMClientAsync = mock(AMRMClientAsync.class);
  doNothing().when(amRMClientAsync).addContainerRequest(Matchers.any(AMRMClient.ContainerRequest.class));

  Field amRMClientAsyncField = containerAllocator.getClass().getDeclaredField("amRMClientAsync");
  amRMClientAsyncField.setAccessible(true);
  amRMClientAsyncField.set(containerAllocator, amRMClientAsync);
}
 
开发者ID:intel-hadoop,项目名称:yacop,代码行数:10,代码来源:TestContainerAllocator.java

示例10: 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

示例11: 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

示例12: TestingYarnResourceManager

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入依赖的package包/类
public TestingYarnResourceManager(
		RpcService rpcService,
		String resourceManagerEndpointId,
		ResourceID resourceId,
		Configuration flinkConfig,
		Map<String, String> env,
		ResourceManagerConfiguration resourceManagerConfiguration,
		HighAvailabilityServices highAvailabilityServices,
		HeartbeatServices heartbeatServices,
		SlotManager slotManager,
		MetricRegistry metricRegistry,
		JobLeaderIdService jobLeaderIdService,
		FatalErrorHandler fatalErrorHandler,
		@Nullable String webInterfaceUrl,
		AMRMClientAsync<AMRMClient.ContainerRequest> mockResourceManagerClient,
		NMClient mockNMClient) {
	super(
		rpcService,
		resourceManagerEndpointId,
		resourceId,
		flinkConfig,
		env,
		resourceManagerConfiguration,
		highAvailabilityServices,
		heartbeatServices,
		slotManager,
		metricRegistry,
		jobLeaderIdService,
		fatalErrorHandler,
		webInterfaceUrl);
	this.mockNMClient = mockNMClient;
	this.mockResourceManagerClient = mockResourceManagerClient;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:34,代码来源:YarnResourceManagerTest.java

示例13: createAndStartResourceManagerClient

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入依赖的package包/类
@Override
protected AMRMClientAsync<AMRMClient.ContainerRequest> createAndStartResourceManagerClient(
		YarnConfiguration yarnConfiguration,
		int yarnHeartbeatIntervalMillis,
		@Nullable String webInteraceUrl) {
	return mockResourceManagerClient;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:YarnResourceManagerTest.java

示例14: YarnService

import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入依赖的package包/类
public YarnService(Config config, String applicationName, ApplicationId applicationId, FileSystem fs,
    EventBus eventBus, String containerJvmArgs) throws Exception {
  this.applicationName = applicationName;
  this.applicationId = applicationId;

  this.config = config;

  this.yarnConfiguration = new YarnConfiguration();
  this.amrmClientAsync = closer.register(
      AMRMClientAsync.createAMRMClientAsync(1000, new AMRMClientCallbackHandler()));
  this.amrmClientAsync.init(this.yarnConfiguration);
  this.nmClientAsync = closer.register(NMClientAsync.createNMClientAsync(new NMClientCallbackHandler()));
  this.nmClientAsync.init(this.yarnConfiguration);

  this.containerLaunchExecutor = Executors.newFixedThreadPool(10,
      ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("ContainerLaunchExecutor")));

  this.fs = fs;

  this.eventBus = eventBus;

  this.initialContainers = config.getInt(GobblinYarnConfigurationKeys.INITIAL_CONTAINERS_KEY);
  this.requestedContainerMemoryMbs = config.getInt(GobblinYarnConfigurationKeys.CONTAINER_MEMORY_MBS_KEY);
  this.requestedContainerCores = config.getInt(GobblinYarnConfigurationKeys.CONTAINER_CORES_KEY);

  this.containerJvmArgs = containerJvmArgs;

  this.tokens = getSecurityTokens();
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:30,代码来源:YarnService.java

示例15: 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


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