Search in sources :

Example 1 with StringLocalResourceMapProto

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

the class ContainerLaunchContextPBImpl method addLocalResourcesToProto.

private void addLocalResourcesToProto() {
    maybeInitBuilder();
    builder.clearLocalResources();
    if (localResources == null)
        return;
    Iterable<StringLocalResourceMapProto> iterable = new Iterable<StringLocalResourceMapProto>() {

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

                Iterator<String> keyIter = localResources.keySet().iterator();

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

                @Override
                public StringLocalResourceMapProto next() {
                    String key = keyIter.next();
                    return StringLocalResourceMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(localResources.get(key))).build();
                }

                @Override
                public boolean hasNext() {
                    return keyIter.hasNext();
                }
            };
        }
    };
    builder.addAllLocalResources(iterable);
}
Also used : Iterator(java.util.Iterator) ByteString(com.google.protobuf.ByteString) StringLocalResourceMapProto(org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto)

Example 2 with StringLocalResourceMapProto

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

the class ContainerLaunchContextPBImpl method initLocalResources.

private void initLocalResources() {
    if (this.localResources != null) {
        return;
    }
    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
    List<StringLocalResourceMapProto> list = p.getLocalResourcesList();
    this.localResources = new HashMap<String, LocalResource>();
    for (StringLocalResourceMapProto c : list) {
        this.localResources.put(c.getKey(), convertFromProtoFormat(c.getValue()));
    }
}
Also used : ByteString(com.google.protobuf.ByteString) ContainerLaunchContextProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder) StringLocalResourceMapProto(org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource)

Aggregations

ByteString (com.google.protobuf.ByteString)2 StringLocalResourceMapProto (org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto)2 Iterator (java.util.Iterator)1 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)1 ContainerLaunchContextProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder)1