org.apache.hadoop.yarn.client.api.async.AMRMClientAsync Java Examples
The following examples show how to use
org.apache.hadoop.yarn.client.api.async.AMRMClientAsync.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestAMRMClientAsync.java From big-c with Apache License 2.0 | 6 votes |
@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(); }
Example #2
Source File: TestYarnClusterResourceManager.java From samza with Apache License 2.0 | 6 votes |
@Test public void testAllocatedResourceExpiryForYarn() { YarnConfiguration yarnConfiguration = mock(YarnConfiguration.class); SamzaAppMasterMetrics metrics = mock(SamzaAppMasterMetrics.class); Config config = mock(Config.class); AMRMClientAsync asyncClient = mock(AMRMClientAsync.class); YarnAppState yarnAppState = new YarnAppState(0, mock(ContainerId.class), "host", 8080, 8081); SamzaYarnAppMasterLifecycle lifecycle = mock(SamzaYarnAppMasterLifecycle.class); SamzaYarnAppMasterService service = mock(SamzaYarnAppMasterService.class); NMClientAsync asyncNMClient = mock(NMClientAsync.class); ClusterResourceManager.Callback callback = mock(ClusterResourceManager.Callback.class); // start the cluster manager YarnClusterResourceManager yarnClusterResourceManager = new YarnClusterResourceManager(asyncClient, asyncNMClient, callback, yarnAppState, lifecycle, service, metrics, yarnConfiguration, config); SamzaResource allocatedResource = mock(SamzaResource.class); when(allocatedResource.getTimestamp()).thenReturn(System.currentTimeMillis() - Duration.ofMinutes(10).toMillis()); Assert.assertTrue(yarnClusterResourceManager.isResourceExpired(allocatedResource)); }
Example #3
Source File: TestAMRMClientAsync.java From hadoop with Apache License 2.0 | 6 votes |
@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(); }
Example #4
Source File: TestAMRMClientAsync.java From big-c with Apache License 2.0 | 5 votes |
@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()); }
Example #5
Source File: YarnResourceManagerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
TestingYarnResourceManager( RpcService rpcService, String resourceManagerEndpointId, ResourceID resourceId, Configuration flinkConfig, Map<String, String> env, HighAvailabilityServices highAvailabilityServices, HeartbeatServices heartbeatServices, SlotManager slotManager, MetricRegistry metricRegistry, JobLeaderIdService jobLeaderIdService, ClusterInformation clusterInformation, FatalErrorHandler fatalErrorHandler, @Nullable String webInterfaceUrl, AMRMClientAsync<AMRMClient.ContainerRequest> mockResourceManagerClient, NMClient mockNMClient, JobManagerMetricGroup jobManagerMetricGroup) { super( rpcService, resourceManagerEndpointId, resourceId, flinkConfig, env, highAvailabilityServices, heartbeatServices, slotManager, metricRegistry, jobLeaderIdService, clusterInformation, fatalErrorHandler, webInterfaceUrl, jobManagerMetricGroup); this.mockNMClient = mockNMClient; this.mockResourceManagerClient = mockResourceManagerClient; }
Example #6
Source File: YarnClusterResourceManager.java From samza with Apache License 2.0 | 5 votes |
YarnClusterResourceManager(AMRMClientAsync amClientAsync, NMClientAsync nmClientAsync, Callback callback, YarnAppState yarnAppState, SamzaYarnAppMasterLifecycle lifecycle, SamzaYarnAppMasterService service, SamzaAppMasterMetrics metrics, YarnConfiguration yarnConfiguration, Config config) { super(callback); this.yarnConfiguration = yarnConfiguration; this.metrics = metrics; this.yarnConfig = new YarnConfig(config); this.config = config; this.amClient = amClientAsync; this.state = yarnAppState; this.lifecycle = lifecycle; this.service = service; this.nmClientAsync = nmClientAsync; }
Example #7
Source File: TestYarnClusterResourceManager.java From samza with Apache License 2.0 | 5 votes |
@Test public void testErrorInStartContainerShouldUpdateState() { // create mocks final int samzaContainerId = 1; YarnConfiguration yarnConfiguration = mock(YarnConfiguration.class); SamzaAppMasterMetrics metrics = mock(SamzaAppMasterMetrics.class); Config config = mock(Config.class); AMRMClientAsync asyncClient = mock(AMRMClientAsync.class); YarnAppState yarnAppState = new YarnAppState(0, mock(ContainerId.class), "host", 8080, 8081); SamzaYarnAppMasterLifecycle lifecycle = mock(SamzaYarnAppMasterLifecycle.class); SamzaYarnAppMasterService service = mock(SamzaYarnAppMasterService.class); NMClientAsync asyncNMClient = mock(NMClientAsync.class); ClusterResourceManager.Callback callback = mock(ClusterResourceManager.Callback.class); // start the cluster manager YarnClusterResourceManager yarnClusterResourceManager = new YarnClusterResourceManager(asyncClient, asyncNMClient, callback, yarnAppState, lifecycle, service, metrics, yarnConfiguration, config); yarnAppState.pendingProcessors.put(String.valueOf(samzaContainerId), new YarnContainer(Container.newInstance( ContainerId.newContainerId( ApplicationAttemptId.newInstance( ApplicationId.newInstance(10000L, 1), 1), 1), NodeId.newInstance("host1", 8088), "http://host1", Resource.newInstance(1024, 1), Priority.newInstance(1), Token.newInstance("id".getBytes(), "read", "password".getBytes(), "service")))); yarnClusterResourceManager.start(); assertEquals(1, yarnAppState.pendingProcessors.size()); yarnClusterResourceManager.onStartContainerError(ContainerId.newContainerId( ApplicationAttemptId.newInstance( ApplicationId.newInstance(10000L, 1), 1), 1), new Exception()); assertEquals(0, yarnAppState.pendingProcessors.size()); verify(callback, times(1)).onStreamProcessorLaunchFailure(anyObject(), any(Exception.class)); }
Example #8
Source File: ContainerRequestListener.java From metron with Apache License 2.0 | 5 votes |
public void initialize(AMRMClientAsync<AMRMClient.ContainerRequest> amRMClient , NMClientAsync nmClient , ServiceDiscoverer serviceDiscoverer ) { this.nmClient = nmClient; this.amRMClient = amRMClient; this.serviceDiscoverer = serviceDiscoverer; }
Example #9
Source File: YarnResourceManager.java From flink with Apache License 2.0 | 5 votes |
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; } final RegisterApplicationMasterResponse registerApplicationMasterResponse = resourceManagerClient.registerApplicationMaster(hostPort.f0, restPort, webInterfaceUrl); getContainersFromPreviousAttempts(registerApplicationMasterResponse); updateMatchingStrategy(registerApplicationMasterResponse); return resourceManagerClient; }
Example #10
Source File: YarnResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected AMRMClientAsync<AMRMClient.ContainerRequest> createAndStartResourceManagerClient( YarnConfiguration yarnConfiguration, int yarnHeartbeatIntervalMillis, @Nullable String webInterfaceUrl) { return testingYarnAMRMClientAsync; }
Example #11
Source File: YarnContainerManager.java From reef with Apache License 2.0 | 5 votes |
@Inject private YarnContainerManager( @Parameter(YarnHeartbeatPeriod.class) final int yarnRMHeartbeatPeriod, @Parameter(JobSubmissionDirectory.class) final String jobSubmissionDirectory, final YarnConfiguration yarnConf, final YarnProxyUser yarnProxyUser, final REEFEventHandlers reefEventHandlers, final Containers containers, final ApplicationMasterRegistration registration, final ContainerRequestCounter containerRequestCounter, final DriverStatusManager driverStatusManager, final REEFFileNames reefFileNames, final TrackingURLProvider trackingURLProvider, final LocalAddressProvider addressProvider, final RackNameFormatter rackNameFormatter, final InjectionFuture<ProgressProvider> progressProvider) throws IOException { this.reefEventHandlers = reefEventHandlers; this.driverStatusManager = driverStatusManager; this.containers = containers; this.registration = registration; this.containerRequestCounter = containerRequestCounter; this.yarnConf = yarnConf; this.yarnProxyUser = yarnProxyUser; this.rackNameFormatter = rackNameFormatter; this.trackingUrl = trackingURLProvider.getTrackingUrl(); this.amRegistrationHost = addressProvider.getLocalAddress(); this.resourceManager = AMRMClientAsync.createAMRMClientAsync(yarnRMHeartbeatPeriod, this); this.nodeManager = new NMClientAsyncImpl(this); this.jobSubmissionDirectory = jobSubmissionDirectory; this.reefFileNames = reefFileNames; this.progressProvider = progressProvider; LOG.log(Level.INFO, "Instantiated YarnContainerManager: {0} {1}, trackingUrl: {3}, jobSubmissionDirectory: {4}.", new Object[] {this.registration, this.yarnProxyUser, this.trackingUrl, this.jobSubmissionDirectory}); }
Example #12
Source File: SolrMaster.java From yarn-proto with Apache License 2.0 | 5 votes |
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 } }
Example #13
Source File: AbstractApplicationMaster.java From Scribengin with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example #14
Source File: YarnManager.java From Scribengin with GNU Affero General Public License v3.0 | 5 votes |
@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)"); }
Example #15
Source File: OlapServerMaster.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private void runNonKerberized(Configuration conf) throws Exception { // Original user has the YARN tokens UserGroupInformation original = UserGroupInformation.getCurrentUser(); String user = System.getProperty("splice.spark.yarn.user", "hbase"); LOG.info("Login with user"); ugi = UserGroupInformation.createRemoteUser(user); Collection<Token<? extends TokenIdentifier>> tokens = UserGroupInformation.getCurrentUser().getCredentials().getAllTokens(); for (Token<? extends TokenIdentifier> token : tokens) { LOG.debug("Token kind is " + token.getKind().toString() + " and the token's service name is " + token.getService()); if (AMRMTokenIdentifier.KIND_NAME.equals(token.getKind())) { ugi.addToken(token); } } // Transfer tokens from original user to the one we'll use from now on SparkHadoopUtil.get().transferCredentials(original, ugi); UserGroupInformation.isSecurityEnabled(); if (mode == Mode.YARN) { rmClient = ugi.doAs(new PrivilegedExceptionAction<AMRMClientAsync<AMRMClient.ContainerRequest>>() { @Override public AMRMClientAsync<AMRMClient.ContainerRequest> run() throws Exception { return initClient(conf); } }); LOG.info("Registered with Resource Manager"); } }
Example #16
Source File: OlapServerMaster.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private AMRMClientAsync<AMRMClient.ContainerRequest> initClient(Configuration conf) throws YarnException, IOException { AMRMClientAsync.CallbackHandler allocListener = new AMRMClientAsync.CallbackHandler() { @Override public void onContainersCompleted(List<ContainerStatus> statuses) { } @Override public void onContainersAllocated(List<Container> containers) { } @Override public void onShutdownRequest() { LOG.warn("Shutting down"); end.set(true); } @Override public void onNodesUpdated(List<NodeReport> updatedNodes) { } @Override public float getProgress() { return 0; } @Override public void onError(Throwable e) { LOG.error("Unexpected error", e); end.set(true); } }; AMRMClientAsync<AMRMClient.ContainerRequest> rmClient = AMRMClientAsync.createAMRMClientAsync(1000, allocListener); rmClient.init(conf); rmClient.start(); // Register with ResourceManager rmClient.registerApplicationMaster(Utils.localHostName(), 0, ""); return rmClient; }
Example #17
Source File: TestTezAMRMClient.java From tez with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Before public void setup() { amrmClient = new TezAMRMClientAsync(new AMRMClientImpl(), 1000, mock(AMRMClientAsync.CallbackHandler.class)); RackResolver.init(new Configuration()); }
Example #18
Source File: TestAMRMClientAsync.java From hadoop with Apache License 2.0 | 5 votes |
@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()); }
Example #19
Source File: ApplicationMaster.java From TensorFlowOnYARN with Apache License 2.0 | 5 votes |
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, ""); }
Example #20
Source File: TestAMRMClientAsync.java From hadoop with Apache License 2.0 | 5 votes |
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); }
Example #21
Source File: TestAMRMClientAsync.java From big-c with Apache License 2.0 | 5 votes |
@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(); } } } }
Example #22
Source File: YarnResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected AMRMClientAsync<AMRMClient.ContainerRequest> createAndStartResourceManagerClient( YarnConfiguration yarnConfiguration, int yarnHeartbeatIntervalMillis, @Nullable String webInterfaceUrl) { return mockResourceManagerClient; }
Example #23
Source File: YarnResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
TestingYarnResourceManager( RpcService rpcService, String resourceManagerEndpointId, ResourceID resourceId, Configuration flinkConfig, Map<String, String> env, HighAvailabilityServices highAvailabilityServices, HeartbeatServices heartbeatServices, SlotManager slotManager, MetricRegistry metricRegistry, JobLeaderIdService jobLeaderIdService, ClusterInformation clusterInformation, FatalErrorHandler fatalErrorHandler, @Nullable String webInterfaceUrl, AMRMClientAsync<AMRMClient.ContainerRequest> mockResourceManagerClient, NMClient mockNMClient, JobManagerMetricGroup jobManagerMetricGroup) { super( rpcService, resourceManagerEndpointId, resourceId, flinkConfig, env, highAvailabilityServices, heartbeatServices, slotManager, metricRegistry, jobLeaderIdService, clusterInformation, fatalErrorHandler, webInterfaceUrl, jobManagerMetricGroup); this.mockNMClient = mockNMClient; this.mockResourceManagerClient = mockResourceManagerClient; }
Example #24
Source File: TestAMRMClientAsync.java From hadoop with Apache License 2.0 | 5 votes |
@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(); }
Example #25
Source File: TestAMRMClientAsync.java From hadoop with Apache License 2.0 | 5 votes |
@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(); } } } }
Example #26
Source File: YarnResourceManager.java From flink with Apache License 2.0 | 5 votes |
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; } final RegisterApplicationMasterResponse registerApplicationMasterResponse = resourceManagerClient.registerApplicationMaster(hostPort.f0, restPort, webInterfaceUrl); getContainersFromPreviousAttempts(registerApplicationMasterResponse); return resourceManagerClient; }
Example #27
Source File: YarnResourceManagerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected AMRMClientAsync<AMRMClient.ContainerRequest> createAndStartResourceManagerClient( YarnConfiguration yarnConfiguration, int yarnHeartbeatIntervalMillis, @Nullable String webInterfaceUrl) { return mockResourceManagerClient; }
Example #28
Source File: TestAMRMClientAsync.java From big-c with Apache License 2.0 | 5 votes |
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); }
Example #29
Source File: TestAMRMClientAsync.java From big-c with Apache License 2.0 | 5 votes |
@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(); }
Example #30
Source File: YarnResourceManager.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
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; } final RegisterApplicationMasterResponse registerApplicationMasterResponse = resourceManagerClient.registerApplicationMaster(hostPort.f0, restPort, webInterfaceUrl); getContainersFromPreviousAttempts(registerApplicationMasterResponse); return resourceManagerClient; }