コード例 #1
0
ファイル: MockRM.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public virtual ApplicationReport GetApplicationReport(ApplicationId appId)
        {
            ApplicationClientProtocol    client   = GetClientRMService();
            GetApplicationReportResponse response = client.GetApplicationReport(GetApplicationReportRequest
                                                                                .NewInstance(appId));

            return(response.GetApplicationReport());
        }
コード例 #2
0
ファイル: AHSClientImpl.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public override ApplicationReport GetApplicationReport(ApplicationId appId)
        {
            GetApplicationReportRequest request = GetApplicationReportRequest.NewInstance(appId
                                                                                          );
            GetApplicationReportResponse response = ahsClient.GetApplicationReport(request);

            return(response.GetApplicationReport());
        }
コード例 #3
0
        private static GetApplicationReportResponse CreateApplicationReportWithFinishedApplication
            ()
        {
            ApplicationReport report = Org.Mockito.Mockito.Mock <ApplicationReport>();

            Org.Mockito.Mockito.When(report.GetYarnApplicationState()).ThenReturn(YarnApplicationState
                                                                                  .Finished);
            GetApplicationReportResponse response = Org.Mockito.Mockito.Mock <GetApplicationReportResponse
                                                                              >();

            Org.Mockito.Mockito.When(response.GetApplicationReport()).ThenReturn(report);
            return(response);
        }
コード例 #4
0
        /// <exception cref="System.Exception"/>
        private void VerifyGetClientAMToken(string submitter, string queueAdmin, string queueName
                                            , bool setupACLs)
        {
            ApplicationId applicationId = SubmitAppAndGetAppId(submitter, queueName, setupACLs
                                                               );
            GetApplicationReportRequest appReportRequest = GetApplicationReportRequest.NewInstance
                                                               (applicationId);
            ApplicationClientProtocol    submitterClient    = GetRMClientForUser(submitter);
            ApplicationClientProtocol    adMinUserClient    = GetRMClientForUser(queueAdmin);
            GetApplicationReportResponse submitterGetReport = submitterClient.GetApplicationReport
                                                                  (appReportRequest);
            GetApplicationReportResponse adMinUserGetReport = adMinUserClient.GetApplicationReport
                                                                  (appReportRequest);

            NUnit.Framework.Assert.AreEqual(submitterGetReport.GetApplicationReport().GetClientToAMToken
                                                (), adMinUserGetReport.GetApplicationReport().GetClientToAMToken());
        }
コード例 #5
0
ファイル: YarnClientImpl.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public override ApplicationReport GetApplicationReport(ApplicationId appId)
        {
            GetApplicationReportResponse response = null;

            try
            {
                GetApplicationReportRequest request = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                                      <GetApplicationReportRequest>();
                request.SetApplicationId(appId);
                response = rmClient.GetApplicationReport(request);
            }
            catch (ApplicationNotFoundException e)
            {
                if (!historyServiceEnabled)
                {
                    // Just throw it as usual if historyService is not enabled.
                    throw;
                }
                return(historyClient.GetApplicationReport(appId));
            }
            return(response.GetApplicationReport());
        }
コード例 #6
0
        public virtual void TestApplicationReport()
        {
            ApplicationId appId = null;

            appId = ApplicationId.NewInstance(0, 1);
            GetApplicationReportRequest request = GetApplicationReportRequest.NewInstance(appId
                                                                                          );
            GetApplicationReportResponse response = clientService.GetApplicationReport(request
                                                                                       );
            ApplicationReport appReport = response.GetApplicationReport();

            NUnit.Framework.Assert.IsNotNull(appReport);
            NUnit.Framework.Assert.AreEqual(123, appReport.GetApplicationResourceUsageReport(
                                                ).GetMemorySeconds());
            NUnit.Framework.Assert.AreEqual(345, appReport.GetApplicationResourceUsageReport(
                                                ).GetVcoreSeconds());
            NUnit.Framework.Assert.AreEqual("application_0_0001", appReport.GetApplicationId(
                                                ).ToString());
            NUnit.Framework.Assert.AreEqual("test app type", appReport.GetApplicationType().ToString
                                                ());
            NUnit.Framework.Assert.AreEqual("test queue", appReport.GetQueue().ToString());
        }
コード例 #7
0
        /// <exception cref="System.Exception"/>
        public virtual void TestClientTokenRace()
        {
            conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "kerberos");
            UserGroupInformation.SetConfiguration(conf);
            ContainerManagementProtocol containerManager = Org.Mockito.Mockito.Mock <ContainerManagementProtocol
                                                                                     >();
            StartContainersResponse mockResponse = Org.Mockito.Mockito.Mock <StartContainersResponse
                                                                             >();

            Org.Mockito.Mockito.When(containerManager.StartContainers((StartContainersRequest
                                                                       )Matchers.Any())).ThenReturn(mockResponse);
            DrainDispatcher dispatcher = new DrainDispatcher();
            MockRM          rm         = new _MockRMWithCustomAMLauncher_433(dispatcher, conf, containerManager
                                                                             );

            rm.Start();
            // Submit an app
            RMApp app = rm.SubmitApp(1024);
            // Set up a node.
            MockNM nm1 = rm.RegisterNode("localhost:1234", 3072);

            nm1.NodeHeartbeat(true);
            dispatcher.Await();
            nm1.NodeHeartbeat(true);
            dispatcher.Await();
            ApplicationAttemptId appAttempt = app.GetCurrentAppAttempt().GetAppAttemptId();
            MockAM mockAM = new MockAM(rm.GetRMContext(), rm.GetApplicationMasterService(), app
                                       .GetCurrentAppAttempt().GetAppAttemptId());
            UserGroupInformation appUgi = UserGroupInformation.CreateRemoteUser(appAttempt.ToString
                                                                                    ());
            RegisterApplicationMasterResponse response = appUgi.DoAs(new _PrivilegedAction_469
                                                                         (mockAM));
            // Get the app-report.
            GetApplicationReportRequest request = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                                  <GetApplicationReportRequest>();

            request.SetApplicationId(app.GetApplicationId());
            GetApplicationReportResponse reportResponse = rm.GetClientRMService().GetApplicationReport
                                                              (request);
            ApplicationReport appReport = reportResponse.GetApplicationReport();

            Org.Apache.Hadoop.Yarn.Api.Records.Token originalClientToAMToken = appReport.GetClientToAMToken
                                                                                   ();
            // ClientToAMToken master key should have been received on register
            // application master response.
            ByteBuffer clientMasterKey = response.GetClientToAMTokenMasterKey();

            NUnit.Framework.Assert.IsNotNull(clientMasterKey);
            NUnit.Framework.Assert.IsTrue(((byte[])clientMasterKey.Array()).Length > 0);
            // Start the AM with the correct shared-secret.
            ApplicationAttemptId appAttemptId = app.GetAppAttempts().Keys.GetEnumerator().Next
                                                    ();

            NUnit.Framework.Assert.IsNotNull(appAttemptId);
            TestClientToAMTokens.CustomAM am = new TestClientToAMTokens.CustomAM(appAttemptId
                                                                                 , null);
            am.Init(conf);
            am.Start();
            // Now the real test!
            // Set up clients to be able to pick up correct tokens.
            SecurityUtil.SetSecurityInfoProviders(new TestClientToAMTokens.CustomSecurityInfo
                                                      ());
            Org.Apache.Hadoop.Security.Token.Token <ClientToAMTokenIdentifier> token = ConverterUtils
                                                                                       .ConvertFromYarn(originalClientToAMToken, am.address);
            // Schedule the key to be set after a significant delay
            Timer     timer     = new Timer();
            TimerTask timerTask = new _TimerTask_516(am, clientMasterKey);

            timer.Schedule(timerTask, 250);
            // connect should pause waiting for the master key to arrive
            VerifyValidToken(conf, am, token);
            am.Stop();
            rm.Stop();
        }
コード例 #8
0
        public virtual void TestClientToAMTokens()
        {
            conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "kerberos");
            UserGroupInformation.SetConfiguration(conf);
            ContainerManagementProtocol containerManager = Org.Mockito.Mockito.Mock <ContainerManagementProtocol
                                                                                     >();
            StartContainersResponse mockResponse = Org.Mockito.Mockito.Mock <StartContainersResponse
                                                                             >();

            Org.Mockito.Mockito.When(containerManager.StartContainers((StartContainersRequest
                                                                       )Matchers.Any())).ThenReturn(mockResponse);
            DrainDispatcher dispatcher = new DrainDispatcher();
            MockRM          rm         = new _MockRMWithCustomAMLauncher_192(dispatcher, conf, containerManager
                                                                             );

            rm.Start();
            // Submit an app
            RMApp app = rm.SubmitApp(1024);
            // Set up a node.
            MockNM nm1 = rm.RegisterNode("localhost:1234", 3072);

            nm1.NodeHeartbeat(true);
            dispatcher.Await();
            nm1.NodeHeartbeat(true);
            dispatcher.Await();
            ApplicationAttemptId appAttempt = app.GetCurrentAppAttempt().GetAppAttemptId();
            MockAM mockAM = new MockAM(rm.GetRMContext(), rm.GetApplicationMasterService(), app
                                       .GetCurrentAppAttempt().GetAppAttemptId());
            UserGroupInformation appUgi = UserGroupInformation.CreateRemoteUser(appAttempt.ToString
                                                                                    ());
            RegisterApplicationMasterResponse response = appUgi.DoAs(new _PrivilegedAction_229
                                                                         (mockAM));
            // Get the app-report.
            GetApplicationReportRequest request = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                                  <GetApplicationReportRequest>();

            request.SetApplicationId(app.GetApplicationId());
            GetApplicationReportResponse reportResponse = rm.GetClientRMService().GetApplicationReport
                                                              (request);
            ApplicationReport appReport = reportResponse.GetApplicationReport();

            Org.Apache.Hadoop.Yarn.Api.Records.Token originalClientToAMToken = appReport.GetClientToAMToken
                                                                                   ();
            // ClientToAMToken master key should have been received on register
            // application master response.
            NUnit.Framework.Assert.IsNotNull(response.GetClientToAMTokenMasterKey());
            NUnit.Framework.Assert.IsTrue(((byte[])response.GetClientToAMTokenMasterKey().Array
                                               ()).Length > 0);
            // Start the AM with the correct shared-secret.
            ApplicationAttemptId appAttemptId = app.GetAppAttempts().Keys.GetEnumerator().Next
                                                    ();

            NUnit.Framework.Assert.IsNotNull(appAttemptId);
            TestClientToAMTokens.CustomAM am = new TestClientToAMTokens.CustomAM(appAttemptId
                                                                                 , ((byte[])response.GetClientToAMTokenMasterKey().Array()));
            am.Init(conf);
            am.Start();
            // Now the real test!
            // Set up clients to be able to pick up correct tokens.
            SecurityUtil.SetSecurityInfoProviders(new TestClientToAMTokens.CustomSecurityInfo
                                                      ());
            // Verify denial for unauthenticated user
            try
            {
                TestClientToAMTokens.CustomProtocol client = (TestClientToAMTokens.CustomProtocol
                                                              )RPC.GetProxy <TestClientToAMTokens.CustomProtocol>(1L, am.address, conf);
                client.Ping();
                NUnit.Framework.Assert.Fail("Access by unauthenticated user should fail!!");
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.IsFalse(am.pinged);
            }
            Org.Apache.Hadoop.Security.Token.Token <ClientToAMTokenIdentifier> token = ConverterUtils
                                                                                       .ConvertFromYarn(originalClientToAMToken, am.address);
            // Verify denial for a malicious user with tampered ID
            VerifyTokenWithTamperedID(conf, am, token);
            // Verify denial for a malicious user with tampered user-name
            VerifyTokenWithTamperedUserName(conf, am, token);
            // Now for an authenticated user
            VerifyValidToken(conf, am, token);
            // Verify for a new version token
            VerifyNewVersionToken(conf, am, token, rm);
            am.Stop();
            rm.Stop();
        }
コード例 #9
0
ファイル: TestAHSClient.cs プロジェクト: orf53975/hadoop.net
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 public override ApplicationReport GetApplicationReport(ApplicationId appId)
 {
     Org.Mockito.Mockito.When(mockResponse.GetApplicationReport()).ThenReturn(GetReport
                                                                                  (appId));
     return(base.GetApplicationReport(appId));
 }