// @Bean(value = SIGNALING_ASYNC_TASK_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService signalingExecutor(PrometheusMeterRegistry registry,
// SignalingExecutorProperty signalingExecutorProperty) {
// return buildExecutor(SIGNALING_ASYNC_TASK_EXECUTOR, registry, signalingExecutorProperty);
// }
//
// @Bean(value = PASSTHROUGH_ASYNC_TASK_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService passthroughExecutor(PrometheusMeterRegistry registry,
// PassthroughExecutorProperty passthroughExecutorProperty) {
// return buildExecutor(PASSTHROUGH_ASYNC_TASK_EXECUTOR, registry, passthroughExecutorProperty);
// }
//
// @Bean(value = PRECONNECTION_REQUEST_RELAY_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService preConnRequestRelayExecutor(PrometheusMeterRegistry registry,
// PreConnectionExecutorProperty preConnectionExecutorProperty) {
// return buildExecutor(PRECONNECTION_REQUEST_RELAY_EXECUTOR, registry, preConnectionExecutorProperty);
// }
//
// @Bean(value = PRECONNECTION_PASSTHROUGH_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService preConnPassthroughExecutor(PrometheusMeterRegistry registry,
// PreConnectionPassthroughExecutorProperty executorProperty) {
// return buildExecutor(PRECONNECTION_PASSTHROUGH_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = STREAM_MANAGE_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService streamManageExecutor(PrometheusMeterRegistry registry,
// StreamManageExecutorProperty executorProperty) {
// return buildExecutor(STREAM_MANAGE_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = USER_AND_DEVICE_INFO_REQUEST_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService userAndDeviceInfoRequestExecutor(PrometheusMeterRegistry registry,
// UserAndDeviceInfoRequestExecutorProperty executorProperty) {
// return buildExecutor(USER_AND_DEVICE_INFO_REQUEST_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = PROLONG_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService prolongExecutor(PrometheusMeterRegistry registry,
// ProlongExecutorProperty executorProperty) {
// return buildExecutor(PROLONG_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = PLAYER_NUM_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService playerNumExecutor(PrometheusMeterRegistry registry,
// PlayerNumExecutorProperty executorProperty) {
// return buildExecutor(PLAYER_NUM_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = SESSION_EXECUTOR, destroyMethod = "shutdown")
// public ScheduledExecutorService sessionScheduledExecutorService(PrometheusMeterRegistry registry,
// SessionExecutorProperty sessionExecutorProperty) {
// RejectedExecutionHandler handler = new MetricRejectedExecutionHandler(registry, SESSION_EXECUTOR);
//
// ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
// sessionExecutorProperty.getCorePoolSize(),
// new ThreadFactoryBuilder().setNameFormat(SESSION_EXECUTOR + "-pool-%d").build(), handler);
// return ExecutorServiceMetrics.monitor(registry, scheduledThreadPoolExecutor, SESSION_EXECUTOR);
// }
// @Bean(value = GRPC_SERVER_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService grpcServerExecutorService(PrometheusMeterRegistry registry,
// GrpcServerExecutorProperty executorProperty) {
// return buildExecutor(GRPC_SERVER_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = TRACK_SESSION_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService trackSessionExecutorService(PrometheusMeterRegistry registry,
// TrackSessionExecutorProperty executorProperty) {
// return buildExecutor(TRACK_SESSION_EXECUTOR, registry, executorProperty);
// }
//
// @Bean(value = RELAY_CLIENT_EXECUTOR, destroyMethod = "shutdown")
// public ExecutorService relayClientExecutorService(PrometheusMeterRegistry registry,
// RelayClientExecutorProperty executorProperty) {
// return buildExecutor(RELAY_CLIENT_EXECUTOR, registry, executorProperty);
// }
//
// private ExecutorService buildExecutor(String executorName, PrometheusMeterRegistry registry,
// ExecutorProperty executorProperty) {
// RejectedExecutionHandler handler = new MetricRejectedExecutionHandler(registry, executorName);
//
// ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
// threadPoolTaskExecutor.setCorePoolSize(executorProperty.getCorePoolSize());
// threadPoolTaskExecutor.setMaxPoolSize(executorProperty.getMaxPoolSize());
// threadPoolTaskExecutor.setKeepAliveSeconds(executorProperty.getKeepAliveSeconds());
// threadPoolTaskExecutor.setQueueCapacity(executorProperty.getQueueSize());
// threadPoolTaskExecutor.setThreadFactory(
// new ThreadFactoryBuilder().setNameFormat(executorName + "-pool-%d").build());
// threadPoolTaskExecutor.setRejectedExecutionHandler(handler);
// threadPoolTaskExecutor.setTaskDecorator(new ContextTaskDecorator());
// threadPoolTaskExecutor.initialize();
//
// return ExecutorServiceMetrics.monitor(registry, threadPoolTaskExecutor.getThreadPoolExecutor(), executorName);
// }
//
// @AllArgsConstructor
// public static class MetricRejectedExecutionHandler implements RejectedExecutionHandler {
//
// private PrometheusMeterRegistry registry;
// private String executorName;
//
// @Override
// public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
// registry.counter("executor.rejected.tasks.total", "name", executorName).increment();
// throw new RejectedExecutionException("Task " + r.toString() + " rejected from " + executor.toString());
// }
// }如上是旧的线程池初始化实现,有新的实现是通过配置文件由spring直接初始化,如何加一个开关在两者之间切换
最新发布