本文整理汇总了Java中org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationResourceUsageReport类的具体用法?Java ApplicationResourceUsageReport怎么用?Java ApplicationResourceUsageReport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationResourceUsageReport类属于org.apache.hadoop.yarn.api.records包,在下文中一共展示了ApplicationResourceUsageReport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractInstanceInfo
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的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);
}
示例2: newApplicationResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public static ApplicationResourceUsageReport newApplicationResourceUsageReport(
int numUsedContainers, int numReservedContainers, Resource usedResources,
Resource reservedResources, Resource neededResources, long memorySeconds,
long vcoreSeconds, long gcoreSeconds) {
ApplicationResourceUsageReport report =
recordFactory.newRecordInstance(ApplicationResourceUsageReport.class);
report.setNumUsedContainers(numUsedContainers);
report.setNumReservedContainers(numReservedContainers);
report.setUsedResources(usedResources);
report.setReservedResources(reservedResources);
report.setNeededResources(neededResources);
report.setMemorySeconds(memorySeconds);
report.setVcoreSeconds(vcoreSeconds);
report.setGcoreSeconds(gcoreSeconds);
return report;
}
示例3: getApplicationResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
@Override
public ApplicationResourceUsageReport getApplicationResourceUsageReport() {
this.readLock.lock();
try {
ApplicationResourceUsageReport report =
scheduler.getAppResourceUsageReport(this.getAppAttemptId());
if (report == null) {
report = RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
}
AggregateAppResourceUsage resUsage =
this.attemptMetrics.getAggregateAppResourceUsage();
report.setMemorySeconds(resUsage.getMemorySeconds());
report.setVcoreSeconds(resUsage.getVcoreSeconds());
report.setGcoreSeconds(resUsage.getGcoreSeconds());
return report;
} finally {
this.readLock.unlock();
}
}
示例4: getAggregateAppResourceUsage
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public AggregateAppResourceUsage getAggregateAppResourceUsage() {
long memorySeconds = finishedMemorySeconds.get();
long vcoreSeconds = finishedVcoreSeconds.get();
long gcoreSeconds = finishedGcoreSeconds.get();
// Only add in the running containers if this is the active attempt.
RMAppAttempt currentAttempt = rmContext.getRMApps()
.get(attemptId.getApplicationId()).getCurrentAppAttempt();
if (currentAttempt.getAppAttemptId().equals(attemptId)) {
ApplicationResourceUsageReport appResUsageReport = rmContext
.getScheduler().getAppResourceUsageReport(attemptId);
if (appResUsageReport != null) {
memorySeconds += appResUsageReport.getMemorySeconds();
vcoreSeconds += appResUsageReport.getVcoreSeconds();
gcoreSeconds += appResUsageReport.getGcoreSeconds();
}
}
return new AggregateAppResourceUsage(memorySeconds, vcoreSeconds, gcoreSeconds);
}
示例5: verifyEnemyAppReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的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());
}
示例6: testGetApplicationResourceUsageReportDummy
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
@Test
public void testGetApplicationResourceUsageReportDummy() throws YarnException,
IOException {
ApplicationAttemptId attemptId = getApplicationAttemptId(1);
YarnScheduler yarnScheduler = mockYarnScheduler();
RMContext rmContext = mock(RMContext.class);
mockRMContext(yarnScheduler, rmContext);
when(rmContext.getDispatcher().getEventHandler()).thenReturn(
new EventHandler<Event>() {
public void handle(Event event) {
}
});
ApplicationSubmissionContext asContext =
mock(ApplicationSubmissionContext.class);
YarnConfiguration config = new YarnConfiguration();
RMAppAttemptImpl rmAppAttemptImpl = new RMAppAttemptImpl(attemptId,
rmContext, yarnScheduler, null, asContext, config, false, null);
ApplicationResourceUsageReport report = rmAppAttemptImpl
.getApplicationResourceUsageReport();
assertEquals(report, RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
}
示例7: getApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
private ApplicationReport getApplicationReport(
YarnApplicationState yarnApplicationState,
FinalApplicationStatus finalApplicationStatus) {
ApplicationReport appReport = Mockito.mock(ApplicationReport.class);
ApplicationResourceUsageReport appResources = Mockito
.mock(ApplicationResourceUsageReport.class);
Mockito.when(appReport.getApplicationId()).thenReturn(
ApplicationId.newInstance(0, 0));
Mockito.when(appResources.getNeededResources()).thenReturn(
Records.newRecord(Resource.class));
Mockito.when(appResources.getReservedResources()).thenReturn(
Records.newRecord(Resource.class));
Mockito.when(appResources.getUsedResources()).thenReturn(
Records.newRecord(Resource.class));
Mockito.when(appReport.getApplicationResourceUsageReport()).thenReturn(
appResources);
Mockito.when(appReport.getYarnApplicationState()).thenReturn(
yarnApplicationState);
Mockito.when(appReport.getFinalApplicationStatus()).thenReturn(
finalApplicationStatus);
return appReport;
}
示例8: getApplicationResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
@Override
public ApplicationResourceUsageReport getApplicationResourceUsageReport() {
this.readLock.lock();
try {
ApplicationResourceUsageReport report =
scheduler.getAppResourceUsageReport(this.getAppAttemptId());
if (report == null) {
report = RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
}
AggregateAppResourceUsage resUsage =
this.attemptMetrics.getAggregateAppResourceUsage();
report.setMemorySeconds(resUsage.getMemorySeconds());
report.setVcoreSeconds(resUsage.getVcoreSeconds());
return report;
} finally {
this.readLock.unlock();
}
}
示例9: getAggregateAppResourceUsage
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public AggregateAppResourceUsage getAggregateAppResourceUsage() {
long memorySeconds = finishedMemorySeconds.get();
long vcoreSeconds = finishedVcoreSeconds.get();
// Only add in the running containers if this is the active attempt.
RMAppAttempt currentAttempt = rmContext.getRMApps()
.get(attemptId.getApplicationId()).getCurrentAppAttempt();
if (currentAttempt.getAppAttemptId().equals(attemptId)) {
ApplicationResourceUsageReport appResUsageReport = rmContext
.getScheduler().getAppResourceUsageReport(attemptId);
if (appResUsageReport != null) {
memorySeconds += appResUsageReport.getMemorySeconds();
vcoreSeconds += appResUsageReport.getVcoreSeconds();
}
}
return new AggregateAppResourceUsage(memorySeconds, vcoreSeconds);
}
示例10: getResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public synchronized ApplicationResourceUsageReport getResourceUsageReport() {
AggregateAppResourceUsage runningResourceUsage =
getRunningAggregateAppResourceUsage();
Resource usedResourceClone =
Resources.clone(attemptResourceUsage.getAllUsed());
Resource reservedResourceClone =
Resources.clone(attemptResourceUsage.getReserved());
Resource cluster = rmContext.getScheduler().getClusterResource();
ResourceCalculator calc = rmContext.getScheduler().getResourceCalculator();
float queueUsagePerc = calc.divide(cluster, usedResourceClone, Resources
.multiply(cluster, queue.getQueueInfo(false, false).getCapacity()))
* 100;
float clusterUsagePerc =
calc.divide(cluster, usedResourceClone, cluster) * 100;
return ApplicationResourceUsageReport.newInstance(liveContainers.size(),
reservedContainers.size(), usedResourceClone, reservedResourceClone,
Resources.add(usedResourceClone, reservedResourceClone),
runningResourceUsage.getMemorySeconds(),
runningResourceUsage.getVcoreSeconds(),
queueUsagePerc, clusterUsagePerc);
}
示例11: testFromYarn
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
@Test
public void testFromYarn() throws Exception {
int appStartTime = 612354;
YarnApplicationState state = YarnApplicationState.RUNNING;
ApplicationId applicationId = ApplicationId.newInstance(0, 0);
ApplicationReport applicationReport = Records
.newRecord(ApplicationReport.class);
applicationReport.setApplicationId(applicationId);
applicationReport.setYarnApplicationState(state);
applicationReport.setStartTime(appStartTime);
applicationReport.setUser("TestTypeConverter-user");
ApplicationResourceUsageReport appUsageRpt = Records
.newRecord(ApplicationResourceUsageReport.class);
Resource r = Records.newRecord(Resource.class);
r.setMemory(2048);
appUsageRpt.setNeededResources(r);
appUsageRpt.setNumReservedContainers(1);
appUsageRpt.setNumUsedContainers(3);
appUsageRpt.setReservedResources(r);
appUsageRpt.setUsedResources(r);
applicationReport.setApplicationResourceUsageReport(appUsageRpt);
JobStatus jobStatus = TypeConverter.fromYarn(applicationReport, "dummy-jobfile");
Assert.assertEquals(appStartTime, jobStatus.getStartTime());
Assert.assertEquals(state.toString(), jobStatus.getState().toString());
}
示例12: newApplicationResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public static ApplicationResourceUsageReport newApplicationResourceUsageReport(
int numUsedContainers, int numReservedContainers, Resource usedResources,
Resource reservedResources, Resource neededResources, long memorySeconds,
long vcoreSeconds, long gpuSeconds, long preemptedMemorySeconds,
long preemptedVcoreSeconds, long preemptedGPUSeconds) {
ApplicationResourceUsageReport report =
recordFactory.newRecordInstance(ApplicationResourceUsageReport.class);
report.setNumUsedContainers(numUsedContainers);
report.setNumReservedContainers(numReservedContainers);
report.setUsedResources(usedResources);
report.setReservedResources(reservedResources);
report.setNeededResources(neededResources);
report.setMemorySeconds(memorySeconds);
report.setVcoreSeconds(vcoreSeconds);
report.setGPUSeconds(gpuSeconds);
report.setPreemptedMemorySeconds(preemptedMemorySeconds);
report.setPreemptedVcoreSeconds(preemptedVcoreSeconds);
report.setPreemptedGPUSeconds(preemptedGPUSeconds);
return report;
}
示例13: getApplicationResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
@Override
public ApplicationResourceUsageReport getApplicationResourceUsageReport() {
this.readLock.lock();
try {
ApplicationResourceUsageReport report =
scheduler.getAppResourceUsageReport(this.getAppAttemptId());
if (report == null) {
report = RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
}
AggregateAppResourceUsage resUsage =
this.attemptMetrics.getAggregateAppResourceUsage();
report.setMemorySeconds(resUsage.getMemorySeconds());
report.setVcoreSeconds(resUsage.getVcoreSeconds());
report.setGPUSeconds(resUsage.getGPUSeconds());
report.setPreemptedMemorySeconds(
this.attemptMetrics.getPreemptedMemory());
report.setPreemptedVcoreSeconds(
this.attemptMetrics.getPreemptedVcore());
report.setPreemptedGPUSeconds(
this.attemptMetrics.getPreemptedGPU());
return report;
} finally {
this.readLock.unlock();
}
}
示例14: getAggregateAppResourceUsage
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public AggregateAppResourceUsage getAggregateAppResourceUsage() {
long memorySeconds = finishedMemorySeconds.get();
long vcoreSeconds = finishedVcoreSeconds.get();
long gpuSeconds = finishedGPUSeconds.get();
// Only add in the running containers if this is the active attempt.
RMAppAttempt currentAttempt = rmContext.getRMApps()
.get(attemptId.getApplicationId()).getCurrentAppAttempt();
if (currentAttempt.getAppAttemptId().equals(attemptId)) {
ApplicationResourceUsageReport appResUsageReport = rmContext
.getScheduler().getAppResourceUsageReport(attemptId);
if (appResUsageReport != null) {
memorySeconds += appResUsageReport.getMemorySeconds();
vcoreSeconds += appResUsageReport.getVcoreSeconds();
gpuSeconds += appResUsageReport.getGPUSeconds();
}
}
return new AggregateAppResourceUsage(memorySeconds, vcoreSeconds, gpuSeconds);
}
示例15: getResourceUsageReport
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入依赖的package包/类
public synchronized ApplicationResourceUsageReport getResourceUsageReport() {
AggregateAppResourceUsage runningResourceUsage =
getRunningAggregateAppResourceUsage();
Resource usedResourceClone =
Resources.clone(attemptResourceUsage.getAllUsed());
Resource reservedResourceClone =
Resources.clone(attemptResourceUsage.getReserved());
Resource cluster = rmContext.getScheduler().getClusterResource();
ResourceCalculator calc = rmContext.getScheduler().getResourceCalculator();
float queueUsagePerc = 0.0f;
float clusterUsagePerc = 0.0f;
if (!calc.isInvalidDivisor(cluster)) {
queueUsagePerc =
calc.divide(cluster, usedResourceClone, Resources.multiply(cluster,
queue.getQueueInfo(false, false).getCapacity())) * 100;
clusterUsagePerc = calc.divide(cluster, usedResourceClone, cluster) * 100;
}
return ApplicationResourceUsageReport.newInstance(liveContainers.size(),
reservedContainers.size(), usedResourceClone, reservedResourceClone,
Resources.add(usedResourceClone, reservedResourceClone),
runningResourceUsage.getMemorySeconds(),
runningResourceUsage.getVcoreSeconds(),
runningResourceUsage.getGPUSeconds(), queueUsagePerc,
clusterUsagePerc, 0, 0, 0);
}