Search in sources :

Example 1 with ApplicationACLMapProto

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();
}
Also used : ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) ApplicationACLMapProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) IOException(java.io.IOException) ByteString(com.google.protobuf.ByteString) ContainerManagerApplicationProto(org.apache.hadoop.yarn.proto.YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with ApplicationACLMapProto

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));
}
Also used : HashMap(java.util.HashMap) ApplicationImpl(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationImpl) ApplicationInitEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationInitEvent) ByteString(com.google.protobuf.ByteString) DataInputStream(java.io.DataInputStream) LogAggregationContextPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.LogAggregationContextPBImpl) ApplicationIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl) ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) ApplicationACLMapProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Credentials(org.apache.hadoop.security.Credentials) LogAggregationContext(org.apache.hadoop.yarn.api.records.LogAggregationContext)

Example 3 with ApplicationACLMapProto

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());
    }
}
Also used : RegisterApplicationMasterResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder) ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) ApplicationACLMapProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto) ByteString(com.google.protobuf.ByteString)

Example 4 with ApplicationACLMapProto

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);
}
Also used : ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) ApplicationACLMapProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto)

Example 5 with ApplicationACLMapProto

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());
    }
}
Also used : ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) ApplicationACLMapProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto) ByteString(com.google.protobuf.ByteString) ContainerLaunchContextProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder)

Aggregations

ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)6 ApplicationACLMapProto (org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto)6 ByteString (com.google.protobuf.ByteString)4 HashMap (java.util.HashMap)2 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)1 Credentials (org.apache.hadoop.security.Credentials)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 LogAggregationContext (org.apache.hadoop.yarn.api.records.LogAggregationContext)1 ApplicationIdPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl)1 LogAggregationContextPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.LogAggregationContextPBImpl)1 ContainerLaunchContextProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder)1 ContainerManagerApplicationProto (org.apache.hadoop.yarn.proto.YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto)1 RegisterApplicationMasterResponseProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder)1 ApplicationImpl (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationImpl)1 ApplicationInitEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationInitEvent)1