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);
}
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());
}
}
Aggregations