internal HDInsightJobSubmissionPocoClient(BasicAuthCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { this.remoteCreds = credentials; this.context = context; this.ignoreSslErrors = ignoreSslErrors; this.userAgentString = userAgentString ?? string.Empty; }
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; }
/// <summary> /// Initializes a new instance of the HadoopRemoteJobSubmissionRestClient class. /// </summary> /// <param name="credentials"> /// The credentials to use to connect to the server. /// </param> /// <param name="context"> /// A CancellationToken that can be used to cancel events. /// </param> /// <param name="ignoreSslErrors"> /// Specifies that server side SSL error should be ignored. /// </param> /// <param name="userAgentString">UserAgent string to pass to all calls.</param> public HadoopRemoteJobSubmissionRestClient(BasicAuthCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { this.credentials = credentials; this.context = context; this.ignoreSslErrors = ignoreSslErrors; this.userAgentString = userAgentString ?? string.Empty; }
public IRdfeServiceRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { if (credentials.Is<IHDInsightCertificateCredential>()) { return new RdfeServiceRestSimulatorClient(credentials.As<IHDInsightCertificateCredential>(), context); } return new RdfeServiceRestSimulatorClient(credentials.As<IHDInsightAccessTokenCredential>(), context); }
public HadoopJobSubmissionPocoSimulatorClient(BasicAuthCredential connectionCredentials, IAbstractionContext context, string userAgentString) { this.credentials = connectionCredentials; var server = connectionCredentials.Server.Host.Split('.')[0]; this.cluster = HDInsightManagementRestSimulatorClient.GetCloudServiceInternal(server); this.context = context; this.userAgentString = userAgentString; this.InitializeSimulator(); }
internal HttpClientAbstraction(HttpClient client, IAbstractionContext context, WebRequestHandler handler, bool ignoreSslErrors) : this(client, handler, ignoreSslErrors) { if (context.Logger.IsNotNull()) { this.instanceLogger = context.Logger; } this.cancellationToken = context.CancellationToken; }
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); }
/// <summary> /// Initializes a new instance of the AbstractionContext class. /// </summary> /// <param name="original">An abstraction context to clone.</param> public AbstractionContext(IAbstractionContext original) { if (ReferenceEquals(original, null)) { throw new ArgumentNullException("original"); } this.RetryPolicy = original.RetryPolicy; this.HttpOperationTimeout = original.HttpOperationTimeout; this.userSetToken = original.CancellationToken; this.Logger = original.Logger; }
public RdfeServiceRestSimulatorClient(IHDInsightCertificateCredential credentials, IAbstractionContext context) { var validCreds = IntegrationTestBase.GetValidCredentials() as IHDInsightCertificateCredential; if (validCreds == null || (credentials.Certificate.SubjectName != validCreds.Certificate.SubjectName && credentials.SubscriptionId != validCreds.SubscriptionId)) { throw new HttpLayerException(HttpStatusCode.Unauthorized, "User " + validCreds.SubscriptionId + " is not authorized"); } this.context = context; this.credentials = credentials; this.PollInterval = TimeSpan.FromMilliseconds(10); }
public SubscriptionRegistrationSimulatorClient(IHDInsightCertificateCredential creds, IAbstractionContext context) { this.context = context; lock (locker) { if (subcriptions == null) { subcriptions = new Dictionary<Guid, List<string>>(); subcriptions.Add(IntegrationTestBase.GetValidCredentials().SubscriptionId, new List<string> { "East US 2" }); } } this.credentials = creds; }
internal HDInsightManagementPocoClient(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { this.Context = context; this.credentials = credentials; this.ignoreSslErrors = ignoreSslErrors; if (context.IsNotNull() && context.Logger.IsNotNull()) { this.Logger = context.Logger; } else { this.Logger = new Logger(); } }
public IRdfeIaasClustersRestClient Create( IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { var defaultHttpClientHandler = new WebRequestHandler(); var certCreds = credentials as IHDInsightCertificateCredential; if (ignoreSslErrors) { defaultHttpClientHandler.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true; } if (certCreds != null) { defaultHttpClientHandler.ClientCertificates.Add(certCreds.Certificate); } return this.Create(defaultHttpClientHandler, credentials, context, ignoreSslErrors); }
public RdfeResourceTypeFinderClient(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors, string schemaVersion) { if (credentials == null) { throw new ArgumentNullException("credentials"); } if (context == null) { throw new ArgumentNullException("context"); } this.context = context; this.credentials = credentials; this.rdfeRestClient = ServiceLocator.Instance.Locate<IRdfeClustersResourceRestClientFactory>() .Create(credentials, context, ignoreSslErrors, schemaVersion); }
public IHadoopJobSubmissionPocoClient Create(IJobSubmissionClientCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { var remoteCredentials = credentials as BasicAuthCredential; if (remoteCredentials == null) { throw new NotSupportedException(); } string clusterKey = remoteCredentials.Server.AbsoluteUri.ToUpperInvariant(); if (pocoSimulators.ContainsKey(clusterKey)) { var simulator = pocoSimulators[clusterKey]; simulator.credentials = remoteCredentials; simulator.context = context; return simulator; } else { var simulator = new HadoopJobSubmissionPocoSimulatorClient(remoteCredentials, context, userAgentString); pocoSimulators.Add(clusterKey, simulator); return simulator; } }
public override IHttpClientAbstraction Create(string token, IAbstractionContext context, bool ignoreSslErrors) { return HttpClientAbstraction.Create(token, context, ignoreSslErrors); }
/// <summary> /// Executes the specified operation with the specified retry policy. /// </summary> /// <typeparam name="T">Returns an arbitrary type.</typeparam> /// <param name="function">The function to execute.</param> /// <param name="policy">The retry policy to apply to the function.</param> /// <param name="context">The abstraction context to use.</param> /// <param name="logger">An ILogger object to log retry attempts.</param> /// <returns> /// Returns the value received from the execution of the function. /// </returns> public static async Task <OperationExecutionResult <T> > ExecuteOperationWithRetry <T>(Func <Task <T> > function, IRetryPolicy policy, IAbstractionContext context, ILogger logger) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int attempt = 0; attempt < policy.MaxAttemptCount;) { try { if (attempt > 0) { logger.LogMessage(string.Format(CultureInfo.InvariantCulture, "\r\nRetrying Operation because previous attempt resulted in error. Current Retry attempt: {0}\r\n\r\n", attempt), Severity.Informational, Verbosity.Detailed); } context.CancellationToken.ThrowIfCancellationRequested(); T result = await function(); attempt++; return(new OperationExecutionResult <T>(result, stopwatch.Elapsed, attempt)); } catch (Exception e) { attempt++; var retryParams = policy.GetRetryParameters(attempt, e); //Log if (retryParams.ShouldRetry) { context.CancellationToken.WaitForInterval(retryParams.WaitTime); } else { logger.LogMessage(string.Format(CultureInfo.InvariantCulture, "\r\nOperation attempt failed because of the following error:: {0}\r\n\r\n", e.Message), Severity.Informational, Verbosity.Detailed); return(new OperationExecutionResult <T>(e, stopwatch.Elapsed, attempt)); } } } throw new InvalidOperationException("Should not reach here. Bug in retry policy implementation"); }
public ISubscriptionRegistrationClient Create(IHDInsightSubscriptionCredentials creds, IAbstractionContext context, bool ignoreSslErrors) { return new SubscriptionRegistrationSimulatorClient(creds.As<IHDInsightCertificateCredential>(), context); }
/// <summary> /// Initializes a new instance of the HDInsightSubscriptionAbstractionContext class. /// </summary> /// <param name="credentials"> /// The subscription credentials. /// </param> /// <param name="context"> /// An abstraction context to clone. /// </param> public HDInsightSubscriptionAbstractionContext(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context) : base(context) { this.Credentials = credentials; }
public RdfeServiceRestSimulatorClient(IHDInsightAccessTokenCredential credentials, IAbstractionContext context) { this.context = context; this.credentials = IntegrationTestBase.GetValidCredentials() as IHDInsightCertificateCredential; this.PollInterval = TimeSpan.FromMilliseconds(10); }
/// <inheritdoc /> public abstract IHttpClientAbstraction Create(IAbstractionContext context, bool ignoreSslErrors);
public IHDInsightManagementRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { return(new ThrowMockRestClient()); }
public IRdfeServiceRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { if (credentials.Is <IHDInsightCertificateCredential>()) { return(new RdfeServiceRestSimulatorClient(credentials.As <IHDInsightCertificateCredential>(), context)); } return(new RdfeServiceRestSimulatorClient(credentials.As <IHDInsightAccessTokenCredential>(), context)); }
public IRdfeServiceRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { return new RdfeServiceRestClient(credentials, context, ignoreSslErrors); }
public IHDInsightManagementPocoClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { var client = new TestPocoClientFlowThrough(underlying.Create(credentials, context, ignoreSslErrors)); this.Clients.Add(client); return client; }
public override IHttpClientAbstraction Create(X509Certificate2 cert, IAbstractionContext context, bool ignoreSslErrors) { return(HttpClientAbstraction.Create(cert, context, ignoreSslErrors)); }
public override IHttpClientAbstraction Create(string token, IAbstractionContext context, bool ignoreSslErrors) { return(HttpClientAbstraction.Create(token, context, ignoreSslErrors)); }
internal LocationFinderClient(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { this.context = context; this.ignoreSslErrors = ignoreSslErrors; this.credentials = credentials; }
public IHDInsightManagementRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { return new HDInsightManagementRestSimulatorClient(credentials, context); }
public override IHttpClientAbstraction Create(X509Certificate2 cert, IAbstractionContext context, bool ignoreSslErrors) { return HttpClientAbstraction.Create(cert, context, ignoreSslErrors); }
public IHadoopJobSubmissionPocoClient Create(IJobSubmissionClientCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { return(Mock); }
public IHDInsightManagementRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { return new ThrowMockRestClient(); }
/// <summary> /// Waits for the cluster to not exist (null) or go into an error state or be in one of the listed states. /// </summary> /// <param name="client"> /// The client instance this is extending. /// </param> /// <param name="notifyHandler"> /// A notification handler used to notify when the state changes. /// </param> /// <param name="dnsName"> /// The dnsName of the cluster. /// </param> /// <param name="location"> /// The location of the cluster. /// </param> /// <param name="timeout"> /// The amount of time to wait for the condition to be satisfied. /// </param> /// <param name="interval"> /// A time frame to wait between polls. /// </param> /// <param name="context"> /// A Cancelation Token that can be used to cancel the request. /// </param> /// <param name="states"> /// The set of states that would cause this funciton to terminate. /// </param> /// <returns> /// An awaitable task. /// </returns> public static async Task WaitForClusterInConditionOrError(this IHDInsightManagementPocoClient client, Action <ClusterDetails> notifyHandler, string dnsName, string location, TimeSpan timeout, TimeSpan interval, IAbstractionContext context, params ClusterState[] states) { await client.WaitForCondition(() => client.ListContainer(dnsName, location), c => client.PollSignal(c, states), notifyHandler, interval, timeout, context.CancellationToken); }
public IHadoopJobSubmissionPocoClient Create(IJobSubmissionClientCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { var remoteCredentials = credentials as BasicAuthCredential; if (remoteCredentials == null) { throw new NotSupportedException(); } string clusterKey = remoteCredentials.Server.AbsoluteUri.ToUpperInvariant(); if (pocoSimulators.ContainsKey(clusterKey)) { var simulator = pocoSimulators[clusterKey]; simulator.credentials = remoteCredentials; simulator.context = context; return(simulator); } else { var simulator = new HadoopJobSubmissionPocoSimulatorClient(remoteCredentials, context, userAgentString); pocoSimulators.Add(clusterKey, simulator); return(simulator); } }
public IHadoopJobSubmissionPocoClient Create(IJobSubmissionClientCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { return(new RemoteHadoopJobSubmissionPocoClient((BasicAuthCredential)credentials, context, ignoreSslErrors, userAgentString)); }
internal ClustersPocoClient(IHDInsightSubscriptionCredentials credentials, bool ignoreSslErrors, IAbstractionContext context, List <string> capabilities) : this(credentials, ignoreSslErrors, context, capabilities, ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>().Create(credentials, context, ignoreSslErrors, GetSchemaVersion(capabilities))) { }
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)); }
public IHadoopJobSubmissionPocoClient Create(IJobSubmissionClientCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { return Mock; }
public ISubscriptionRegistrationClient Create(IHDInsightSubscriptionCredentials creds, IAbstractionContext context, bool ignoreSslErrors) { return new SubscriptionRegistrationClient(creds, context, ignoreSslErrors); }
public IHDInsightManagementPocoClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { var client = new TestPocoClientFlowThrough(underlying.Create(credentials, context, ignoreSslErrors)); this.Clients.Add(client); return(client); }
public IVersionFinderClient Create(IHDInsightSubscriptionCredentials creds, IAbstractionContext context, bool ignoreSslErrors) { return new VersionFinderClient(creds, context, ignoreSslErrors); }
public static IHttpClientAbstraction Create(IAbstractionContext context) { return(Create(context, false)); }
public VersionFinderClient(IHDInsightSubscriptionCredentials creds, IAbstractionContext context, bool ignoreSslErrors) { this.context = context; this.ignoreSslErrors = ignoreSslErrors; this.credentials = creds; }
public static IHttpClientAbstraction Create(X509Certificate2 cert, IAbstractionContext context) { return(Create(cert, context, false)); }
public RdfeResourceTypeFinderClient(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors, string schemaVersion) { if (credentials == null) { throw new ArgumentNullException("credentials"); } if (context == null) { throw new ArgumentNullException("context"); } this.context = context; this.credentials = credentials; this.rdfeRestClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(credentials, context, ignoreSslErrors, schemaVersion); }
public static IHttpClientAbstraction Create(string accessToken, IAbstractionContext context) { return(Create(accessToken, context, false)); }
public IHadoopJobSubmissionRestClient Create(IJobSubmissionClientCredential credentials, IAbstractionContext context, bool ignoreSslErrors, string userAgentString) { return new HadoopRemoteJobSubmissionRestClient((BasicAuthCredential)credentials, context, ignoreSslErrors, userAgentString); }
internal RdfeServiceRestClient(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { this.context = context; this.ignoreSslErrors = ignoreSslErrors; this.credentials = credentials; }
public static IHttpClientAbstraction Create(IAbstractionContext context, bool ignoreSslErrors) { var handler = new WebRequestHandler(); return(Help.SafeCreate(() => new HttpClientAbstraction(Help.SafeCreate(() => new HttpClient(handler)), context, handler, ignoreSslErrors))); }
/// <summary> /// Creates an instance IRdfeResourceTypeFinderClient using the specified credentials. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="context">The context that can be used to cancel the task.</param> /// <param name="ignoreSslErrors">If set to <c>true</c> ignore SSL errors.</param> /// <param name="schemaVersion">The schema version.</param> /// <returns> /// An instance of IRdfeResourceTypeFinderClient. /// </returns> public IRdfeResourceTypeFinderClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors, string schemaVersion) { return(new RdfeResourceTypeFinderClient(credentials, context, ignoreSslErrors, schemaVersion)); }
public IHDInsightJobSubmissionRestClient Create(IHDInsightSubscriptionCredentials credentials, IAbstractionContext context, bool ignoreSslErrors) { return new HDInsightJobSubmissionRestClient(credentials, context, ignoreSslErrors); }