Search in sources :

Example 1 with NodeIdProto

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

the class GetLabelsToNodesResponsePBImpl method initLabelsToNodes.

private void initLabelsToNodes() {
    if (this.labelsToNodes != null) {
        return;
    }
    GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder;
    List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList();
    this.labelsToNodes = new HashMap<String, Set<NodeId>>();
    for (LabelsToNodeIdsProto c : list) {
        Set<NodeId> setNodes = new HashSet<NodeId>();
        for (NodeIdProto n : c.getNodeIdList()) {
            NodeId node = new NodeIdPBImpl(n);
            setNodes.add(node);
        }
        if (!setNodes.isEmpty()) {
            this.labelsToNodes.put(c.getNodeLabels(), setNodes);
        }
    }
}
Also used : GetLabelsToNodesResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProtoOrBuilder) Set(java.util.Set) HashSet(java.util.HashSet) NodeId(org.apache.hadoop.yarn.api.records.NodeId) NodeIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl) NodeIdProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto) LabelsToNodeIdsProto(org.apache.hadoop.yarn.proto.YarnProtos.LabelsToNodeIdsProto) HashSet(java.util.HashSet)

Example 2 with NodeIdProto

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

the class GetLabelsToNodesResponsePBImpl method addLabelsToNodesToProto.

private void addLabelsToNodesToProto() {
    maybeInitBuilder();
    builder.clearLabelsToNodes();
    if (labelsToNodes == null) {
        return;
    }
    Iterable<LabelsToNodeIdsProto> iterable = new Iterable<LabelsToNodeIdsProto>() {

        @Override
        public Iterator<LabelsToNodeIdsProto> iterator() {
            return new Iterator<LabelsToNodeIdsProto>() {

                Iterator<Entry<String, Set<NodeId>>> iter = labelsToNodes.entrySet().iterator();

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public LabelsToNodeIdsProto next() {
                    Entry<String, Set<NodeId>> now = iter.next();
                    Set<NodeIdProto> nodeProtoSet = new HashSet<NodeIdProto>();
                    for (NodeId n : now.getValue()) {
                        nodeProtoSet.add(convertToProtoFormat(n));
                    }
                    return LabelsToNodeIdsProto.newBuilder().setNodeLabels(now.getKey()).addAllNodeId(nodeProtoSet).build();
                }

                @Override
                public boolean hasNext() {
                    return iter.hasNext();
                }
            };
        }
    };
    builder.addAllLabelsToNodes(iterable);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) NodeId(org.apache.hadoop.yarn.api.records.NodeId) NodeIdProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto) LabelsToNodeIdsProto(org.apache.hadoop.yarn.proto.YarnProtos.LabelsToNodeIdsProto) HashSet(java.util.HashSet)

Example 3 with NodeIdProto

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

the class CheckForDecommissioningNodesResponsePBImpl method addDecommissioningNodesToProto.

private void addDecommissioningNodesToProto() {
    maybeInitBuilder();
    builder.clearDecommissioningNodes();
    if (this.decommissioningNodes == null)
        return;
    Set<NodeIdProto> nodeIdProtos = new HashSet<NodeIdProto>();
    for (NodeId nodeId : decommissioningNodes) {
        nodeIdProtos.add(convertToProtoFormat(nodeId));
    }
    builder.addAllDecommissioningNodes(nodeIdProtos);
}
Also used : NodeId(org.apache.hadoop.yarn.api.records.NodeId) NodeIdProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto) HashSet(java.util.HashSet)

Example 4 with NodeIdProto

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

the class CheckForDecommissioningNodesResponsePBImpl method initNodesDecommissioning.

private void initNodesDecommissioning() {
    if (this.decommissioningNodes != null) {
        return;
    }
    CheckForDecommissioningNodesResponseProtoOrBuilder p = viaProto ? proto : builder;
    List<NodeIdProto> nodeIds = p.getDecommissioningNodesList();
    this.decommissioningNodes = new HashSet<NodeId>();
    for (NodeIdProto nodeIdProto : nodeIds) {
        this.decommissioningNodes.add(convertFromProtoFormat(nodeIdProto));
    }
}
Also used : CheckForDecommissioningNodesResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.CheckForDecommissioningNodesResponseProtoOrBuilder) NodeId(org.apache.hadoop.yarn.api.records.NodeId) NodeIdProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto)

Example 5 with NodeIdProto

use of org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto in project incubator-myriad by apache.

the class OfferLifeCycleManagerTest method setUp.

@Before
public void setUp() throws Exception {
    NodeStore store = new NodeStore();
    NodeIdProto nodeId = NodeIdProto.newBuilder().setHost("localhost").setPort(8000).build();
    RMNode rmNode = new RMNodeImpl(new NodeIdPBImpl(nodeId), new MockRMContext(), "localhost", 8000, 8070, new NodeBase(), new ResourcePBImpl(), "1.0");
    SchedulerNode node = new FiCaSchedulerNode(rmNode, false);
    store.add(node);
    manager = new OfferLifecycleManager(store, new MyriadDriver(new MockSchedulerDriver()));
}
Also used : MyriadDriver(org.apache.myriad.scheduler.MyriadDriver) MockRMContext(org.apache.myriad.state.MockRMContext) FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) SchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode) FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) NodeIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl) NodeIdProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto) ResourcePBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl) NodeBase(org.apache.hadoop.net.NodeBase) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) RMNodeImpl(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeImpl) MockSchedulerDriver(org.apache.myriad.scheduler.MockSchedulerDriver) Before(org.junit.Before)

Aggregations

NodeIdProto (org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto)5 NodeId (org.apache.hadoop.yarn.api.records.NodeId)4 HashSet (java.util.HashSet)3 Set (java.util.Set)2 NodeIdPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl)2 LabelsToNodeIdsProto (org.apache.hadoop.yarn.proto.YarnProtos.LabelsToNodeIdsProto)2 Iterator (java.util.Iterator)1 NodeBase (org.apache.hadoop.net.NodeBase)1 ResourcePBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl)1 CheckForDecommissioningNodesResponseProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.CheckForDecommissioningNodesResponseProtoOrBuilder)1 GetLabelsToNodesResponseProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProtoOrBuilder)1 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)1 RMNodeImpl (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeImpl)1 SchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode)1 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)1 MockSchedulerDriver (org.apache.myriad.scheduler.MockSchedulerDriver)1 MyriadDriver (org.apache.myriad.scheduler.MyriadDriver)1 MockRMContext (org.apache.myriad.state.MockRMContext)1 Before (org.junit.Before)1