本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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, "");
}
示例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);
}
示例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();
}
示例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();
}
}
}
}
示例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());
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}