use of org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto 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