本文整理汇总了Java中org.apache.hadoop.yarn.api.records.ApplicationReport类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationReport类的具体用法?Java ApplicationReport怎么用?Java ApplicationReport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationReport类属于org.apache.hadoop.yarn.api.records包,在下文中一共展示了ApplicationReport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanAll
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
/**
* Scan all clusters to recover the soft state.
*/
@VisibleForTesting
void scanAll() throws IOException, YarnException {
ConcurrentHashMap<UUID, InstanceInfo> newInstances = new ConcurrentHashMap<>();
for (ClusterInfo cluster : clusters.values()) {
List<ApplicationReport> reports = cluster.client()
.getApplications(Collections.singleton(ATHENAX_APPLICATION_TYPE));
for (ApplicationReport report : reports) {
InstanceInfo instance = Utils.extractInstanceInfo(cluster.name(), report);
if (instance == null) {
LOG.warn("Failed to retrieve instance info for {}:{}", cluster.name(), report.getApplicationId());
} else {
newInstances.put(instance.metadata().uuid(), instance);
}
}
}
LOG.info("Inspected {} active instances", newInstances.size());
instances.set(newInstances);
listener.onUpdatedInstances(newInstances);
}
示例2: deploy
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Override
public YarnClusterClient deploy() {
ApplicationSubmissionContext context = Records.newRecord(ApplicationSubmissionContext.class);
context.setApplicationId(job.yarnAppId());
ApplicationReport report;
try {
report = startAppMaster(context);
Configuration conf = getFlinkConfiguration();
conf.setString(JobManagerOptions.ADDRESS.key(), report.getHost());
conf.setInteger(JobManagerOptions.PORT.key(), report.getRpcPort());
return createYarnClusterClient(this, yarnClient, report, conf, false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: run
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Override
public void run() {
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
try {
ApplicationReport report = poll();
if (report == null) {
YARN_POLL_EXECUTOR.schedule(this, RETRY_DELAY_MS, TimeUnit.MILLISECONDS);
} else {
result.complete(report);
}
} catch (YarnException | IOException e) {
result.completeExceptionally(e);
}
}
示例4: extractInstanceInfo
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
static InstanceInfo extractInstanceInfo(String clusterName, ApplicationReport report) {
InstanceMetadata md = getMetadata(report.getApplicationTags());
if (md == null) {
return null;
}
ApplicationResourceUsageReport usage = report.getApplicationResourceUsageReport();
InstanceStatus stat = new InstanceStatus()
.allocatedVCores((long) usage.getUsedResources().getVirtualCores())
.allocatedMB((long) usage.getUsedResources().getMemory())
.clusterId(clusterName)
.applicationId(report.getApplicationId().toString())
.startedTime(report.getStartTime())
.runningContainers((long) usage.getNumUsedContainers())
.trackingUrl(report.getTrackingUrl())
.state(InstanceStatus.StateEnum.fromValue(report.getYarnApplicationState().toString()));
return new InstanceInfo(clusterName, report.getApplicationId(), md, stat);
}
示例5: submitJob
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Override
public JobStatus submitJob(JobID jobId, String jobSubmitDir, Credentials ts)
throws IOException, InterruptedException {
addHistoryToken(ts);
// Construct necessary information to start the MR AM
ApplicationSubmissionContext appContext = createApplicationSubmissionContext(conf, jobSubmitDir, ts);
// Submit to ResourceManager
try {
ApplicationId applicationId = resMgrDelegate.submitApplication(appContext);
ApplicationReport appMaster = resMgrDelegate.getApplicationReport(applicationId);
String diagnostics = (appMaster == null ? "application report is null" : appMaster.getDiagnostics());
if (appMaster == null || appMaster.getYarnApplicationState() == YarnApplicationState.FAILED
|| appMaster.getYarnApplicationState() == YarnApplicationState.KILLED) {
throw new IOException("Failed to run job : " + diagnostics);
}
return clientCache.getClient(jobId).getJobStatus(jobId);
} catch (YarnException e) {
throw new IOException(e);
}
}
示例6: resyncWithRM
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
public void resyncWithRM() throws Exception {
List<ApplicationReport> reports = null;
try {
// Only Get LAUNCHER ApplicationReport
reports = yarnClient.getApplications(new HashSet<>(
Collections.singletonList(GlobalConstants.LAUNCHER_APPLICATION_TYPE)));
} catch (Exception e) {
LOGGER.logWarning(e,
"Exception occurred during GetApplications. It should be transient. " +
"Will retry next time after %ss", conf.getServiceRMResyncIntervalSec());
}
if (reports != null) {
// ApplicationId -> ApplicationReport
HashMap<String, ApplicationReport> liveApplicationReports = new HashMap<>();
for (ApplicationReport report : reports) {
liveApplicationReports.put(report.getApplicationId().toString(), report);
}
service.onLiveApplicationsUpdated(liveApplicationReports);
}
service.queueResyncWithRM(conf.getServiceRMResyncIntervalSec());
}
示例7: testGetApplicationAttempt
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
Configuration conf = new Configuration();
final YarnClient client = new MockYarnClient();
client.init(conf);
client.start();
List<ApplicationReport> expectedReports = ((MockYarnClient) client)
.getReports();
ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
applicationId, 1);
ApplicationAttemptReport report = client
.getApplicationAttemptReport(appAttemptId);
Assert.assertNotNull(report);
Assert.assertEquals(report.getApplicationAttemptId().toString(),
expectedReports.get(0).getCurrentApplicationAttemptId().toString());
client.stop();
}
示例8: awaitApplication
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
boolean awaitApplication(ApplicationId appId) throws Exception {
Set<YarnApplicationState> terminated = Sets.newHashSet(
YarnApplicationState.FAILED,
YarnApplicationState.FINISHED,
YarnApplicationState.KILLED);
while (true) {
ApplicationReport report = yarnClient.getApplicationReport(appId);
YarnApplicationState state = report.getYarnApplicationState();
if (state.equals(YarnApplicationState.RUNNING)) {
ClusterSpec clusterSpec = Client.getClusterSpec(yarnClient, appId);
if (isClusterSpecSatisfied(clusterSpec)) {
System.out.println("ClusterSpec: " + Utils.toJsonString(clusterSpec.getCluster()));
return true;
}
} else if (terminated.contains(state)) {
return false;
} else {
Thread.sleep(1000);
}
}
}
示例9: testJobSubmissionFailure
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Test(timeout=20000)
public void testJobSubmissionFailure() throws Exception {
when(resourceMgrDelegate.submitApplication(any(ApplicationSubmissionContext.class))).
thenReturn(appId);
ApplicationReport report = mock(ApplicationReport.class);
when(report.getApplicationId()).thenReturn(appId);
when(report.getDiagnostics()).thenReturn(failString);
when(report.getYarnApplicationState()).thenReturn(YarnApplicationState.FAILED);
when(resourceMgrDelegate.getApplicationReport(appId)).thenReturn(report);
Credentials credentials = new Credentials();
File jobxml = new File(testWorkDir, "job.xml");
OutputStream out = new FileOutputStream(jobxml);
conf.writeXml(out);
out.close();
try {
yarnRunner.submitJob(jobId, testWorkDir.getAbsolutePath().toString(), credentials);
} catch(IOException io) {
LOG.info("Logging exception:", io);
assertTrue(io.getLocalizedMessage().contains(failString));
}
}
示例10: testApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Test
public void testApplicationReport() {
long timestamp = System.currentTimeMillis();
ApplicationReport appReport1 =
createApplicationReport(1, 1, timestamp);
ApplicationReport appReport2 =
createApplicationReport(1, 1, timestamp);
ApplicationReport appReport3 =
createApplicationReport(1, 1, timestamp);
Assert.assertEquals(appReport1, appReport2);
Assert.assertEquals(appReport2, appReport3);
appReport1.setApplicationId(null);
Assert.assertNull(appReport1.getApplicationId());
Assert.assertNotSame(appReport1, appReport2);
appReport2.setCurrentApplicationAttemptId(null);
Assert.assertNull(appReport2.getCurrentApplicationAttemptId());
Assert.assertNotSame(appReport2, appReport3);
Assert.assertNull(appReport1.getAMRMToken());
}
示例11: getApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Override
public ApplicationReport getApplicationReport(ApplicationId applicationId)
throws IOException {
List<ApplicationReport> reports = null;
try {
reports = getApplications(applicationId.getId());
} catch (Throwable e) {
LOG.info("Couldn't get application report for " + applicationId
+ ", might be completed already.");
}
if (reports == null || reports.isEmpty()) {
return ApplicationReport.newInstance(applicationId, null, "", "default",
"", "", 0, null, YarnApplicationState.FINISHED, "", "", 0, 0,
FinalApplicationStatus.SUCCEEDED, null, "", 100, null, null);
}
return reports.get(0);
}
示例12: AppInfo
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
public AppInfo(ApplicationReport app) {
appId = app.getApplicationId().toString();
if (app.getCurrentApplicationAttemptId() != null) {
currentAppAttemptId = app.getCurrentApplicationAttemptId().toString();
}
user = app.getUser();
queue = app.getQueue();
name = app.getName();
type = app.getApplicationType();
host = app.getHost();
rpcPort = app.getRpcPort();
appState = app.getYarnApplicationState();
diagnosticsInfo = app.getDiagnostics();
trackingUrl = app.getTrackingUrl();
originalTrackingUrl = app.getOriginalTrackingUrl();
submittedTime = app.getStartTime();
startedTime = app.getStartTime();
finishedTime = app.getFinishTime();
elapsedTime = Times.elapsed(startedTime, finishedTime);
finalAppStatus = app.getFinalApplicationStatus();
progress = app.getProgress() * 100; // in percent
if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
this.applicationTags = CSV_JOINER.join(app.getApplicationTags());
}
}
示例13: tesAllJobs
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@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());
}
示例14: testInvalidatedAMHostPortOnAMRestart
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
@Test (timeout = 60000)
public void testInvalidatedAMHostPortOnAMRestart() throws Exception {
MockRM rm1 = new MockRM(conf);
rm1.start();
MockNM nm1 =
new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
nm1.registerNode();
// a failed app
RMApp app2 = rm1.submitApp(200);
MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
nm1
.nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
am2.waitForState(RMAppAttemptState.FAILED);
rm1.waitForState(app2.getApplicationId(), RMAppState.ACCEPTED);
// before new attempt is launched, the app report returns the invalid AM
// host and port.
GetApplicationReportRequest request1 =
GetApplicationReportRequest.newInstance(app2.getApplicationId());
ApplicationReport report1 =
rm1.getClientRMService().getApplicationReport(request1)
.getApplicationReport();
Assert.assertEquals("N/A", report1.getHost());
Assert.assertEquals(-1, report1.getRpcPort());
}
示例15: verifyEnemyAppReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入依赖的package包/类
private void verifyEnemyAppReport(ApplicationReport appReport) {
Assert.assertEquals("Enemy should not see app host!",
UNAVAILABLE, appReport.getHost());
Assert.assertEquals("Enemy should not see app rpc port!",
-1, appReport.getRpcPort());
Assert.assertEquals("Enemy should not see app client token!",
null, appReport.getClientToAMToken());
Assert.assertEquals("Enemy should not see app diagnostics!",
UNAVAILABLE, appReport.getDiagnostics());
Assert.assertEquals("Enemy should not see app tracking url!",
UNAVAILABLE, appReport.getTrackingUrl());
Assert.assertEquals("Enemy should not see app original tracking url!",
UNAVAILABLE, appReport.getOriginalTrackingUrl());
ApplicationResourceUsageReport usageReport =
appReport.getApplicationResourceUsageReport();
Assert.assertEquals("Enemy should not see app used containers",
-1, usageReport.getNumUsedContainers());
Assert.assertEquals("Enemy should not see app reserved containers",
-1, usageReport.getNumReservedContainers());
Assert.assertEquals("Enemy should not see app used resources",
-1, usageReport.getUsedResources().getMemory());
Assert.assertEquals("Enemy should not see app reserved resources",
-1, usageReport.getReservedResources().getMemory());
Assert.assertEquals("Enemy should not see app needed resources",
-1, usageReport.getNeededResources().getMemory());
}