我目前正在开发一个项目,我们将数据存储在 Azure Datalake 上。Datalake 连接到 Azure Databricks。
该要求要求 Azure Databricks 连接到 C# 应用程序,以便能够运行查询并从 C# 应用程序获取所有结果。我们目前解决该问题的方法是在 Databricks 上创建一个工作区,其中包含许多需要执行的查询。我们创建了一个链接到上述工作区的作业。从 C# 应用程序中,我们调用本文档中列出的许多 API来调用作业实例并等待其执行。但是,我无法从文档中列出的任何 API 中提取结果。
我的问题是,我们采取了正确的方法还是有什么我们没有看到的?如果这是可行的方法,那么您在从 C# 应用程序在 Azure Databricks 上成功运行的作业中提取结果方面有何经验。
我目前正在使用 Polly 来限制我发送的请求数量。这是我目前的政策:
private AsyncPolicyWrap<HttpResponseMessage> DefineAndRetrieveResiliencyStrategy()
{
HttpStatusCode[] retryCodes = {
HttpStatusCode.InternalServerError,
HttpStatusCode.BadGateway,
HttpStatusCode.GatewayTimeout
};
var waitAndRetryPolicy = Policy
.HandleResult<HttpResponseMessage>(e => e.StatusCode == HttpStatusCode.ServiceUnavailable || e.StatusCode == (HttpStatusCode)429)
.WaitAndRetryAsync(10,
attempt => TimeSpan.FromSeconds(5), (exception, calculatedWaitDuration) =>
{
_log.Info($"Bitfinex API server is throttling our requests. Automatically delaying for {calculatedWaitDuration.TotalMilliseconds}ms");
}
);
var circuitBreakerPolicyForRecoverable = Policy
.Handle<HttpResponseException>()
.OrResult<HttpResponseMessage>(r => retryCodes.Contains(r.StatusCode))
.CircuitBreakerAsync(
handledEventsAllowedBeforeBreaking: 3,
durationOfBreak: TimeSpan.FromSeconds(3),
onBreak: (outcome, breakDelay) =>
{
_log.Info($"Polly Circuit Breaker logging: Breaking the circuit for {breakDelay.TotalMilliseconds}ms due to: {outcome.Exception?.Message ?? …Run Code Online (Sandbox Code Playgroud)