Skip to content

Commit

Permalink
[#noissue] Refactor Executor Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Oct 5, 2023
1 parent f39def5 commit 36e4658
Show file tree
Hide file tree
Showing 73 changed files with 1,431 additions and 1,354 deletions.
5 changes: 4 additions & 1 deletion batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@


import com.navercorp.pinpoint.collector.config.ClusterModule;
import com.navercorp.pinpoint.collector.config.CollectorConfiguration;
import com.navercorp.pinpoint.collector.config.CollectorProperties;
import com.navercorp.pinpoint.collector.config.FlinkContextModule;
import com.navercorp.pinpoint.collector.config.MetricConfiguration;
import com.navercorp.pinpoint.collector.event.config.CollectorEventConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.CollectorGrpcConfiguration;
import com.navercorp.pinpoint.collector.grpc.ssl.GrpcSslModule;
import com.navercorp.pinpoint.common.server.CommonsServerConfiguration;
import com.navercorp.pinpoint.common.server.config.TypeLoaderConfiguration;
Expand All @@ -21,16 +23,19 @@
"classpath:applicationContext-collector.xml",
"classpath:servlet-context-collector.xml",

"classpath:applicationContext-collector-grpc.xml",

})
@Import({
CollectorAppPropertySources.class,
CommonsServerConfiguration.class,
TypeLoaderConfiguration.class,

FlinkContextModule.class,
CollectorConfiguration.class,
CollectorHbaseModule.class,

CollectorGrpcConfiguration.class,

CollectorEventConfiguration.class,

ClusterModule.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public FactoryBean<Connection> batchConnectionFactory(Configuration configuratio
}

@Bean
public FactoryBean<ExecutorService> batchHbaseThreadPool(ExecutorCustomizer<ThreadPoolExecutorFactoryBean> executorCustomizer,
public FactoryBean<ExecutorService> batchHbaseThreadPool(@Qualifier("hbaseExecutorCustomizer") ExecutorCustomizer<ThreadPoolExecutorFactoryBean> executorCustomizer,
@Qualifier("hbaseClientExecutorProperties")
com.navercorp.pinpoint.common.config.executor.ExecutorProperties properties) {
ThreadPoolExecutorFactoryBean factory = new ThreadPoolExecutorFactoryBean();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2023 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.navercorp.pinpoint.collector.config;

import com.navercorp.pinpoint.common.config.executor.ExecutorCustomizer;
import com.navercorp.pinpoint.common.config.executor.ExecutorProperties;
import com.navercorp.pinpoint.common.config.executor.ThreadPoolExecutorCustomizer;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean;
import org.springframework.validation.annotation.Validated;

import java.util.concurrent.ExecutorService;

@Configuration
public class CollectorConfiguration {

@Bean
public ExecutorCustomizer<ThreadPoolExecutorFactoryBean> collectorExecutorCustomizer() {
return new ThreadPoolExecutorCustomizer();
}

@Bean
@Validated
@ConfigurationProperties(prefix="collector.agent-event-worker")
public ExecutorProperties agentEventWorkerExecutorProperties() {
return new ExecutorProperties();
}

@Bean
public FactoryBean<ExecutorService> agentEventWorker(@Qualifier("collectorExecutorCustomizer") ExecutorCustomizer<ThreadPoolExecutorFactoryBean> executorCustomizer,
@Qualifier("agentEventWorkerExecutorProperties") ExecutorProperties properties) {

ThreadPoolExecutorFactoryBean factory = new ThreadPoolExecutorFactoryBean();
executorCustomizer.customize(factory, properties);

String beanName = CallerUtils.getCallerMethodName();
factory.setThreadNamePrefix(beanName);
return factory;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
public class CollectorProperties {
private final Logger logger = LogManager.getLogger(getClass());

@Value("${collector.agentEventWorker.threadSize:32}")
private int agentEventWorkerThreadSize;
@Value("${collector.agentEventWorker.queueSize:5120}")
private int agentEventWorkerQueueSize;
@Value("${collector.l4.ip:}")
private String[] l4IpList = new String[0];
@Value("${collector.metric.jmx:false}")
Expand All @@ -50,21 +46,6 @@ public class CollectorProperties {
@Value("${collector.statistics.agent-state.enable:false}")
private boolean statisticsAgentStateEnable;

public int getAgentEventWorkerThreadSize() {
return this.agentEventWorkerThreadSize;
}

public void setAgentEventWorkerThreadSize(int agentEventWorkerThreadSize) {
this.agentEventWorkerThreadSize = agentEventWorkerThreadSize;
}

public int getAgentEventWorkerQueueSize() {
return agentEventWorkerQueueSize;
}

public void setAgentEventWorkerQueueSize(int agentEventWorkerQueueSize) {
this.agentEventWorkerQueueSize = agentEventWorkerQueueSize;
}

public List<String> getL4IpList() {
return List.of(l4IpList);
Expand Down Expand Up @@ -117,8 +98,6 @@ public void log() {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CollectorConfiguration{");
sb.append("agentEventWorkerThreadSize=").append(agentEventWorkerThreadSize);
sb.append(", agentEventWorkerQueueSize=").append(agentEventWorkerQueueSize);
sb.append(", l4IpList=").append(Arrays.toString(l4IpList));
sb.append(", metricJmxEnable=").append(metricJmxEnable);
sb.append(", metricJmxDomainName='").append(metricJmxDomainName).append('\'');
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.navercorp.pinpoint.collector.grpc.config;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.common.config.executor.ExecutorCustomizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean;

@Configuration
@ImportResource({
"classpath:applicationContext-collector-grpc.xml"
})
public class CollectorGrpcConfiguration {

@Bean
public MonitoringExecutors monitoringExecutors(
@Qualifier("collectorExecutorCustomizer") ExecutorCustomizer<ThreadPoolExecutorFactoryBean> customizer,
@Autowired(required = false) MetricRegistry metricRegistry) {
return new MonitoringExecutors(customizer, metricRegistry);
}

}
Loading

0 comments on commit 36e4658

Please sign in to comment.