Skip to content

Commit

Permalink
[#11278] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jul 25, 2024
1 parent 5dbf0be commit cfc6f73
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.navercorp.pinpoint.collector.receiver.grpc.ServerInterceptorFactory;
import com.navercorp.pinpoint.collector.receiver.grpc.ShutdownEventListener;
import com.navercorp.pinpoint.collector.receiver.grpc.SimpleServerCallExecutorSupplier;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.Monitor;
import com.navercorp.pinpoint.collector.receiver.grpc.service.AgentLifecycleListener;
import com.navercorp.pinpoint.collector.receiver.grpc.service.AgentService;
import com.navercorp.pinpoint.collector.receiver.grpc.service.KeepAliveService;
Expand Down Expand Up @@ -117,7 +118,8 @@ public GrpcReceiver grpcAgentReceiver(@Qualifier("grpcAgentReceiverProperties")
@Qualifier("grpcAgentServerExecutor")
Executor grpcSpanExecutor,
@Qualifier("grpcAgentServerCallExecutorSupplier")
SimpleServerCallExecutorSupplier simpleServerCallExecutorSupplier) {
SimpleServerCallExecutorSupplier simpleServerCallExecutorSupplier,
Monitor monitor) {
GrpcReceiver grpcReceiver = new GrpcReceiver();
grpcReceiver.setBindAddress(properties.getBindAddress());
grpcReceiver.setAddressFilter(addressFilter);
Expand All @@ -129,6 +131,8 @@ public GrpcReceiver grpcAgentReceiver(@Qualifier("grpcAgentReceiverProperties")
grpcReceiver.setServerOption(properties.getServerOption());

grpcReceiver.setServerCallExecutorSupplier(simpleServerCallExecutorSupplier);

grpcReceiver.setMonitor(monitor);
return grpcReceiver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

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

import com.navercorp.pinpoint.collector.receiver.grpc.monitor.BasicMonitor;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.Monitor;
import com.navercorp.pinpoint.collector.receiver.grpc.service.DefaultServerRequestFactory;
import com.navercorp.pinpoint.collector.receiver.grpc.service.ServerRequestFactory;
import com.navercorp.pinpoint.common.server.bo.filter.SpanEventFilter;
import com.navercorp.pinpoint.common.server.bo.grpc.CollectorGrpcSpanFactory;
import com.navercorp.pinpoint.common.server.bo.grpc.GrpcSpanBinder;
import io.grpc.ServerTransportFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand Down Expand Up @@ -54,4 +57,12 @@ public CollectorGrpcSpanFactory collectorGrpcSpanFactory(SpanEventFilter spanEve
return new CollectorGrpcSpanFactory(grpcSpanBinder, spanEventFilter);
}

@Bean
public Monitor grpcReceiverMonitor(@Value("${collector.receiver.grpc.monitor.enable:true}") boolean enable) {
if (enable) {
return new BasicMonitor("GrpcReceiverMonitor");
} else {
return Monitor.NONE;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.navercorp.pinpoint.collector.receiver.grpc.GrpcReceiver;
import com.navercorp.pinpoint.collector.receiver.grpc.ServerInterceptorFactory;
import com.navercorp.pinpoint.collector.receiver.grpc.flow.RateLimitClientStreamServerInterceptor;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.Monitor;
import com.navercorp.pinpoint.collector.receiver.grpc.service.ServerRequestFactory;
import com.navercorp.pinpoint.collector.receiver.grpc.service.SpanService;
import com.navercorp.pinpoint.collector.receiver.grpc.service.StreamExecutorServerInterceptorFactory;
Expand Down Expand Up @@ -140,7 +141,8 @@ public GrpcReceiver grpcSpanReceiver(@Qualifier("grpcSpanReceiverProperties")
List<ServerTransportFilter> serverTransportFilterList,
ChannelzRegistry channelzRegistry,
@Qualifier("grpcSpanServerExecutor")
Executor grpcSpanExecutor) {
Executor grpcSpanExecutor,
Monitor monitor) {
GrpcReceiver grpcReceiver = new GrpcReceiver();
grpcReceiver.setBindAddress(properties.getBindAddress());
grpcReceiver.setAddressFilter(addressFilter);
Expand All @@ -151,6 +153,7 @@ public GrpcReceiver grpcSpanReceiver(@Qualifier("grpcSpanReceiverProperties")
grpcReceiver.setExecutor(grpcSpanExecutor);
grpcReceiver.setEnable(properties.isEnable());
grpcReceiver.setServerOption(properties.getServerOption());
grpcReceiver.setMonitor(monitor);
return grpcReceiver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.navercorp.pinpoint.collector.receiver.grpc.GrpcReceiver;
import com.navercorp.pinpoint.collector.receiver.grpc.ServerInterceptorFactory;
import com.navercorp.pinpoint.collector.receiver.grpc.flow.RateLimitClientStreamServerInterceptor;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.Monitor;
import com.navercorp.pinpoint.collector.receiver.grpc.service.ServerRequestFactory;
import com.navercorp.pinpoint.collector.receiver.grpc.service.StatService;
import com.navercorp.pinpoint.collector.receiver.grpc.service.StreamExecutorServerInterceptorFactory;
Expand Down Expand Up @@ -145,7 +146,8 @@ public GrpcReceiver grpcStatReceiver(@Qualifier("grpcStatReceiverProperties")
List<ServerTransportFilter> serverTransportFilterList,
ChannelzRegistry channelzRegistry,
@Qualifier("grpcStatServerExecutor")
Executor grpcSpanExecutor) {
Executor grpcSpanExecutor,
Monitor monitor) {
GrpcReceiver grpcReceiver = new GrpcReceiver();
grpcReceiver.setBindAddress(properties.getBindAddress());
grpcReceiver.setAddressFilter(addressFilter);
Expand All @@ -156,6 +158,7 @@ public GrpcReceiver grpcStatReceiver(@Qualifier("grpcStatReceiverProperties")
grpcReceiver.setExecutor(grpcSpanExecutor);
grpcReceiver.setEnable(properties.isEnable());
grpcReceiver.setServerOption(properties.getServerOption());
grpcReceiver.setMonitor(monitor);
return grpcReceiver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.navercorp.pinpoint.collector.receiver.grpc;

import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.BasicMonitor;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.EmptyMonitor;
import com.navercorp.pinpoint.collector.receiver.grpc.monitor.Monitor;
import com.navercorp.pinpoint.common.server.util.AddressFilter;
import com.navercorp.pinpoint.common.util.Assert;
Expand Down Expand Up @@ -83,8 +81,7 @@ public class GrpcReceiver implements InitializingBean, DisposableBean, BeanNameA
private Server server;
private ChannelzRegistry channelzRegistry;

private boolean enableMonitor = true;
private Monitor monitor;
private Monitor monitor = Monitor.NONE;


@Override
Expand All @@ -99,11 +96,6 @@ public void afterPropertiesSet() throws Exception {
Objects.requireNonNull(this.addressFilter, "addressFilter");
Assert.isTrue(CollectionUtils.hasLength(this.serviceList), "serviceList must not be empty");
Objects.requireNonNull(this.serverOption, "serverOption");
if (enableMonitor) {
this.monitor = new BasicMonitor(beanName + "-Monitor");
} else {
this.monitor = new EmptyMonitor();
}

if (sslContext != null) {
this.serverFactory = new ServerFactory(beanName, this.bindAddress.getIp(), this.bindAddress.getPort(), this.executor, this.serverCallExecutorSupplier, serverOption, sslContext);
Expand Down Expand Up @@ -267,7 +259,7 @@ public void setChannelzRegistry(ChannelzRegistry channelzRegistry) {
this.channelzRegistry = Objects.requireNonNull(channelzRegistry, "channelzRegistry");
}

public void setEnableMonitor(boolean enableMonitor) {
this.enableMonitor = enableMonitor;
public void setMonitor(Monitor monitor) {
this.monitor = Objects.requireNonNull(monitor, "monitor");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.Closeable;

public interface Monitor extends Closeable {
Monitor NONE = new EmptyMonitor();

void register(Runnable job);

Expand Down

0 comments on commit cfc6f73

Please sign in to comment.