sách gpt4 ai đã đi

c# - .NET HBase REST API 客户端库 - 从 MVC5 Controller 调用

In lại 作者:可可西里 更新时间:2023-11-01 15:13:20 27 4
mua khóa gpt4 Nike

查看 https://azure.microsoft.com/en-us/documentation/articles/hdinsight-hbase-tutorial-get-started/#use-the-net-hbase-rest-api-client-library 上给出的示例代码,

我尝试从 MVC Controller 连接到 HBase,如下所示:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;

using Microsoft.HBase.Client;
using org.apache.hadoop.hbase.rest.protobuf.generated;

namespace MyHBaseTest.Controllers
{
[RoutePrefix("api/myhbasetestcontroller")]
public class MyHBaseTestController : ApiController
{
HBaseReader hbase = new HBaseReader();

[HttpGet]
[Route("")]
public IHttpActionResult Index()
{

string clusterURL = "https://.azurehdinsight.net";
string hadoopUsername = "";
string hadoopUserPassword = "";

// Create a new instance of an HBase client.
ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword);
HBaseClient hbaseClient = new HBaseClient(creds);

// Retrieve the cluster version
var version = hbaseClient.GetVersion();
Console.WriteLine("The HBase cluster version is " + version);

return Ok();
}
}
}

当我尝试在浏览器中以 Debug模式运行时查看 URL/api/myhbasetestcontroller 时,它会永远加载页面,而不会在 Visual Studio 中抛出任何异常或任何内容。我已经等了 15-20 分钟,但没有任何变化。

当我尝试在控制台应用程序中执行相同操作时,它会在几秒钟内获取版本信息:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.HBase.Client;
using org.apache.hadoop.hbase.rest.protobuf.generated;

namespace ConsoleApplication1
{
class Program
{
void tĩnh Main(string[] args)
{
string clusterURL = "https://.azurehdinsight.net";
string hadoopUsername= "";
string hadoopUserPassword = "";

// Create a new instance of an HBase client.
ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword);
HBaseClient hbaseClient = new HBaseClient(creds);

// Retrieve the cluster version
var version = hbaseClient.GetVersion();
Console.WriteLine("The HBase cluster version is " + version);
}
}
}

我只是不明白这到底有何不同。

能给点建议吗?

Cảm ơn bạn rất nhiều.

1 Câu trả lời

从今天开始,您需要在后台线程上运行调用。我遇到了同样的问题。我的通话被整合到一个函数中。我在后台线程上运行该函数,一切正常。

        // POST: api/Vizzini
[ResponseType(typeof(string))]
public async Task GetResponse(string tweet)
{
string s = await Task.Run(() =>
{
return ResponseEngine.GetBestResponse(tweet);
});
return Ok(s);
}

关于c# - .NET HBase REST API 客户端库 - 从 MVC5 Controller 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30971186/

27 4 0
可可西里
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com