Something along the following lines would do:
-----
UserGroupInformation ugi = //get your UGI
...
YarnClient yarnClient = YarnClient.createYarnClient();
yarnClient.init(yarnConf);
yarnClient.start();
YarnClientApplication app = yarnClient.createApplication();
ApplicationSubmissionContext appCtx
=Records.newRecord(ApplicationSubmissionContext.class);
appCtx.setApplicationId(appId);
appCtx.setUnmanagedAM(true);
// other settings to appCtx
ApplicationId appId = yarnClient.submitApplication(appContext);
// wait until application state is ACCEPTED
ugi.addToken(yarnClient.getAMRMToken(appId));
-----
thx
On Mon, Jan 27, 2014 at 10:49 AM, Sujeet Varakhedi <[email protected]
> wrote:
> Hi All,
> I am not sure if this is the right alias to ask this question. Let me know
> if there is any other for these type of questions.
> I am trying to create an Unmanaged ApplicationMaster and having issues with
> creating AMRMtokens right. I peeked into the TestAMRMtokens.java test cases
> and here is what I have come up with. (This is scala code)
>
>
> *def getNextAttemptid() : ApplicationAttemptId = {*
> * val t = java.lang.System.currentTimeMillis()*
> *
>
> ConverterUtils.toApplicationAttemptId(ConverterUtils.APPLICATION_ATTEMPT_PREFIX
> + "_" + t.toString() + "_0001" + "_0001")*
> * }*
>
> * appAttemptId = getNextAttemptid()*
>
>
> * UserGroupInformation.setConfiguration(yarnConf)*
> * val ugi = UserGroupInformation.getCurrentUser()*
> * val tokenIdentifier = new AMRMTokenIdentifier(appAttemptId)*
> * val secretManager = new AMRMTokenSecretManager(yarnConf)*
> * val token: Token[_ <: TokenIdentifier] = new
> Token[AMRMTokenIdentifier](tokenIdentifier, secretManager)*
> * ugi.addToken(token)*
>
> * amClient = AMRMClient.createAMRMClient()*
> * amClient.init(yarnConf)*
> * amClient.start()*
> * val appMasterResponse =
> amClient.registerApplicationMaster("localhost", 0, "") *
>
>
>
>
> Yarn does not like this request and says:
> 2014-01-27 10:47:10,938 WARN SecurityLogger.org.apache.hadoop.ipc.Server:
> Auth failed for 127.0.0.1:63085:null (DIGEST-MD5: IO error acquiring
> password)
> 2014-01-27 10:47:10,938 INFO org.apache.hadoop.ipc.Server: IPC Server
> listener on 8030: readAndProcess from client 127.0.0.1 threw exception
> [org.apache.hadoop.security.token.SecretManager$InvalidToken: Password not
> found for ApplicationAttempt appattempt_1390848430314_0001_000001]
>
>
> I am sure I am doing something wrong. Is a documentation or example code
> that tells how to create the tokens right?
>
> Thanks in advance
>
> Sujeet
>
--
Alejandro