Ejemplo n.º 1
0
        public IRdfeIaasClustersRestClient Create(
            HttpMessageHandler defaultHttpClientHandler,
            IHDInsightSubscriptionCredentials credentials,
            IAbstractionContext context,
            bool ignoreSslErrors)
        {
            HttpRestClientRetryPolicy retryPolicy = null;
            var tokenCreds = credentials as IHDInsightAccessTokenCredential;

            var customHandlers = new List <DelegatingHandler>();

            if (context != null && context.Logger != null)
            {
                customHandlers.Add(new HttpLoggingHandler(context.Logger));
                retryPolicy = new HttpRestClientRetryPolicy(context.RetryPolicy);
            }
            else
            {
                retryPolicy = new HttpRestClientRetryPolicy(RetryPolicyFactory.CreateExponentialRetryPolicy());
                customHandlers.Add(new HttpLoggingHandler(new Logger()));
            }

            if (tokenCreds != null)
            {
                customHandlers.Add(new BearerTokenMessageHandler(tokenCreds.AccessToken));
            }

            var httpConfiguration = new HttpRestClientConfiguration(defaultHttpClientHandler, customHandlers, retryPolicy);
            var client            = new RdfeIaasClustersRestClient(credentials.Endpoint, httpConfiguration);

            return(client);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the AbstractionContext class.
 /// </summary>
 /// <param name="token">A Cancellation token.</param>
 internal AbstractionContext(CancellationToken token)
 {
     this.userSetToken         = token;
     this.RetryPolicy          = RetryPolicyFactory.CreateExponentialRetryPolicy();
     this.useUserToken         = true;
     this.Logger               = new Logger();
     this.HttpOperationTimeout = RetryDefaultConstants.DefaultOperationTimeout;
 }
Ejemplo n.º 3
0
        public IHadoopApplicationHistoryRestClient Create(BasicAuthCredential credentials, IAbstractionContext context, bool ignoreSslErrors)
        {
            IHadoopApplicationHistoryRestReadClient readProxy = new HadoopApplicationHistoryRestReadClient(
                credentials.Server,
                new HttpRestClientConfiguration(new HadoopRestWebRequestHandler(credentials, ignoreSslErrors),
                                                new[] { new HttpLoggingHandler(context.Logger) },
                                                new HttpRestClientRetryPolicy(RetryPolicyFactory.CreateExponentialRetryPolicy())));

            return(new HadoopApplicationHistoryRestClient(readProxy));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the ClientBase class.
 /// </summary>
 /// <param name="httpOperationTimeout">The HTTP operation timeout.</param>
 /// <param name="retryPolicy">The retry policy.</param>
 protected ClientBase(TimeSpan?httpOperationTimeout, IRetryPolicy retryPolicy)
 {
     this.IgnoreSslErrors      = false;
     this.RetryPolicy          = retryPolicy ?? RetryPolicyFactory.CreateExponentialRetryPolicy();
     this.HttpOperationTimeout = httpOperationTimeout ?? RetryDefaultConstants.DefaultOperationTimeout;
     if (this.HttpOperationTimeout < TimeSpan.FromSeconds(1))
     {
         throw new ArgumentOutOfRangeException("httpOperationTimeout", "The specified HTTP Operation Timeout is too small. The minimum allowed timeout is 1 second.");
     }
     this.SetCancellationSource(Help.SafeCreate <CancellationTokenSource>());
 }
Ejemplo n.º 5
0
 internal IRetryPolicy GetRetryPolicy()
 {
     return(RetryPolicyFactory.CreateExponentialRetryPolicy(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(100), 3, 0.2));
 }
Ejemplo n.º 6
0
 public BlobClient(CloudStorageAccount cloudStorageAccount)
     : this(cloudStorageAccount, RetryPolicyFactory.CreateExponentialRetryPolicy())
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the ClientBase class.
 /// </summary>
 protected ClientBase() : this(RetryDefaultConstants.DefaultOperationTimeout, RetryPolicyFactory.CreateExponentialRetryPolicy())
 {
 }