Search in sources :

Example 1 with DtpExecutor

use of com.dtp.core.thread.DtpExecutor in project dynamic-tp by lyh200.

the class DtpPostProcessor method postProcessAfterInitialization.

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof DtpExecutor) {
        DtpExecutor dtpExecutor = (DtpExecutor) bean;
        register(dtpExecutor);
        return dtpExecutor;
    }
    return bean;
}
Also used : DtpExecutor(com.dtp.core.thread.DtpExecutor)

Example 2 with DtpExecutor

use of com.dtp.core.thread.DtpExecutor in project dynamic-tp by lyh200.

the class AbstractNotifier method buildAlarmContent.

public String buildAlarmContent(NotifyPlatform platform, NotifyTypeEnum typeEnum, String template) {
    DtpContext contextWrapper = DtpContextHolder.get();
    String dtpName = contextWrapper.getDtpExecutor().getThreadPoolName();
    DtpExecutor executor = DtpRegistry.getExecutor(dtpName);
    List<String> receivers = StrUtil.split(platform.getReceivers(), ',');
    String receivesStr = Joiner.on(", @").join(receivers);
    NotifyItem notifyItem = contextWrapper.getNotifyItem();
    String content = String.format(template, getInstance().getServiceName(), getInstance().getIp() + ":" + getInstance().getPort(), getInstance().getEnv(), executor.getThreadPoolName(), typeEnum.getValue(), notifyItem.getThreshold(), executor.getCorePoolSize(), executor.getMaximumPoolSize(), executor.getPoolSize(), executor.getActiveCount(), executor.getLargestPoolSize(), executor.getTaskCount(), executor.getCompletedTaskCount(), executor.getQueue().size(), executor.getQueueName(), executor.getQueueCapacity(), executor.getQueue().size(), executor.getQueue().remainingCapacity(), executor.getRejectHandlerName(), executor.getRejectCount(), receivesStr, DateUtil.now(), notifyItem.getInterval());
    return highlightAlarmContent(content, typeEnum);
}
Also used : NotifyItem(com.dtp.common.dto.NotifyItem) DtpExecutor(com.dtp.core.thread.DtpExecutor) DtpContext(com.dtp.core.context.DtpContext)

Example 3 with DtpExecutor

use of com.dtp.core.thread.DtpExecutor in project dynamic-tp by lyh200.

the class AbstractNotifier method buildNoticeContent.

public String buildNoticeContent(NotifyPlatform platform, String template, DtpMainProp oldProp, List<String> diffs) {
    String threadPoolName = oldProp.getDtpName();
    DtpExecutor dtpExecutor = DtpRegistry.getExecutor(threadPoolName);
    List<String> receivers = StrUtil.split(platform.getReceivers(), ',');
    String receivesStr = Joiner.on(", @").join(receivers);
    String content = String.format(template, getInstance().getServiceName(), getInstance().getIp() + ":" + getInstance().getPort(), getInstance().getEnv(), threadPoolName, oldProp.getCorePoolSize(), dtpExecutor.getCorePoolSize(), oldProp.getMaxPoolSize(), dtpExecutor.getMaximumPoolSize(), oldProp.isAllowCoreThreadTimeOut(), dtpExecutor.allowsCoreThreadTimeOut(), oldProp.getKeepAliveTime(), dtpExecutor.getKeepAliveTime(TimeUnit.SECONDS), dtpExecutor.getQueueName(), oldProp.getQueueCapacity(), dtpExecutor.getQueueCapacity(), oldProp.getRejectType(), dtpExecutor.getRejectHandlerName(), receivesStr, DateTime.now());
    return highlightNotifyContent(content, diffs);
}
Also used : DtpExecutor(com.dtp.core.thread.DtpExecutor)

Example 4 with DtpExecutor

use of com.dtp.core.thread.DtpExecutor in project dynamic-tp by lyh200.

the class DtpMonitor method run.

private void run() {
    List<String> names = DtpRegistry.listAllDtpNames();
    if (CollUtil.isEmpty(names)) {
        return;
    }
    names.forEach(x -> {
        DtpExecutor executor = DtpRegistry.getExecutor(x);
        AlarmManager.triggerAlarm(() -> doAlarm(executor, ALARM_TYPES));
        ThreadPoolStats poolStats = MetricsConverter.convert(executor);
        doCollect(poolStats);
    });
    publishEvent();
}
Also used : ThreadPoolStats(com.dtp.common.dto.ThreadPoolStats) DtpExecutor(com.dtp.core.thread.DtpExecutor)

Example 5 with DtpExecutor

use of com.dtp.core.thread.DtpExecutor in project austin by ZhongFuCheng3y.

the class TaskPendingHolder method init.

/**
 * 给每个渠道,每种消息类型初始化一个线程池
 */
@PostConstruct
public void init() {
    /**
     * example ThreadPoolName:austin.im.notice
     *
     * 可以通过apollo配置:dynamic-tp-apollo-dtp.yml  动态修改线程池的信息
     */
    for (String groupId : groupIds) {
        DtpExecutor executor = HandlerThreadPoolConfig.getExecutor(groupId);
        threadPoolUtils.register(executor);
        taskPendingHolder.put(groupId, executor);
    }
}
Also used : DtpExecutor(com.dtp.core.thread.DtpExecutor) PostConstruct(javax.annotation.PostConstruct)

Aggregations

DtpExecutor (com.dtp.core.thread.DtpExecutor)19 EagerDtpExecutor (com.dtp.core.thread.EagerDtpExecutor)3 RuntimeInfo (cn.hutool.system.RuntimeInfo)2 JvmStats (com.dtp.common.dto.JvmStats)2 Metrics (com.dtp.common.dto.Metrics)2 NotifyItem (com.dtp.common.dto.NotifyItem)2 ThreadPoolStats (com.dtp.common.dto.ThreadPoolStats)2 DtpContext (com.dtp.core.context.DtpContext)2 ExecutorWrapper (com.dtp.core.support.ExecutorWrapper)2 lombok.val (lombok.val)2 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)2 CollUtil (cn.hutool.core.collection.CollUtil)1 DtpProperties (com.dtp.common.config.DtpProperties)1 ThreadPoolProperties (com.dtp.common.config.ThreadPoolProperties)1 NotifyPlatform (com.dtp.common.dto.NotifyPlatform)1 NotifyTypeEnum (com.dtp.common.em.NotifyTypeEnum)1 StreamUtil (com.dtp.common.util.StreamUtil)1 DynamicTp (com.dtp.core.support.DynamicTp)1 TaskQueue (com.dtp.core.support.TaskQueue)1 Lists (com.google.common.collect.Lists)1