YARN-2611. Fixing jenkins findbugs warning and TestRMWebServicesCapacitySched for branch YARN-1051. Contributed by Subru Krishnan and Carlo Curino.

(cherry picked from commit c47464aba4)
(cherry picked from commit a2986234be)
This commit is contained in:
subru 2014-09-26 10:48:12 -07:00 committed by Chris Douglas
parent ae0f16ccc8
commit fb5e9df7fd
7 changed files with 50 additions and 7 deletions

View File

@ -29,3 +29,6 @@ delegate. (Subru Krishnan and Carlo Curino via subru)
YARN-2576. Fixing compilation, javadocs and audit issues to pass YARN-2576. Fixing compilation, javadocs and audit issues to pass
test patch in branch. (Subru Krishnan and Carlo Curino via subru) test patch in branch. (Subru Krishnan and Carlo Curino via subru)
YARN-2611. Fixing jenkins findbugs warning and TestRMWebServicesCapacitySched
for branch YARN-1051. (Subru Krishnan and Carlo Curino via subru)

View File

@ -62,6 +62,11 @@ public class CapacityOverTimePolicy implements SharingPolicy {
// it should be easy to remove this limitation // it should be easy to remove this limitation
@Override @Override
public void init(String reservationQueuePath, Configuration conf) { public void init(String reservationQueuePath, Configuration conf) {
if (!(conf instanceof CapacitySchedulerConfiguration)) {
throw new IllegalArgumentException("Unexpected conf type: "
+ conf.getClass().getSimpleName() + " only supported conf is: "
+ CapacitySchedulerConfiguration.class.getSimpleName());
}
this.conf = (CapacitySchedulerConfiguration) conf; this.conf = (CapacitySchedulerConfiguration) conf;
validWindow = this.conf.getReservationWindow(reservationQueuePath); validWindow = this.conf.getReservationWindow(reservationQueuePath);
maxInst = this.conf.getInstantaneousMaxCapacity(reservationQueuePath) / 100; maxInst = this.conf.getInstantaneousMaxCapacity(reservationQueuePath) / 100;
@ -203,7 +208,7 @@ public long getValidWindow() {
* The comparison/multiplication behaviors of IntegralResource are consistent * The comparison/multiplication behaviors of IntegralResource are consistent
* with the DefaultResourceCalculator. * with the DefaultResourceCalculator.
*/ */
public class IntegralResource { private static class IntegralResource {
long memory; long memory;
long vcores; long vcores;

View File

@ -326,7 +326,7 @@ private List<ReservationAllocation> sortByDelta(
return currentReservations; return currentReservations;
} }
private class ReservationAllocationComparator implements private static class ReservationAllocationComparator implements
Comparator<ReservationAllocation> { Comparator<ReservationAllocation> {
CapacityScheduler scheduler; CapacityScheduler scheduler;
long now; long now;

View File

@ -138,7 +138,7 @@ private void decrementAllocation(ReservationAllocation reservation) {
rleSparseVector.removeInterval(r.getKey(), r.getValue()); rleSparseVector.removeInterval(r.getKey(), r.getValue());
} }
if (resAlloc.isEmpty()) { if (resAlloc.isEmpty()) {
userResourceAlloc.remove(resAlloc); userResourceAlloc.remove(user);
} }
} }
@ -311,9 +311,9 @@ public boolean deleteReservation(ReservationId reservationID) {
public void archiveCompletedReservations(long tick) { public void archiveCompletedReservations(long tick) {
// Since we are looking for old reservations, read lock is optimal // Since we are looking for old reservations, read lock is optimal
LOG.debug("Running archival at time: {}", tick); LOG.debug("Running archival at time: {}", tick);
readLock.lock();
List<InMemoryReservationAllocation> expiredReservations = List<InMemoryReservationAllocation> expiredReservations =
new ArrayList<InMemoryReservationAllocation>(); new ArrayList<InMemoryReservationAllocation>();
readLock.lock();
// archive reservations and delete the ones which are beyond // archive reservations and delete the ones which are beyond
// the reservation policy "window" // the reservation policy "window"
try { try {
@ -351,9 +351,9 @@ public void archiveCompletedReservations(long tick) {
@Override @Override
public Set<ReservationAllocation> getReservationsAtTime(long tick) { public Set<ReservationAllocation> getReservationsAtTime(long tick) {
readLock.lock();
ReservationInterval searchInterval = ReservationInterval searchInterval =
new ReservationInterval(tick, Long.MAX_VALUE); new ReservationInterval(tick, Long.MAX_VALUE);
readLock.lock();
try { try {
SortedMap<ReservationInterval, Set<InMemoryReservationAllocation>> reservations = SortedMap<ReservationInterval, Set<InMemoryReservationAllocation>> reservations =
currentReservations.headMap(searchInterval, true); currentReservations.headMap(searchInterval, true);

View File

@ -78,6 +78,36 @@ public int compareTo(ReservationInterval anotherInterval) {
} }
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (endTime ^ (endTime >>> 32));
result = prime * result + (int) (startTime ^ (startTime >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ReservationInterval)) {
return false;
}
ReservationInterval other = (ReservationInterval) obj;
if (endTime != other.endTime) {
return false;
}
if (startTime != other.startTime) {
return false;
}
return true;
}
public String toString() { public String toString() {
return "[" + startTime + ", " + endTime + "]"; return "[" + startTime + ", " + endTime + "]";
} }

View File

@ -70,6 +70,11 @@ public SimpleCapacityReplanner() {
@Override @Override
public void init(String planQueueName, Configuration conf) { public void init(String planQueueName, Configuration conf) {
if (!(conf instanceof CapacitySchedulerConfiguration)) {
throw new IllegalArgumentException("Unexpected conf type: "
+ conf.getClass().getSimpleName() + " only supported conf is: "
+ CapacitySchedulerConfiguration.class.getSimpleName());
}
this.lengthOfCheckZone = this.lengthOfCheckZone =
((CapacitySchedulerConfiguration) conf) ((CapacitySchedulerConfiguration) conf)
.getEnforcementWindow(planQueueName); .getEnforcementWindow(planQueueName);

View File

@ -357,10 +357,10 @@ private void verifyClusterSchedulerGeneric(String type, float usedCapacity,
private void verifySubQueue(JSONObject info, String q, private void verifySubQueue(JSONObject info, String q,
float parentAbsCapacity, float parentAbsMaxCapacity) float parentAbsCapacity, float parentAbsMaxCapacity)
throws JSONException, Exception { throws JSONException, Exception {
int numExpectedElements = 11; int numExpectedElements = 12;
boolean isParentQueue = true; boolean isParentQueue = true;
if (!info.has("queues")) { if (!info.has("queues")) {
numExpectedElements = 21; numExpectedElements = 22;
isParentQueue = false; isParentQueue = false;
} }
assertEquals("incorrect number of elements", numExpectedElements, info.length()); assertEquals("incorrect number of elements", numExpectedElements, info.length());