Search in sources :

Example 1 with ResourceAllocationRequestProto

use of org.apache.hadoop.yarn.proto.YarnProtos.ResourceAllocationRequestProto 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;
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) ResourceAllocationRequestProto(org.apache.hadoop.yarn.proto.YarnProtos.ResourceAllocationRequestProto) ReservationDefinitionProto(org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto) HashMap(java.util.HashMap) Map(java.util.Map) ReservationAllocationStateProto(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)

Example 2 with ResourceAllocationRequestProto

use of org.apache.hadoop.yarn.proto.YarnProtos.ResourceAllocationRequestProto in project hadoop by apache.

the class ReservationAllocationStatePBImpl method initResourceAllocations.

private void initResourceAllocations() {
    if (this.resourceAllocations != null) {
        return;
    }
    ReservationAllocationStateProtoOrBuilder p = viaProto ? proto : builder;
    List<ResourceAllocationRequestProto> resourceAllocationProtos = p.getAllocationRequestsList();
    resourceAllocations = new ArrayList<>();
    for (ResourceAllocationRequestProto r : resourceAllocationProtos) {
        resourceAllocations.add(convertFromProtoFormat(r));
    }
}
Also used : ReservationAllocationStateProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProtoOrBuilder) ResourceAllocationRequestProto(org.apache.hadoop.yarn.proto.YarnProtos.ResourceAllocationRequestProto)

Aggregations

ResourceAllocationRequestProto (org.apache.hadoop.yarn.proto.YarnProtos.ResourceAllocationRequestProto)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 ReservationAllocationStateProto (org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto)1 ReservationAllocationStateProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProtoOrBuilder)1 ReservationDefinitionProto (org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto)1