hadoop机架是什么_什么是机架?

hadoop机架是什么

There’s a lot of talk about Rack, but unless you’re a framework author yourself, you rarely see it. So what is Rack And why, as an application developer, should you care about it

关于Rack的讨论很多,但是除非您自己是框架作者,否则很少会看到它。 那么机架是什么? 作为应用程序开发人员,为什么要关心它呢?

机架基础 ( Rack Basics )

Rack is a kind of middleware. It sits between your web application and the web server. It handles all of the server-specific API calls, passes on the HTTP request and all the environment parameters in a hash, and gives your application’s response back to the server. In other words, your application doesn’t need to know how to talk to an HTTP server, it needs to know how to talk to Rack.

机架是一种中间件。 它位于您的Web应用程序和Web服务器之间。 它处理所有服务器特定的API调用,将HTTP请求和所有环境参数传递给哈希,然后将应用程序的响应返回给服务器。 换句话说,您的应用程序不需要知道如何与HTTP服务器通信,而是需要知道如何与Rack通信。

机架的优点 ( Advantages of Rack )

This has a number of advantages. First, talking to Rack is easy (as you’ll see below). Second, since you only need to know how to talk to Rack, and Rack knows how to talk to many different HTTP servers, your application will run on any of these HTTP servers. Rack is like a universal adapter for web applications.

这具有许多优点。 首先,与Rack交谈很容易(如下所示)。 其次,由于您只需要知道如何与Rack对话,而Rack知道如何与许多不同的HTTP服务器对话,因此您的应用程序可以在这些HTTP服务器中的任何一个上运行。 机架就像Web应用程序的通用适配器。

The Rack applications themselves are nothing special. In fact, the Rack API is so dead simple, it can be described in a single sentence:

Rack应用程序本身没有什么特别的。 实际上,Rack API非常简单,可以用一句话来描述:

call method, takes a single hash parameter and returns an array containing the response status code, HTTP response headers and the response body as an array of strings. _call_方法作出响应的Ruby对象,它采用单个哈希参数并返回一个包含响应状态代码,HTTP响应标头和响应主体的字符串数组。

That’s pretty much it. It sounds too simple to be true, or at least too simple to be useful, but when it really comes down to it, that’s all you’re really doing when you’re talking to HTTP servers.

就是这样。 这听起来太简单,难以置信,或者至少太简单,没有用,但是真正归根结底,这就是您在与HTTP服务器通信时真正要做的事情。

为什么机架很重要? ( Why Is Rack Important )

But on to the real question: Why, as an application programmer, should you care about Rack Well first, there’s always enlightenment in understanding how your framework works. But more importantly, there are useful things you can do with Rack. Most importantly: middleware.

但是,真正的问题是:为什么作为应用程序程序员,您应该关心Rack? 首先,了解框架的工作原理总是有启发性的。 但更重要的是,您可以使用Rack做一些有用的事情。 最重要的是:中间件。

Now, this sounds a bit odd. But an extra layer between your application and Rack can be a good thing, and implement features that would only clutter your application. What this middleware does is simply take the request from Rack, pass it on to your application, get its response, add something to it or filter it or something along these lines and then pass the response back to Rack. This can be used to implement very interesting little features like a server-agnostic logger, or a request sanity checker, or a little middleware that emails an admin every time your application comes back with a 404. None of these features need to clutter up your application, they can be implemented as middleware with Rack.

现在,这听起来有些奇怪。 但是,您的应用程序和Rack之间的额外层可能是一件好事,并且实现只会使您的应用程序混乱的功能。 该中间件所做的只是简单地从Rack接收请求,将其传递到您的应用程序,获取其响应,向其添加内容或对其进行过滤,或者将这些内容过滤,然后将响应传递回Rack。 这可以用来实现非常有趣的小功能,例如与服务器无关的记录器,请求完整性检查程序,或者是每次应用程序返回404时都会向管理员发送电子邮件的小中间件。这些功能都不需要使您的代码杂乱无章应用程序,它们可以与Rack一起实现为中间件。

翻译自: https://www.thoughtco.com/what-is-rack-2908122

hadoop机架是什么

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值