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