Jboss AS7,APR本机连接器和sendfile [英] Jboss AS7, APR native connectors and sendfile

查看:90
本文介绍了Jboss AS7,APR本机连接器和sendfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已着手实现对类似于torquebox(www.torquebox.org)上的mod_xsendfile的功能的支持. Torquebox基本上是在JBoss AS 7之上的一堆代码,这使我的工作等同于使sendfile在JBoss AS 7上工作.

I've set out on an endeavour to implement support for a feature similar to mod_xsendfile on torquebox (www.torquebox.org). Torquebox is basically a bunch of code on top of JBoss AS 7, which makes my effort kinda equivalent to making sendfile work on JBoss AS 7.

这里的主要问题可能是我对JBoss感到困惑,但是在浪费了太多时间来耗尽我所有的Google搜索资源之后,我不得不相信那里确实有人真正知道这件事是如何工作的.在AS 7中.

The main problem here is probably my confusion over JBoss, but after wasting way too many hours exhausting all my googling resources, I have to beleive that there's someone out there who actually know how this thing works in AS 7.

据我了解,JBoss通过使用JBoss Web本机连接器(http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-10)支持sendfile,即APR http连接器.

As I understand this, sendfile is supported in JBoss by using the JBoss Web native connectors (http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-10), namely the APR http connector.

在花费了数小时未能在AS 7上安装它们后,这似乎对其他人来说是一种魅力(https://community.jboss.org/message/614790),重复我的本地JBoss目录告诉我,这些本机连接器似乎与AS 7捆绑在一起.对于我来说,所需的dll被放置在

After spending hours failing to install these on AS 7, which seems works like a charm for others (https://community.jboss.org/message/614790), grep'ing my local JBoss dir tells me, that these native connectors are appearently bundled with AS 7. In my case, the dll needed is placed in

%JBOSS_HOME%\ modules \ org \ jboss \ as \ web \ main \ lib \ win-x86_64

%JBOSS_HOME%\modules\org\jboss\as\web\main\lib\win-x86_64

如此史诗般的失败,试图安装已经存在的东西. 检查我的standalone.xml配置文件还显示此本地连接器正在使用

So epic fail, trying to install something that's already there. Inspecting my standalone.xml configuration file also reveal this native connector is being used

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <virtual-server name="default-host" enable-welcome-root="false">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>

将所有日志记录级别切换为调试并检查日志会显示日志消息

Switching all logging levels to debug and inspecting the log shows the log message

standalone/log/server.log.2012-02-10:324:23:12:17,964 INFO [org.apache.coyote.http11.Http11AprProtocol](MSC服务线程1-5)在以下位置启动Coyote HTTP/1.1 http-127.0.0.1-127.0.0.1-8080

standalone/log/server.log.2012-02-10:324:23:12:17,964 INFO [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-5) Starting Coyote HTTP/1.1 on http-127.0.0.1-127.0.0.1-8080

其中Http11AprProtocol指示使用了APR http连接器.但是,网络上的许多帖子都提到以下行也应显示:

Where Http11AprProtocol indicates that the APR http connector is used. However, many posts on the web mention that the following line should also be shown:

org.apache.catalina.core.AprLifecycleListener初始化信息:APR功能:IPv6 [true],sendfile [true],接受过滤器[false],随机[true].

org.apache.catalina.core.AprLifecycleListener init INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

无论日志记录级别如何,ApLifecycleListener行都不会显示.

No matter the logging level, the AprLifecycleListener line never shows.

当我查看此内容时,似乎正在使用APR http连接器.

When I review this, is seems that the APR http connector is now in use.

根据文档,我可以使以下servlet正常工作

According to the docs, I can get the following servlet to work

public class Sendfile extends HttpServlet {
    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
        if(Boolean.TRUE == request.getAttribute("org.apache.tomcat.sendfile.support")){
            // Send all the files!!
        }
        else{
            throw new ServletException("BOOM!");
        }
    }
}

但是没有. org.apache.tomcat.sendfile.support属性为null,如果尝试尝试设置用于发送文件的http标头(忽略support属性)并设置其余必需的sendfile属性,我的浏览器会认为它正在接收文件,但没有数据传输...并且连接保持挂起状态.

But no. The org.apache.tomcat.sendfile.support attribute is null and if try attempt to set http headers for sending a file (ignoring the support attribute) and set the rest of the required sendfile attributes, my browser thinks that it's receiving a file, but no data is transferred... and the connection is left hanging.

总结这个问题,似乎正在使用必需的APR本机连接器,默认情况下应启用sendfile,但是服务器不知道Im打算做什么.

To conclude the question, it seems the required APR native connector is in use, sendfile should be enabled by default, but the server has no clue what Im trying to make it do.

如何进行?

推荐答案

我也迷失了数小时,试图了解它的工作原理.你做得对.只是错过了将Web系统设置为native=true:

I was also lost hours trying to learn how it works. You did everything right. Just missed putting the Web System as native=true:

<subsystem xmlns="urn:jboss:domain:web:1.1" 
         default-virtual-server="default-host" native="true">

启动它:

11:00:26,018 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) Loaded: apr-1
11:00:26,039 DEBUG [org.jboss.modules] (ServerService Thread Pool -- 58) Module org.jboss.xb:main defined by local module loader @d8d9850 (roots: /home/mmagnani/Development/jboss-eap/jboss-eap-6.0/modules)
11:00:26,070 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) Loaded: z
11:00:26,071 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) Loaded: crypto
11:00:26,072 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) Loaded: ssl
11:00:26,079 DEBUG [org.jboss.as.ejb3] (ServerService Thread Pool -- 36) Adding EJB @Asynchronous support
11:00:26,082 DEBUG [org.jboss.as.ejb3] (ServerService Thread Pool -- 36) Configuring timers
11:00:26,092 DEBUG [org.jboss.as.ejb3] (ServerService Thread Pool -- 36) Adding EJB IIOP support
11:00:26,101 FINE  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-6) Starting server HornetQServerImpl::
11:00:26,120 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) Loaded: tcnative-1
11:00:26,141 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) Loaded Apache Tomcat Native library 1.1.23.
11:00:26,141 DEBUG [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-3) APR capabilities: IPv6 [true], sendfile [true], random [true].

祝你好运:)

这篇关于Jboss AS7,APR本机连接器和sendfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆