Search in sources :

Example 1 with ResourceLocalizationSpecPBImpl

use of org.apache.hadoop.yarn.server.nodemanager.api.impl.pb.ResourceLocalizationSpecPBImpl in project hadoop by apache.

the class LocalizerHeartbeatResponsePBImpl method addResourcesToProto.

private void addResourcesToProto() {
    maybeInitBuilder();
    builder.clearResources();
    if (this.resourceSpecs == null)
        return;
    Iterable<ResourceLocalizationSpecProto> iterable = new Iterable<ResourceLocalizationSpecProto>() {

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

                Iterator<ResourceLocalizationSpec> iter = resourceSpecs.iterator();

                @Override
                public boolean hasNext() {
                    return iter.hasNext();
                }

                @Override
                public ResourceLocalizationSpecProto next() {
                    ResourceLocalizationSpec resource = iter.next();
                    return ((ResourceLocalizationSpecPBImpl) resource).getProto();
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
    builder.addAllResources(iterable);
}
Also used : Iterator(java.util.Iterator) ResourceLocalizationSpec(org.apache.hadoop.yarn.server.nodemanager.api.ResourceLocalizationSpec) ResourceLocalizationSpecProto(org.apache.hadoop.yarn.proto.YarnServerNodemanagerServiceProtos.ResourceLocalizationSpecProto) ResourceLocalizationSpecPBImpl(org.apache.hadoop.yarn.server.nodemanager.api.impl.pb.ResourceLocalizationSpecPBImpl)

Aggregations

Iterator (java.util.Iterator)1 ResourceLocalizationSpecProto (org.apache.hadoop.yarn.proto.YarnServerNodemanagerServiceProtos.ResourceLocalizationSpecProto)1 ResourceLocalizationSpec (org.apache.hadoop.yarn.server.nodemanager.api.ResourceLocalizationSpec)1 ResourceLocalizationSpecPBImpl (org.apache.hadoop.yarn.server.nodemanager.api.impl.pb.ResourceLocalizationSpecPBImpl)1