use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestInMemoryReservationAllocation method testZeroAlloaction.
@Test
public void testZeroAlloaction() {
ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong());
int[] alloc = {};
long start = 0;
ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length);
Map<ReservationInterval, Resource> allocations = new HashMap<ReservationInterval, Resource>();
ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc);
doAssertions(rAllocation, reservationID, rDef, allocations, (int) start, alloc);
Assert.assertFalse(rAllocation.containsGangs());
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestInMemoryReservationAllocation method testGangAlloaction.
@Test
public void testGangAlloaction() {
ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong());
int[] alloc = { 10, 10, 10, 10, 10, 10 };
int start = 100;
ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length);
boolean isGang = true;
Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, false, isGang);
ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc, isGang);
doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc);
Assert.assertTrue(rAllocation.containsGangs());
for (int i = 0; i < alloc.length; i++) {
Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rAllocation.getResourcesAtTime(start + i));
}
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class LeveldbRMStateStore method loadReservationState.
private void loadReservationState(RMState rmState) throws IOException {
int numReservations = 0;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(RM_RESERVATION_KEY_PREFIX));
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
String planReservationString = key.substring(RM_RESERVATION_KEY_PREFIX.length());
String[] parts = planReservationString.split(SEPARATOR);
if (parts.length != 2) {
LOG.warn("Incorrect reservation state key " + key);
continue;
}
String planName = parts[0];
String reservationName = parts[1];
ReservationAllocationStateProto allocationState = ReservationAllocationStateProto.parseFrom(entry.getValue());
if (!rmState.getReservationState().containsKey(planName)) {
rmState.getReservationState().put(planName, new HashMap<ReservationId, ReservationAllocationStateProto>());
}
ReservationId reservationId = ReservationId.parseReservationId(reservationName);
rmState.getReservationState().get(planName).put(reservationId, allocationState);
numReservations++;
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
LOG.info("Recovered " + numReservations + " reservations");
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class MemoryRMStateStore method storeReservationState.
@Override
protected synchronized void storeReservationState(ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) throws Exception {
LOG.info("Storing reservationallocation for " + reservationIdName + " " + "for plan " + planName);
Map<ReservationId, ReservationAllocationStateProto> planState = state.getReservationState().get(planName);
if (planState == null) {
planState = new HashMap<>();
state.getReservationState().put(planName, planState);
}
ReservationId reservationId = ReservationId.parseReservationId(reservationIdName);
planState.put(reservationId, reservationAllocation);
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestClientRMService method testUpdateReservation.
@Test
public void testUpdateReservation() {
ResourceManager rm = setupResourceManager();
ClientRMService clientService = rm.getClientRMService();
Clock clock = new UTCClock();
long arrival = clock.getTime();
long duration = 60000;
long deadline = (long) (arrival + 1.05 * duration);
ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration);
ReservationDefinition rDef = sRequest.getReservationDefinition();
ReservationRequest rr = rDef.getReservationRequests().getReservationResources().get(0);
ReservationId reservationID = sRequest.getReservationId();
rr.setNumContainers(5);
arrival = clock.getTime();
duration = 30000;
deadline = (long) (arrival + 1.05 * duration);
rr.setDuration(duration);
rDef.setArrival(arrival);
rDef.setDeadline(deadline);
ReservationUpdateRequest uRequest = ReservationUpdateRequest.newInstance(rDef, reservationID);
ReservationUpdateResponse uResponse = null;
try {
uResponse = clientService.updateReservation(uRequest);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(uResponse);
System.out.println("Update reservation response: " + uResponse);
rm.stop();
}
Aggregations