use of org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto 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.proto.YarnProtos.ReservationAllocationStateProto 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.proto.YarnProtos.ReservationAllocationStateProto in project hadoop by apache.
the class ReservationListResponsePBImpl method initReservations.
private void initReservations() {
if (this.reservations != null) {
return;
}
ReservationListResponseProtoOrBuilder p = viaProto ? proto : builder;
List<ReservationAllocationStateProto> reservationProtos = p.getReservationsList();
reservations = new ArrayList<>();
for (ReservationAllocationStateProto r : reservationProtos) {
reservations.add(convertFromProtoFormat(r));
}
}
use of org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto in project hadoop by apache.
the class AbstractReservationSystem method loadPlan.
private void loadPlan(String planName, Map<ReservationId, ReservationAllocationStateProto> reservations) throws PlanningException {
Plan plan = plans.get(planName);
Resource minAllocation = getMinAllocation();
ResourceCalculator rescCalculator = getResourceCalculator();
for (Entry<ReservationId, ReservationAllocationStateProto> currentReservation : reservations.entrySet()) {
plan.addReservation(ReservationSystemUtil.toInMemoryAllocation(planName, currentReservation.getKey(), currentReservation.getValue(), minAllocation, rescCalculator), true);
resQMap.put(currentReservation.getKey(), planName);
}
LOG.info("Recovered reservations for Plan: {}", planName);
}
use of org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto in project hadoop by apache.
the class ReservationSystemUtil method buildStateProto.
public static ReservationAllocationStateProto buildStateProto(ReservationAllocation allocation) {
ReservationAllocationStateProto.Builder builder = ReservationAllocationStateProto.newBuilder();
builder.setAcceptanceTime(allocation.getAcceptanceTime());
builder.setContainsGangs(allocation.containsGangs());
builder.setStartTime(allocation.getStartTime());
builder.setEndTime(allocation.getEndTime());
builder.setUser(allocation.getUser());
ReservationDefinitionProto definitionProto = convertToProtoFormat(allocation.getReservationDefinition());
builder.setReservationDefinition(definitionProto);
for (Map.Entry<ReservationInterval, Resource> entry : allocation.getAllocationRequests().entrySet()) {
ResourceAllocationRequestProto p = ResourceAllocationRequestProto.newBuilder().setStartTime(entry.getKey().getStartTime()).setEndTime(entry.getKey().getEndTime()).setResource(convertToProtoFormat(entry.getValue())).build();
builder.addAllocationRequests(p);
}
ReservationAllocationStateProto allocationProto = builder.build();
return allocationProto;
}
Aggregations