use of org.apache.hadoop.yarn.api.records.ReservationRequest in project hadoop by apache.
the class ReservationSystemTestUtil method createSimpleReservationRequest.
public static ReservationSubmissionRequest createSimpleReservationRequest(ReservationId reservationId, int numContainers, long arrival, long deadline, long duration, Priority priority) {
// create a request with a single atomic ask
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
ReservationRequests reqs = ReservationRequests.newInstance(Collections.singletonList(r), ReservationRequestInterpreter.R_ALL);
ReservationDefinition rDef = ReservationDefinition.newInstance(arrival, deadline, reqs, "testClientRMService#reservation", "0", priority);
ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, reservationQ, reservationId);
return request;
}
use of org.apache.hadoop.yarn.api.records.ReservationRequest in project hadoop by apache.
the class ReservationSystemTestUtil method generateRandomRR.
public static ReservationDefinition generateRandomRR(Random rand, long i) {
rand.setSeed(i);
long now = System.currentTimeMillis();
// start time at random in the next 12 hours
long arrival = rand.nextInt(12 * 3600 * 1000);
// deadline at random in the next day
long deadline = arrival + rand.nextInt(24 * 3600 * 1000);
// create a request with a single atomic ask
ReservationDefinition rr = new ReservationDefinitionPBImpl();
rr.setArrival(now + arrival);
rr.setDeadline(now + deadline);
int gang = 1 + rand.nextInt(9);
int par = (rand.nextInt(1000) + 1) * gang;
// random duration within 2h
long dur = rand.nextInt(2 * 3600 * 1000);
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), par, gang, dur);
ReservationRequests reqs = new ReservationRequestsPBImpl();
reqs.setReservationResources(Collections.singletonList(r));
rand.nextInt(3);
ReservationRequestInterpreter[] type = ReservationRequestInterpreter.values();
reqs.setInterpreter(type[rand.nextInt(type.length)]);
rr.setReservationRequests(reqs);
return rr;
}
use of org.apache.hadoop.yarn.api.records.ReservationRequest in project hadoop by apache.
the class TestInMemoryPlan method createSimpleReservationDefinition.
private ReservationDefinition createSimpleReservationDefinition(long arrival, long deadline, long duration, Collection<ReservationRequest> resources) {
// create a request with a single atomic ask
ReservationDefinition rDef = new ReservationDefinitionPBImpl();
ReservationRequests reqs = new ReservationRequestsPBImpl();
reqs.setReservationResources(new ArrayList<ReservationRequest>(resources));
reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
rDef.setReservationRequests(reqs);
rDef.setArrival(arrival);
rDef.setDeadline(deadline);
return rDef;
}
use of org.apache.hadoop.yarn.api.records.ReservationRequest in project hadoop by apache.
the class TestInMemoryReservationAllocation method generateAllocation.
private Map<ReservationInterval, Resource> generateAllocation(int startTime, int[] alloc, boolean isStep, boolean isGang) {
Map<ReservationInterval, Resource> req = new HashMap<ReservationInterval, Resource>();
int numContainers = 0;
for (int i = 0; i < alloc.length; i++) {
if (isStep) {
numContainers = alloc[i] + i;
} else {
numContainers = alloc[i];
}
ReservationRequest rr = ReservationRequest.newInstance(Resource.newInstance(1024, 1), (numContainers));
if (isGang) {
rr.setConcurrency(numContainers);
}
req.put(new ReservationInterval(startTime + i, startTime + i + 1), ReservationSystemUtil.toResource(rr));
}
return req;
}
use of org.apache.hadoop.yarn.api.records.ReservationRequest in project hadoop by apache.
the class TestReservationInputValidator method createSimpleReservationUpdateRequest.
private ReservationUpdateRequest createSimpleReservationUpdateRequest(int numRequests, int numContainers, long arrival, long deadline, long duration) {
// create a request with a single atomic ask
ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
ReservationDefinition rDef = new ReservationDefinitionPBImpl();
rDef.setArrival(arrival);
rDef.setDeadline(deadline);
if (numRequests > 0) {
ReservationRequests reqs = new ReservationRequestsPBImpl();
rDef.setReservationRequests(reqs);
if (numContainers > 0) {
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(1024, 1), numContainers, 1, duration);
reqs.setReservationResources(Collections.singletonList(r));
reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
}
}
request.setReservationDefinition(rDef);
request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
return request;
}
Aggregations