Search in sources :

Example 6 with IncreaseContainersResourceResponse

use of org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse in project hadoop by apache.

the class TestContainerManagerRecovery method increaseContainersResource.

private IncreaseContainersResourceResponse increaseContainersResource(Context context, final ContainerManagerImpl cm, ContainerId cid, Resource capability) throws Exception {
    UserGroupInformation user = UserGroupInformation.createRemoteUser(cid.getApplicationAttemptId().toString());
    // construct container resource increase request
    final List<Token> increaseTokens = new ArrayList<Token>();
    // add increase request
    Token containerToken = TestContainerManager.createContainerToken(cid, 0, context.getNodeId(), user.getShortUserName(), capability, context.getContainerTokenSecretManager(), null);
    increaseTokens.add(containerToken);
    final IncreaseContainersResourceRequest increaseRequest = IncreaseContainersResourceRequest.newInstance(increaseTokens);
    NMTokenIdentifier nmToken = new NMTokenIdentifier(cid.getApplicationAttemptId(), context.getNodeId(), user.getShortUserName(), context.getNMTokenSecretManager().getCurrentKey().getKeyId());
    user.addTokenIdentifier(nmToken);
    return user.doAs(new PrivilegedExceptionAction<IncreaseContainersResourceResponse>() {

        @Override
        public IncreaseContainersResourceResponse run() throws Exception {
            return cm.increaseContainersResource(increaseRequest);
        }
    });
}
Also used : NMTokenIdentifier(org.apache.hadoop.yarn.security.NMTokenIdentifier) ArrayList(java.util.ArrayList) IncreaseContainersResourceRequest(org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest) Token(org.apache.hadoop.yarn.api.records.Token) IncreaseContainersResourceResponse(org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) UnsupportedFileSystemException(org.apache.hadoop.fs.UnsupportedFileSystemException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

IncreaseContainersResourceResponse (org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse)6 ArrayList (java.util.ArrayList)5 IncreaseContainersResourceRequest (org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest)5 Token (org.apache.hadoop.yarn.api.records.Token)5 HashMap (java.util.HashMap)4 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)4 Test (org.junit.Test)4 File (java.io.File)3 PrintWriter (java.io.PrintWriter)3 Path (org.apache.hadoop.fs.Path)3 StartContainerRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)3 StartContainersRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)3 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)3 URL (org.apache.hadoop.yarn.api.records.URL)3 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)3 Map (java.util.Map)2 StartContainersResponse (org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse)2 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2