Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#noissue] Cleanup GrpcConfiguration #11243

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
package com.navercorp.pinpoint.collector.grpc;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.grpc.config.GrpcAgentDataReceiverConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcAgentConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcAgentReceiverConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcComponentConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcKeepAliveScheduler;
import com.navercorp.pinpoint.collector.grpc.config.GrpcSpanConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcSpanReceiverConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcStatConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcStatReceiverConfiguration;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.common.server.executor.ExecutorCustomizer;
Expand All @@ -36,8 +39,14 @@
@Configuration
@Import({
GrpcComponentConfiguration.class,
GrpcAgentDataReceiverConfiguration.class,

GrpcAgentReceiverConfiguration.class,
GrpcAgentConfiguration.class,

GrpcSpanConfiguration.class,
GrpcSpanReceiverConfiguration.class,

GrpcStatConfiguration.class,
GrpcStatReceiverConfiguration.class,

GrpcKeepAliveScheduler.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import com.navercorp.pinpoint.collector.handler.RequestResponseHandler;
import com.navercorp.pinpoint.collector.handler.SimpleAndRequestResponseHandler;
import com.navercorp.pinpoint.collector.manage.HandlerManager;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.receiver.AgentDispatchHandler;
import com.navercorp.pinpoint.collector.receiver.AgentLifeCycleChangeEventHandler;
import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.collector.receiver.DispatchHandler;
import com.navercorp.pinpoint.collector.receiver.DispatchHandlerFactoryBean;
import com.navercorp.pinpoint.collector.receiver.grpc.GrpcReceiver;
Expand All @@ -38,11 +36,8 @@
import com.navercorp.pinpoint.collector.service.AgentInfoService;
import com.navercorp.pinpoint.collector.service.async.AgentEventAsyncTaskService;
import com.navercorp.pinpoint.collector.service.async.AgentLifeCycleAsyncTaskService;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import com.navercorp.pinpoint.common.server.util.AcceptedTimeService;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import com.navercorp.pinpoint.common.server.util.IgnoreAddressFilter;
import com.navercorp.pinpoint.grpc.server.ServerOption;
import com.navercorp.pinpoint.grpc.server.lifecycle.DefaultPingEventHandler;
import com.navercorp.pinpoint.grpc.server.lifecycle.DefaultPingSessionRegistry;
import com.navercorp.pinpoint.grpc.server.lifecycle.PingEventHandler;
Expand All @@ -56,96 +51,22 @@
import org.apache.logging.log4j.Logger;
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.core.env.Environment;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.validation.annotation.Validated;

import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;

/**
* @author emeroad
*/
@Configuration
public class GrpcAgentDataReceiverConfiguration {
public class GrpcAgentConfiguration {

private static final Logger logger = LogManager.getLogger(GrpcAgentDataReceiverConfiguration.class);
private static final Logger logger = LogManager.getLogger(GrpcAgentConfiguration.class);

Check warning on line 67 in collector/src/main/java/com/navercorp/pinpoint/collector/grpc/config/GrpcAgentConfiguration.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/grpc/config/GrpcAgentConfiguration.java#L67

Added line #L67 was not covered by tests

public GrpcAgentDataReceiverConfiguration() {
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.bindaddress")
public BindAddress.Builder grpcAgentBindAddressBuilder() {
BindAddress.Builder builder = BindAddress.newBuilder();
builder.setPort(9991);
return builder;
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.server.executor")
public MonitoringExecutorProperties grpcAgentServerExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.server-call.executor")
public MonitoringExecutorProperties grpcAgentServerCallExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.worker.executor")
public MonitoringExecutorProperties grpcAgentWorkerExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@ConfigurationProperties("collector.receiver.grpc.agent")
public GrpcPropertiesServerOptionBuilder grpcAgentServerOption() {
// Server option
return new GrpcPropertiesServerOptionBuilder();
}

@Bean
public GrpcReceiverProperties grpcAgentReceiverProperties(Environment environment) {
boolean enable = environment.getProperty("collector.receiver.grpc.agent.enable", boolean.class, false);

ServerOption serverOption = grpcAgentServerOption().build();
BindAddress bindAddress = grpcAgentBindAddressBuilder().build();

return new GrpcReceiverProperties(enable, bindAddress, serverOption);
}

@Bean
public FactoryBean<ExecutorService> grpcAgentWorkerExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcAgentWorkerExecutorProperties();
return executors.newExecutorFactoryBean(properties, beanName);
}


@Bean
public FactoryBean<ExecutorService> grpcAgentServerExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcAgentServerExecutorProperties();
return executors.newExecutorFactoryBean(properties, beanName);
}

@Bean
public FactoryBean<ExecutorService> grpcAgentServerCallExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcAgentServerCallExecutorProperties();
properties.setLogRate(1);
return executors.newExecutorFactoryBean(properties, beanName);
public GrpcAgentConfiguration() {

Check warning on line 69 in collector/src/main/java/com/navercorp/pinpoint/collector/grpc/config/GrpcAgentConfiguration.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/grpc/config/GrpcAgentConfiguration.java#L69

Added line #L69 was not covered by tests
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright 2021 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.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import com.navercorp.pinpoint.grpc.server.ServerOption;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.validation.annotation.Validated;

import java.util.concurrent.ExecutorService;

/**
* @author emeroad
*/
@Configuration
public class GrpcAgentReceiverConfiguration {

public GrpcAgentReceiverConfiguration() {
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.bindaddress")
public BindAddress.Builder grpcAgentBindAddressBuilder() {
BindAddress.Builder builder = BindAddress.newBuilder();
builder.setPort(9991);
return builder;
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.server.executor")
public MonitoringExecutorProperties grpcAgentServerExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.server-call.executor")
public MonitoringExecutorProperties grpcAgentServerCallExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.agent.worker.executor")
public MonitoringExecutorProperties grpcAgentWorkerExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@ConfigurationProperties("collector.receiver.grpc.agent")
public GrpcPropertiesServerOptionBuilder grpcAgentServerOption() {
// Server option
return new GrpcPropertiesServerOptionBuilder();
}

@Bean
public GrpcReceiverProperties grpcAgentReceiverProperties(Environment environment) {
boolean enable = environment.getProperty("collector.receiver.grpc.agent.enable", boolean.class, false);

ServerOption serverOption = grpcAgentServerOption().build();
BindAddress bindAddress = grpcAgentBindAddressBuilder().build();

return new GrpcReceiverProperties(enable, bindAddress, serverOption);
}

@Bean
public FactoryBean<ExecutorService> grpcAgentWorkerExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcAgentWorkerExecutorProperties();
return executors.newExecutorFactoryBean(properties, beanName);
}


@Bean
public FactoryBean<ExecutorService> grpcAgentServerExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcAgentServerExecutorProperties();
return executors.newExecutorFactoryBean(properties, beanName);
}

@Bean
public FactoryBean<ExecutorService> grpcAgentServerCallExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcAgentServerCallExecutorProperties();
properties.setLogRate(1);
return executors.newExecutorFactoryBean(properties, beanName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright 2021 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.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import com.navercorp.pinpoint.grpc.server.ServerOption;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.validation.annotation.Validated;

import java.util.concurrent.ExecutorService;


/**
* @author emeroad
*/
@Configuration
public class GrpcSpanConfiguration {

public GrpcSpanConfiguration() {
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.span.bindaddress")
public BindAddress.Builder grpcSpanBindAddressBuilder() {
BindAddress.Builder builder = BindAddress.newBuilder();
builder.setPort(9993);
return builder;
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.span.server.executor")
public MonitoringExecutorProperties grpcSpanServerExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.span.server-call.executor")
public MonitoringExecutorProperties grpcSpanServerCallExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.span.worker.executor")
public MonitoringExecutorProperties grpcSpanWorkerExecutorProperties() {
return new MonitoringExecutorProperties();
}

@Bean
@Validated
@ConfigurationProperties("collector.receiver.grpc.span.stream")
public GrpcStreamProperties grpcSpanStreamProperties() {
return new GrpcStreamProperties();
}

@Bean
@ConfigurationProperties("collector.receiver.grpc.span")
public GrpcPropertiesServerOptionBuilder grpcSpanServerOption() {
// Server option
return new GrpcPropertiesServerOptionBuilder();
}

@Bean
public GrpcReceiverProperties grpcSpanReceiverProperties(Environment environment) {

boolean enable = environment.getProperty("collector.receiver.grpc.span.enable", boolean.class, false);

ServerOption serverOption = grpcSpanServerOption().build();

BindAddress bindAddress = grpcSpanBindAddressBuilder().build();

return new GrpcReceiverProperties(enable, bindAddress, serverOption);
}

@Bean
public FactoryBean<ExecutorService> grpcSpanWorkerExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcSpanWorkerExecutorProperties();
return executors.newExecutorFactoryBean(properties, beanName);
}

@Bean
public FactoryBean<ExecutorService> grpcSpanServerExecutor(MonitoringExecutors executors) {
String beanName = CallerUtils.getCallerMethodName();
MonitoringExecutorProperties properties = grpcSpanServerExecutorProperties();
return executors.newExecutorFactoryBean(properties, beanName);
}

}
Loading