Search in sources :

Example 1 with StringStringMapProto

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

the class ContainerLaunchContextPBImpl method addEnvToProto.

private void addEnvToProto() {
    maybeInitBuilder();
    builder.clearEnvironment();
    if (environment == null)
        return;
    Iterable<StringStringMapProto> iterable = new Iterable<StringStringMapProto>() {

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

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

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

                @Override
                public StringStringMapProto next() {
                    String key = keyIter.next();
                    String value = environment.get(key);
                    if (value == null) {
                        value = "";
                    }
                    return StringStringMapProto.newBuilder().setKey(key).setValue((value)).build();
                }

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

Example 2 with StringStringMapProto

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

the class ContainerLaunchContextPBImpl method initEnv.

private void initEnv() {
    if (this.environment != null) {
        return;
    }
    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
    List<StringStringMapProto> list = p.getEnvironmentList();
    this.environment = new HashMap<String, String>();
    for (StringStringMapProto c : list) {
        this.environment.put(c.getKey(), c.getValue());
    }
}
Also used : StringStringMapProto(org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto) ByteString(com.google.protobuf.ByteString) ContainerLaunchContextProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder)

Aggregations

ByteString (com.google.protobuf.ByteString)2 StringStringMapProto (org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto)2 Iterator (java.util.Iterator)1 ContainerLaunchContextProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder)1