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;
}
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);
}
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);
}
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();
}
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);
}
}
Aggregations