Java Thread Stuck Wildfly 10.1消耗100%CPU(10核心)

时间:2017-07-04 08:31:46

标签: java jboss wildfly servlet-filters wildfly-10

我们最近从Jboss 4迁移到Wildfly 10.1和Java 1.6到1.8。 我们面临着许多关于CPU利用率的问题,例如,线程在过去16小时内运行并且没有结束。有这样的两个线程,两个都消耗16%的CPU和增加。

我们在此过滤器上的每个请求都有Web应用程序,因为此CPU利用率增加到100%。

在我们的项目中,我们正在使用 java.nio.channels 但是在野生动物群上运行它正在服用 的 org.xnio.channels.Channels

在jboss 4上,一切正常,CPU利用率不超过200%。

"default task-39" #252 prio=5 os_prio=0 tid=0x00007f7d8803f800 nid=0x4c8f runnable [0x00007f7e072f2000]
java.lang.Thread.State: RUNNABLE
at org.xnio.channels.Channels.writeBlocking(Channels.java:158)
at io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:283)
at io.undertow.io.BlockingSenderImpl.writeBuffer(BlockingSenderImpl.java:190)
at io.undertow.io.BlockingSenderImpl.send(BlockingSenderImpl.java:71)
at io.undertow.server.handlers.resource.CachedResource.serve(CachedResource.java:187)
at io.undertow.servlet.handlers.DefaultServlet.serveFileBlocking(DefaultServlet.java:332)
at io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at com.eko.framework.MifosNGFilter.doNormal(MifosNGFilter.java:283)
at com.eko.framework.MifosNGFilter.doFilter(MifosNGFilter.java:121)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at com.eko.framework.CrossScriptingFilter.doFilter(CrossScriptingFilter.java:48)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at com.eko.framework.URLSessionFilter.doFilter(URLSessionFilter.java:38)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.mifos.framework.security.util.FileNameFilter.doFilter(FileNameFilter.java:59)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我们只是执行基本的过滤器和线程没有结束。 以下是java代码:

public void doFilter(ServletRequest req, ServletResponse res,
        FilterChain chain) throws IOException, ServletException {


    String reqUri = ((HttpServletRequest) req).getRequestURI();
    String reqMethod = ((HttpServletRequest) req).getParameter("method");
    String requestText = ((HttpServletRequest) req).getParameter("requestText");
    String originatioAddress = ((HttpServletRequest) req).getParameter("originationAddress");

    Date requestTime = new Date();
    HttpSession httpSession = ((HttpServletRequest) req).getSession(false);
    UserContext userContext = null;
    if (httpSession != null) {
        userContext = (UserContext) httpSession
                .getAttribute(Constants.USERCONTEXT);
    }

    try {

        HttpServletResponse resp = (HttpServletResponse) res;

        resp.setHeader("Cache-Control","no-store"); 
        resp.setHeader("Pragma","no-cache"); 
        resp.setDateHeader ("Expires", -1);
        resp.setHeader("X-Powered-By", null);
        resp.setHeader("SET-COOKIE", "JSESSIONID=" + ((HttpServletRequest) req).getSession().getId() 
                 +
                 "; _ga=" + 
                ((HttpServletRequest) req).getSession().getAttribute("_ga")
                + "; Path=" + 
        ((HttpServletRequest) req).getContextPath()      
                +
                 "; httpOnly; secure;" );

        doNormal(chain, req, res);

    }
    catch (Throwable t) {
        logger.warn(t, t);
    }
}

private void doNormal(FilterChain chain, ServletRequest req,
        ServletResponse res) throws ServletException {
    try {
        chain.doFilter(req, res);
    }
    catch (Throwable t) {
        logger.error(t, t);
        throw new ServletException(t);
    }
}

0 个答案:

没有答案