YARN-1889. In Fair Scheduler, avoid creating objects on each call to AppSchedulable comparator (Hong Zhiguo via Sandy Ryza)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1583494 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20fb03a6c4
commit
06d62b1982
|
@ -36,6 +36,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
YARN-1883. TestRMAdminService fails due to inconsistent entries in
|
YARN-1883. TestRMAdminService fails due to inconsistent entries in
|
||||||
UserGroups (Mit Desai via jeagles)
|
UserGroups (Mit Desai via jeagles)
|
||||||
|
|
||||||
|
YARN-1889. In Fair Scheduler, avoid creating objects on each call to
|
||||||
|
AppSchedulable comparator (Hong Zhiguo via Sandy Ryza)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -34,13 +34,17 @@ public class ResourceWeights {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceWeights(float weight) {
|
public ResourceWeights(float weight) {
|
||||||
|
setWeight(weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceWeights() { }
|
||||||
|
|
||||||
|
public void setWeight(float weight) {
|
||||||
for (int i = 0; i < weights.length; i++) {
|
for (int i = 0; i < weights.length; i++) {
|
||||||
weights[i] = weight;
|
weights[i] = weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceWeights() { }
|
|
||||||
|
|
||||||
public void setWeight(ResourceType resourceType, float weight) {
|
public void setWeight(ResourceType resourceType, float weight) {
|
||||||
weights[resourceType.ordinal()] = weight;
|
weights[resourceType.ordinal()] = weight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,11 @@ public class AppSchedulable extends Schedulable {
|
||||||
private FSSchedulerApp app;
|
private FSSchedulerApp app;
|
||||||
private Resource demand = Resources.createResource(0);
|
private Resource demand = Resources.createResource(0);
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
|
|
||||||
private static final Log LOG = LogFactory.getLog(AppSchedulable.class);
|
private static final Log LOG = LogFactory.getLog(AppSchedulable.class);
|
||||||
private FSLeafQueue queue;
|
private FSLeafQueue queue;
|
||||||
private RMContainerTokenSecretManager containerTokenSecretManager;
|
private RMContainerTokenSecretManager containerTokenSecretManager;
|
||||||
|
private Priority priority;
|
||||||
|
private ResourceWeights resourceWeights;
|
||||||
|
|
||||||
public AppSchedulable(FairScheduler scheduler, FSSchedulerApp app, FSLeafQueue queue) {
|
public AppSchedulable(FairScheduler scheduler, FSSchedulerApp app, FSLeafQueue queue) {
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
|
@ -64,6 +65,8 @@ public class AppSchedulable extends Schedulable {
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
this.containerTokenSecretManager = scheduler.
|
this.containerTokenSecretManager = scheduler.
|
||||||
getContainerTokenSecretManager();
|
getContainerTokenSecretManager();
|
||||||
|
this.priority = Priority.newInstance(1);
|
||||||
|
this.resourceWeights = new ResourceWeights();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,6 +78,10 @@ public class AppSchedulable extends Schedulable {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResourceWeights getResourceWeights() {
|
||||||
|
return resourceWeights;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDemand() {
|
public void updateDemand() {
|
||||||
demand = Resources.createResource(0);
|
demand = Resources.createResource(0);
|
||||||
|
@ -134,9 +141,7 @@ public class AppSchedulable extends Schedulable {
|
||||||
public Priority getPriority() {
|
public Priority getPriority() {
|
||||||
// Right now per-app priorities are not passed to scheduler,
|
// Right now per-app priorities are not passed to scheduler,
|
||||||
// so everyone has the same priority.
|
// so everyone has the same priority.
|
||||||
Priority p = recordFactory.newRecordInstance(Priority.class);
|
return priority;
|
||||||
p.setPriority(1);
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -535,7 +535,9 @@ public class FairScheduler extends AbstractYarnScheduler {
|
||||||
// Run weight through the user-supplied weightAdjuster
|
// Run weight through the user-supplied weightAdjuster
|
||||||
weight = weightAdjuster.adjustWeight(app, weight);
|
weight = weightAdjuster.adjustWeight(app, weight);
|
||||||
}
|
}
|
||||||
return new ResourceWeights((float)weight);
|
ResourceWeights resourceWeights = app.getResourceWeights();
|
||||||
|
resourceWeights.setWeight((float)weight);
|
||||||
|
return resourceWeights;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue