use of org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto in project hadoop by apache.
the class ContainerManagerImpl method buildAppProto.
private ContainerManagerApplicationProto buildAppProto(ApplicationId appId, String user, Credentials credentials, Map<ApplicationAccessType, String> appAcls, LogAggregationContext logAggregationContext) {
ContainerManagerApplicationProto.Builder builder = ContainerManagerApplicationProto.newBuilder();
builder.setId(((ApplicationIdPBImpl) appId).getProto());
builder.setUser(user);
if (logAggregationContext != null) {
builder.setLogAggregationContext(((LogAggregationContextPBImpl) logAggregationContext).getProto());
}
builder.clearCredentials();
if (credentials != null) {
DataOutputBuffer dob = new DataOutputBuffer();
try {
credentials.writeTokenStorageToStream(dob);
builder.setCredentials(ByteString.copyFrom(dob.getData()));
} catch (IOException e) {
// should not occur
LOG.error("Cannot serialize credentials", e);
}
}
builder.clearAcls();
if (appAcls != null) {
for (Map.Entry<ApplicationAccessType, String> acl : appAcls.entrySet()) {
ApplicationACLMapProto p = ApplicationACLMapProto.newBuilder().setAccessType(ProtoUtils.convertToProtoFormat(acl.getKey())).setAcl(acl.getValue()).build();
builder.addAcls(p);
}
}
return builder.build();
}
use of org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto in project hadoop by apache.
the class ContainerManagerImpl method recoverApplication.
private void recoverApplication(ContainerManagerApplicationProto p) throws IOException {
ApplicationId appId = new ApplicationIdPBImpl(p.getId());
Credentials creds = new Credentials();
creds.readTokenStorageStream(new DataInputStream(p.getCredentials().newInput()));
List<ApplicationACLMapProto> aclProtoList = p.getAclsList();
Map<ApplicationAccessType, String> acls = new HashMap<ApplicationAccessType, String>(aclProtoList.size());
for (ApplicationACLMapProto aclProto : aclProtoList) {
acls.put(ProtoUtils.convertFromProtoFormat(aclProto.getAccessType()), aclProto.getAcl());
}
LogAggregationContext logAggregationContext = null;
if (p.getLogAggregationContext() != null) {
logAggregationContext = new LogAggregationContextPBImpl(p.getLogAggregationContext());
}
LOG.info("Recovering application " + appId);
//TODO: Recover flow and flow run ID
ApplicationImpl app = new ApplicationImpl(dispatcher, p.getUser(), appId, creds, context, p.getAppLogAggregationInitedTime());
context.getApplications().put(appId, app);
app.handle(new ApplicationInitEvent(appId, acls, logAggregationContext));
}
use of org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto in project hadoop by apache.
the class RegisterApplicationMasterResponsePBImpl method initApplicationACLs.
private void initApplicationACLs() {
if (this.applicationACLS != null) {
return;
}
RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder;
List<ApplicationACLMapProto> list = p.getApplicationACLsList();
this.applicationACLS = new HashMap<ApplicationAccessType, String>(list.size());
for (ApplicationACLMapProto aclProto : list) {
this.applicationACLS.put(ProtoUtils.convertFromProtoFormat(aclProto.getAccessType()), aclProto.getAcl());
}
}
use of org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto in project hadoop by apache.
the class RegisterApplicationMasterResponsePBImpl method addApplicationACLs.
private void addApplicationACLs() {
maybeInitBuilder();
builder.clearApplicationACLs();
if (applicationACLS == null) {
return;
}
Iterable<? extends ApplicationACLMapProto> values = new Iterable<ApplicationACLMapProto>() {
@Override
public Iterator<ApplicationACLMapProto> iterator() {
return new Iterator<ApplicationACLMapProto>() {
Iterator<ApplicationAccessType> aclsIterator = applicationACLS.keySet().iterator();
@Override
public boolean hasNext() {
return aclsIterator.hasNext();
}
@Override
public ApplicationACLMapProto next() {
ApplicationAccessType key = aclsIterator.next();
return ApplicationACLMapProto.newBuilder().setAcl(applicationACLS.get(key)).setAccessType(ProtoUtils.convertToProtoFormat(key)).build();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
this.builder.addAllApplicationACLs(values);
}
use of org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto in project hadoop by apache.
the class ContainerLaunchContextPBImpl method initApplicationACLs.
private void initApplicationACLs() {
if (this.applicationACLS != null) {
return;
}
ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
List<ApplicationACLMapProto> list = p.getApplicationACLsList();
this.applicationACLS = new HashMap<ApplicationAccessType, String>(list.size());
for (ApplicationACLMapProto aclProto : list) {
this.applicationACLS.put(ProtoUtils.convertFromProtoFormat(aclProto.getAccessType()), aclProto.getAcl());
}
}
Aggregations