org.apache.hadoop.yarn.client.api.impl.YarnClientImpl Java Examples
The following examples show how to use
org.apache.hadoop.yarn.client.api.impl.YarnClientImpl.
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: TestResourceMgrDelegate.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void tesAllJobs() throws Exception { final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class); GetApplicationsResponse allApplicationsResponse = Records .newRecord(GetApplicationsResponse.class); List<ApplicationReport> applications = new ArrayList<ApplicationReport>(); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.FAILED)); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.SUCCEEDED)); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.KILLED)); applications.add(getApplicationReport(YarnApplicationState.FAILED, FinalApplicationStatus.FAILED)); allApplicationsResponse.setApplicationList(applications); Mockito.when( applicationsManager.getApplications(Mockito .any(GetApplicationsRequest.class))).thenReturn( allApplicationsResponse); ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate( new YarnConfiguration()) { @Override protected void serviceStart() throws Exception { Assert.assertTrue(this.client instanceof YarnClientImpl); ((YarnClientImpl) this.client).setRMClient(applicationsManager); } }; JobStatus[] allJobs = resourceMgrDelegate.getAllJobs(); Assert.assertEquals(State.FAILED, allJobs[0].getState()); Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState()); Assert.assertEquals(State.KILLED, allJobs[2].getState()); Assert.assertEquals(State.FAILED, allJobs[3].getState()); }
Example #2
Source File: TestResourceMgrDelegate.java From big-c with Apache License 2.0 | 5 votes |
@Test public void tesAllJobs() throws Exception { final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class); GetApplicationsResponse allApplicationsResponse = Records .newRecord(GetApplicationsResponse.class); List<ApplicationReport> applications = new ArrayList<ApplicationReport>(); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.FAILED)); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.SUCCEEDED)); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.KILLED)); applications.add(getApplicationReport(YarnApplicationState.FAILED, FinalApplicationStatus.FAILED)); allApplicationsResponse.setApplicationList(applications); Mockito.when( applicationsManager.getApplications(Mockito .any(GetApplicationsRequest.class))).thenReturn( allApplicationsResponse); ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate( new YarnConfiguration()) { @Override protected void serviceStart() throws Exception { Assert.assertTrue(this.client instanceof YarnClientImpl); ((YarnClientImpl) this.client).setRMClient(applicationsManager); } }; JobStatus[] allJobs = resourceMgrDelegate.getAllJobs(); Assert.assertEquals(State.FAILED, allJobs[0].getState()); Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState()); Assert.assertEquals(State.KILLED, allJobs[2].getState()); Assert.assertEquals(State.FAILED, allJobs[3].getState()); }
Example #3
Source File: InlineAM.java From attic-apex-core with Apache License 2.0 | 5 votes |
/** */ public InlineAM(Configuration conf) throws Exception { appName = "UnmanagedAM"; amPriority = 0; amQueue = "default"; YarnConfiguration yarnConf = new YarnConfiguration(conf); rmClient = new YarnClientImpl(); rmClient.init(yarnConf); }
Example #4
Source File: DAGClientRPCImpl.java From incubator-tez with Apache License 2.0 | 5 votes |
public DAGClientRPCImpl(ApplicationId appId, String dagId, TezConfiguration conf) { this.appId = appId; this.dagId = dagId; this.conf = conf; yarnClient = new YarnClientImpl(); yarnClient.init(new YarnConfiguration(conf)); yarnClient.start(); appReport = null; }
Example #5
Source File: YarnClient.java From hadoop with Apache License 2.0 | 4 votes |
/** * Create a new instance of YarnClient. */ @Public public static YarnClient createYarnClient() { YarnClient client = new YarnClientImpl(); return client; }
Example #6
Source File: TestYARNRunner.java From hadoop with Apache License 2.0 | 4 votes |
@Test(timeout=20000) public void testResourceMgrDelegate() throws Exception { /* we not want a mock of resource mgr delegate */ final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class); ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) { @Override protected void serviceStart() throws Exception { assertTrue(this.client instanceof YarnClientImpl); ((YarnClientImpl) this.client).setRMClient(clientRMProtocol); } }; /* make sure kill calls finish application master */ when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class))) .thenReturn(KillApplicationResponse.newInstance(true)); delegate.killApplication(appId); verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class)); /* make sure getalljobs calls get all applications */ when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))). thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class)); delegate.getAllJobs(); verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class)); /* make sure getapplication report is called */ when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class))) .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class)); delegate.getApplicationReport(appId); verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class)); /* make sure metrics is called */ GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance (GetClusterMetricsResponse.class); clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance( YarnClusterMetrics.class)); when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class))) .thenReturn(clusterMetricsResponse); delegate.getClusterMetrics(); verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class)); when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))). thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class)); delegate.getActiveTrackers(); verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class)); GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance( GetNewApplicationResponse.class); newAppResponse.setApplicationId(appId); when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))). thenReturn(newAppResponse); delegate.getNewJobID(); verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class)); GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance( GetQueueInfoResponse.class); queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class)); when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))). thenReturn(queueInfoResponse); delegate.getQueues(); verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class)); GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance( GetQueueUserAclsInfoResponse.class); when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class))) .thenReturn(aclResponse); delegate.getQueueAclsForCurrentUser(); verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)); }
Example #7
Source File: YarnClient.java From big-c with Apache License 2.0 | 4 votes |
/** * Create a new instance of YarnClient. */ @Public public static YarnClient createYarnClient() { YarnClient client = new YarnClientImpl(); return client; }
Example #8
Source File: TestYARNRunner.java From big-c with Apache License 2.0 | 4 votes |
@Test(timeout=20000) public void testResourceMgrDelegate() throws Exception { /* we not want a mock of resource mgr delegate */ final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class); ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) { @Override protected void serviceStart() throws Exception { assertTrue(this.client instanceof YarnClientImpl); ((YarnClientImpl) this.client).setRMClient(clientRMProtocol); } }; /* make sure kill calls finish application master */ when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class))) .thenReturn(KillApplicationResponse.newInstance(true)); delegate.killApplication(appId); verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class)); /* make sure getalljobs calls get all applications */ when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))). thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class)); delegate.getAllJobs(); verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class)); /* make sure getapplication report is called */ when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class))) .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class)); delegate.getApplicationReport(appId); verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class)); /* make sure metrics is called */ GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance (GetClusterMetricsResponse.class); clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance( YarnClusterMetrics.class)); when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class))) .thenReturn(clusterMetricsResponse); delegate.getClusterMetrics(); verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class)); when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))). thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class)); delegate.getActiveTrackers(); verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class)); GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance( GetNewApplicationResponse.class); newAppResponse.setApplicationId(appId); when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))). thenReturn(newAppResponse); delegate.getNewJobID(); verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class)); GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance( GetQueueInfoResponse.class); queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class)); when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))). thenReturn(queueInfoResponse); delegate.getQueues(); verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class)); GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance( GetQueueUserAclsInfoResponse.class); when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class))) .thenReturn(aclResponse); delegate.getQueueAclsForCurrentUser(); verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)); }
Example #9
Source File: YarnTajoResourceManager.java From incubator-tajo with Apache License 2.0 | 4 votes |
private void connectYarnClient() { this.yarnClient = new YarnClientImpl(); this.yarnClient.init(conf); this.yarnClient.start(); }
Example #10
Source File: YarnResourceAllocator.java From incubator-tajo with Apache License 2.0 | 4 votes |
private void connectYarnClient() { this.yarnClient = new YarnClientImpl(); this.yarnClient.init(systemConf); this.yarnClient.start(); }