Search in sources :

Example 1 with WebServerTpHandler

use of com.dtp.adapter.web.handler.WebServerTpHandler in project dynamic-tp by lyh200.

the class DtpWebRefreshListener method onApplicationEvent.

@Override
public void onApplicationEvent(RefreshEvent event) {
    ApplicationContext applicationContext = ApplicationContextHolder.getInstance();
    if (!(applicationContext instanceof WebServerApplicationContext)) {
        return;
    }
    try {
        WebServerTpHandler webServerTpHandler = ApplicationContextHolder.getBean(WebServerTpHandler.class);
        webServerTpHandler.updateWebServerTp(event.getDtpProperties());
    } catch (Exception e) {
        log.error("DynamicTp refresh, update web server thread pool failed.", e);
    }
}
Also used : WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) WebServerTpHandler(com.dtp.adapter.web.handler.WebServerTpHandler)

Example 2 with WebServerTpHandler

use of com.dtp.adapter.web.handler.WebServerTpHandler in project dynamic-tp by lyh200.

the class DtpWebCollectListener method onApplicationEvent.

@Override
public void onApplicationEvent(CollectEvent event) {
    DtpProperties dtpProperties = event.getDtpProperties();
    if (!dtpProperties.isEnabledCollect()) {
        return;
    }
    try {
        WebServerTpHandler webServerTpHandler = ApplicationContextHolder.getBean(WebServerTpHandler.class);
        ThreadPoolStats poolStats = webServerTpHandler.getPoolStats();
        if (poolStats == null) {
            return;
        }
        CollectorHandler.getInstance().collect(poolStats, dtpProperties.getCollectorType());
    } catch (Exception e) {
        log.error("DynamicTp monitor, collect web server thread pool metrics failed.", e);
    }
}
Also used : ThreadPoolStats(com.dtp.common.dto.ThreadPoolStats) DtpProperties(com.dtp.common.config.DtpProperties) WebServerTpHandler(com.dtp.adapter.web.handler.WebServerTpHandler)

Aggregations

WebServerTpHandler (com.dtp.adapter.web.handler.WebServerTpHandler)2 DtpProperties (com.dtp.common.config.DtpProperties)1 ThreadPoolStats (com.dtp.common.dto.ThreadPoolStats)1 WebServerApplicationContext (org.springframework.boot.web.context.WebServerApplicationContext)1 ApplicationContext (org.springframework.context.ApplicationContext)1