Beispiel #1
0
 public _PrivilegedExceptionAction_320(TimelineClientImpl _enclosing, object obj,
                                       string path)
 {
     this._enclosing = _enclosing;
     this.obj        = obj;
     this.path       = path;
 }
Beispiel #2
0
        private static ClientResponse MockEntityClientResponse(TimelineClientImpl client,
                                                               ClientResponse.Status status, bool hasError, bool hasRuntimeError)
        {
            ClientResponse response = Org.Mockito.Mockito.Mock <ClientResponse>();

            if (hasRuntimeError)
            {
                Org.Mockito.Mockito.DoThrow(new ClientHandlerException(new ConnectException())).When
                    (client).DoPostingObject(Matchers.Any <TimelineEntities>(), Matchers.Any <string>(
                                                 ));
                return(response);
            }
            Org.Mockito.Mockito.DoReturn(response).When(client).DoPostingObject(Matchers.Any <
                                                                                    TimelineEntities>(), Matchers.Any <string>());
            Org.Mockito.Mockito.When(response.GetClientResponseStatus()).ThenReturn(status);
            TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError
                                                             ();
            error.SetEntityId("test entity id");
            error.SetEntityType("test entity type");
            error.SetErrorCode(TimelinePutResponse.TimelinePutError.IoException);
            TimelinePutResponse putResponse = new TimelinePutResponse();

            if (hasError)
            {
                putResponse.AddError(error);
            }
            Org.Mockito.Mockito.When(response.GetEntity <TimelinePutResponse>()).ThenReturn(putResponse
                                                                                            );
            return(response);
        }
Beispiel #3
0
        public virtual void Setup()
        {
            YarnConfiguration conf = new YarnConfiguration();

            conf.SetBoolean(YarnConfiguration.TimelineServiceEnabled, true);
            client = CreateTimelineClient(conf);
        }
Beispiel #4
0
 private void AssertException(TimelineClientImpl client, RuntimeException ce)
 {
     NUnit.Framework.Assert.IsTrue("Handler exception for reason other than retry: " +
                                   ce.ToString(), ce.Message.Contains("Connection retries limit exceeded"));
     // we would expect this exception here, check if the client has retried
     NUnit.Framework.Assert.IsTrue("Retry filter didn't perform any retries! ", client
                                   .connectionRetry.GetRetired());
 }
Beispiel #5
0
        private static TimelineClientImpl CreateTimelineClient(YarnConfiguration conf)
        {
            TimelineClientImpl client = Org.Mockito.Mockito.Spy((TimelineClientImpl)TimelineClient
                                                                .CreateTimelineClient());

            client.Init(conf);
            client.Start();
            return(client);
        }
Beispiel #6
0
 public _PrivilegedExceptionAction_415(TimelineClientImpl _enclosing, Org.Apache.Hadoop.Security.Token.Token
                                       <TimelineDelegationTokenIdentifier> timelineDT, bool isTokenServiceAddrEmpty, string
                                       scheme, IPEndPoint address)
 {
     this._enclosing = _enclosing;
     this.timelineDT = timelineDT;
     this.isTokenServiceAddrEmpty = isTokenServiceAddrEmpty;
     this.scheme  = scheme;
     this.address = address;
 }
Beispiel #7
0
        public virtual void TestCheckRetryCount()
        {
            try
            {
                YarnConfiguration conf = new YarnConfiguration();
                conf.SetBoolean(YarnConfiguration.TimelineServiceEnabled, true);
                conf.SetInt(YarnConfiguration.TimelineServiceClientMaxRetries, -2);
                CreateTimelineClient(conf);
                NUnit.Framework.Assert.Fail();
            }
            catch (ArgumentException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains(YarnConfiguration.TimelineServiceClientMaxRetries
                                                                 ));
            }
            try
            {
                YarnConfiguration conf = new YarnConfiguration();
                conf.SetBoolean(YarnConfiguration.TimelineServiceEnabled, true);
                conf.SetLong(YarnConfiguration.TimelineServiceClientRetryIntervalMs, 0);
                CreateTimelineClient(conf);
                NUnit.Framework.Assert.Fail();
            }
            catch (ArgumentException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains(YarnConfiguration.TimelineServiceClientRetryIntervalMs
                                                                 ));
            }
            int  newMaxRetries       = 5;
            long newIntervalMs       = 500;
            YarnConfiguration conf_1 = new YarnConfiguration();

            conf_1.SetInt(YarnConfiguration.TimelineServiceClientMaxRetries, newMaxRetries);
            conf_1.SetLong(YarnConfiguration.TimelineServiceClientRetryIntervalMs, newIntervalMs
                           );
            conf_1.SetBoolean(YarnConfiguration.TimelineServiceEnabled, true);
            TimelineClientImpl client = CreateTimelineClient(conf_1);

            try
            {
                // This call should fail because there is no timeline server
                client.PutEntities(GenerateEntity());
                NUnit.Framework.Assert.Fail("Exception expected! " + "Timeline server should be off to run this test. "
                                            );
            }
            catch (RuntimeException ce)
            {
                NUnit.Framework.Assert.IsTrue("Handler exception for reason other than retry: " +
                                              ce.Message, ce.Message.Contains("Connection retries limit exceeded"));
                // we would expect this exception here, check if the client has retried
                NUnit.Framework.Assert.IsTrue("Retry filter didn't perform any retries! ", client
                                              .connectionRetry.GetRetired());
            }
        }
Beispiel #8
0
 /// <exception cref="System.IO.IOException"/>
 public HttpURLConnection Configure(HttpURLConnection conn)
 {
     if (conn is HttpsURLConnection)
     {
         HttpsURLConnection c = (HttpsURLConnection)conn;
         c.SetSSLSocketFactory(sf);
         c.SetHostnameVerifier(hv);
     }
     TimelineClientImpl.SetTimeouts(conn, timeout);
     return(conn);
 }
Beispiel #9
0
        private static ClientResponse MockDomainClientResponse(TimelineClientImpl client,
                                                               ClientResponse.Status status, bool hasRuntimeError)
        {
            ClientResponse response = Org.Mockito.Mockito.Mock <ClientResponse>();

            if (hasRuntimeError)
            {
                Org.Mockito.Mockito.DoThrow(new ClientHandlerException(new ConnectException())).When
                    (client).DoPostingObject(Matchers.Any <TimelineDomain>(), Matchers.Any <string>());
                return(response);
            }
            Org.Mockito.Mockito.DoReturn(response).When(client).DoPostingObject(Matchers.Any <
                                                                                    TimelineDomain>(), Matchers.Any <string>());
            Org.Mockito.Mockito.When(response.GetClientResponseStatus()).ThenReturn(status);
            return(response);
        }
Beispiel #10
0
        public virtual void TestDelegationTokenOperationsRetry()
        {
            int  newMaxRetries     = 5;
            long newIntervalMs     = 500;
            YarnConfiguration conf = new YarnConfiguration();

            conf.SetInt(YarnConfiguration.TimelineServiceClientMaxRetries, newMaxRetries);
            conf.SetLong(YarnConfiguration.TimelineServiceClientRetryIntervalMs, newIntervalMs
                         );
            conf.SetBoolean(YarnConfiguration.TimelineServiceEnabled, true);
            // use kerberos to bypass the issue in HADOOP-11215
            conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "kerberos");
            UserGroupInformation.SetConfiguration(conf);
            TimelineClientImpl client = CreateTimelineClient(conf);

            TestTimelineClient.TestTimlineDelegationTokenSecretManager dtManager = new TestTimelineClient.TestTimlineDelegationTokenSecretManager
                                                                                       ();
            try
            {
                dtManager.StartThreads();
                Sharpen.Thread.Sleep(3000);
                try
                {
                    // try getting a delegation token
                    client.GetDelegationToken(UserGroupInformation.GetCurrentUser().GetShortUserName(
                                                  ));
                    AssertFail();
                }
                catch (RuntimeException ce)
                {
                    AssertException(client, ce);
                }
                try
                {
                    // try renew a delegation token
                    TimelineDelegationTokenIdentifier timelineDT = new TimelineDelegationTokenIdentifier
                                                                       (new Text("tester"), new Text("tester"), new Text("tester"));
                    client.RenewDelegationToken(new Org.Apache.Hadoop.Security.Token.Token <TimelineDelegationTokenIdentifier
                                                                                            >(timelineDT.GetBytes(), dtManager.CreatePassword(timelineDT), timelineDT.GetKind
                                                                                                  (), new Text("0.0.0.0:8188")));
                    AssertFail();
                }
                catch (RuntimeException ce)
                {
                    AssertException(client, ce);
                }
                try
                {
                    // try cancel a delegation token
                    TimelineDelegationTokenIdentifier timelineDT = new TimelineDelegationTokenIdentifier
                                                                       (new Text("tester"), new Text("tester"), new Text("tester"));
                    client.CancelDelegationToken(new Org.Apache.Hadoop.Security.Token.Token <TimelineDelegationTokenIdentifier
                                                                                             >(timelineDT.GetBytes(), dtManager.CreatePassword(timelineDT), timelineDT.GetKind
                                                                                                   (), new Text("0.0.0.0:8188")));
                    AssertFail();
                }
                catch (RuntimeException ce)
                {
                    AssertException(client, ce);
                }
            }
            finally
            {
                client.Stop();
                dtManager.StopThreads();
            }
        }
Beispiel #11
0
 /// <exception cref="System.IO.IOException"/>
 public HttpURLConnection Configure(HttpURLConnection conn)
 {
     TimelineClientImpl.SetTimeouts(conn, TimelineClientImpl.DefaultSocketTimeout);
     return(conn);
 }
Beispiel #12
0
 internal TimelineURLConnectionFactory(TimelineClientImpl _enclosing)
 {
     this._enclosing = _enclosing;
 }
Beispiel #13
0
 public _TimelineClientRetryOp_444(TimelineClientImpl _enclosing, PrivilegedExceptionAction
                                   <object> action)
 {
     this._enclosing = _enclosing;
     this.action     = action;
 }
Beispiel #14
0
 public _PrivilegedExceptionAction_351(TimelineClientImpl _enclosing, string renewer
                                       )
 {
     this._enclosing = _enclosing;
     this.renewer    = renewer;
 }
Beispiel #15
0
 internal TimelineJerseyRetryFilter(TimelineClientImpl _enclosing)
 {
     this._enclosing = _enclosing;
 }