Skip to content

Commit

Permalink
[#7375] Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Dec 11, 2020
1 parent cac2bd0 commit b24f9e7
Show file tree
Hide file tree
Showing 31 changed files with 258 additions and 306 deletions.
2 changes: 2 additions & 0 deletions agent/src/main/resources/pinpoint-root.config
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ profiler.transport.grpc.span.sender.discardpolicy.not-ready-timeout-millis=30000
## AUTO, NIO, EPOLL
profiler.transport.grpc.span.sender.channel-type=AUTO
profiler.transport.grpc.span.sender.maxtraceevent=8
profiler.transport.grpc.span.sender.limitcount=100
profiler.transport.grpc.span.sender.limittime=60000

# This configuration enable some function of netty
# Functions are available without the this configuration when using jdk8 and below,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public Attributes transportReady(Attributes transportAttrs) {
final InetSocketAddress remoteAddress = transportMetadata.getRemoteAddress();
final InetSocketAddress localAddress = transportMetadata.getLocalAddress();


if (logger.isDebugEnabled()) {
logger.debug("Add logId:{} remoteAddress:{} localAddress:{}",
logId,
Expand All @@ -53,9 +52,6 @@ public void transportTerminated(Attributes transportAttrs) {
final TransportMetadata transportMetadata = getTransportMetadata(transportAttrs);

final InetSocketAddress remoteAddress = transportMetadata.getRemoteAddress();
final InetSocketAddress localAddress = transportMetadata.getLocalAddress();
final String target = remoteAddress.getHostString() + ":" + localAddress.getPort();


final Long logId = registry.removeSocket(remoteAddress);
if (logger.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public class ClientOption {
public static final int DEFAULT_WRITE_BUFFER_HIGH_WATER_MARK = 32 * 1024 * 1024;
public static final int DEFAULT_WRITE_BUFFER_LOW_WATER_MARK = 16 * 1024 * 1024;
public static final String DEFAULT_CHANNEL_TYPE = ChannelTypeEnum.AUTO.name();

public static final int DEFAULT_MAX_TRACE_EVENT = 0;
public static final int DEFAULT_LIMIT_COUNT = 100;
public static final int DEFAULT_LIMIT_TIME = 60 * 1000;

private final long keepAliveTime;
private final long keepAliveTimeout;
Expand All @@ -56,10 +59,12 @@ public class ClientOption {
private final int writeBufferLowWaterMark;
private final ChannelTypeEnum channelTypeEnum;
private final int maxTraceEvent;
private final int limitCount;
private final long limitTime;

private ClientOption(long keepAliveTime, long keepAliveTimeout, int maxHeaderListSize, int maxInboundMessageSize,
int flowControlWindow, int connectTimeout, int writeBufferHighWaterMark, int writeBufferLowWaterMark,
ChannelTypeEnum channelTypeEnum, int maxTraceEvent) {
ChannelTypeEnum channelTypeEnum, int maxTraceEvent, int limitCount, long limitTime) {
this.keepAliveTime = keepAliveTime;
this.keepAliveTimeout = keepAliveTimeout;
this.flowControlWindow = flowControlWindow;
Expand All @@ -71,6 +76,9 @@ private ClientOption(long keepAliveTime, long keepAliveTimeout, int maxHeaderLis

this.channelTypeEnum = Assert.requireNonNull(channelTypeEnum, "channelTypeEnum");
this.maxTraceEvent = maxTraceEvent;

this.limitCount = limitCount;
this.limitTime = limitTime;
}

public int getFlowControlWindow() {
Expand Down Expand Up @@ -120,24 +128,32 @@ public int getMaxTraceEvent() {
return maxTraceEvent;
}

public int getLimitCount() {
return limitCount;
}

public long getLimitTime() {
return limitTime;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("ClientOption{");
sb.append("keepAliveTime=").append(keepAliveTime);
sb.append(", keepAliveTimeout=").append(keepAliveTimeout);
sb.append(", keepAliveWithoutCalls=").append(keepAliveWithoutCalls);
sb.append(", idleTimeoutMillis=").append(idleTimeoutMillis);
sb.append(", maxHeaderListSize=").append(maxHeaderListSize);
sb.append(", maxInboundMessageSize=").append(maxInboundMessageSize);
sb.append(", flowControlWindow=").append(flowControlWindow);
sb.append(", connectTimeout=").append(connectTimeout);
sb.append(", writeBufferHighWaterMark=").append(writeBufferHighWaterMark);
sb.append(", writeBufferLowWaterMark=").append(writeBufferLowWaterMark);
sb.append(", channelTypeEnum=").append(channelTypeEnum);
sb.append(", maxTraceEvent=").append(maxTraceEvent);
sb.append('}');

return sb.toString();
return "ClientOption{" +
"keepAliveTime=" + keepAliveTime +
", keepAliveTimeout=" + keepAliveTimeout +
", keepAliveWithoutCalls=" + keepAliveWithoutCalls +
", idleTimeoutMillis=" + idleTimeoutMillis +
", maxHeaderListSize=" + maxHeaderListSize +
", maxInboundMessageSize=" + maxInboundMessageSize +
", flowControlWindow=" + flowControlWindow +
", connectTimeout=" + connectTimeout +
", writeBufferHighWaterMark=" + writeBufferHighWaterMark +
", writeBufferLowWaterMark=" + writeBufferLowWaterMark +
", channelTypeEnum=" + channelTypeEnum +
", maxTraceEvent=" + maxTraceEvent +
", limitCount=" + limitCount +
", limitTime=" + limitTime +
'}';
}

public static class Builder {
Expand All @@ -154,10 +170,14 @@ public static class Builder {
private ChannelTypeEnum channelTypeEnum = ChannelTypeEnum.valueOf(DEFAULT_CHANNEL_TYPE);
private int maxTraceEvent;

private int limitCount;
private long limitTime;

public ClientOption build() {
final ClientOption clientOption = new ClientOption(keepAliveTime, keepAliveTimeout, maxHeaderListSize, maxInboundMessageSize,
flowControlWindow, connectTimeout,
writeBufferHighWaterMark, writeBufferLowWaterMark, channelTypeEnum, maxTraceEvent);
writeBufferHighWaterMark, writeBufferLowWaterMark, channelTypeEnum,
maxTraceEvent, limitCount, limitTime);
return clientOption;
}

Expand Down Expand Up @@ -213,21 +233,32 @@ public void setMaxTraceEvent(int maxTraceEvent) {
this.maxTraceEvent = maxTraceEvent;
}

public void setLimitCount(int limitCount) {
Assert.isTrue(limitCount >= 0, "limitCount must be positive");
this.limitCount = limitCount;
}

public void setLimitTime(long limitTime) {
Assert.isTrue(limitTime >= 0, "limitTime must be positive");
this.limitTime = limitTime;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Builder{");
sb.append("flowControlWindow=").append(flowControlWindow);
sb.append(", maxHeaderListSize=").append(maxHeaderListSize);
sb.append(", keepAliveTime=").append(keepAliveTime);
sb.append(", keepAliveTimeout=").append(keepAliveTimeout);
sb.append(", maxInboundMessageSize=").append(maxInboundMessageSize);
sb.append(", connectTimeout=").append(connectTimeout);
sb.append(", writeBufferHighWaterMark=").append(writeBufferHighWaterMark);
sb.append(", writeBufferLowWaterMark=").append(writeBufferLowWaterMark);
sb.append(", channelTypeEnum=").append(channelTypeEnum);
sb.append(", maxTraceEvent=").append(maxTraceEvent);
sb.append('}');
return sb.toString();
return "Builder{" +
"flowControlWindow=" + flowControlWindow +
", maxHeaderListSize=" + maxHeaderListSize +
", keepAliveTime=" + keepAliveTime +
", keepAliveTimeout=" + keepAliveTimeout +
", maxInboundMessageSize=" + maxInboundMessageSize +
", connectTimeout=" + connectTimeout +
", writeBufferHighWaterMark=" + writeBufferHighWaterMark +
", writeBufferLowWaterMark=" + writeBufferLowWaterMark +
", channelTypeEnum=" + channelTypeEnum +
", maxTraceEvent=" + maxTraceEvent +
", limitCount=" + limitCount +
", limitTime=" + limitTime +
'}';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ private ClientOption readClientOption(final ProfilerConfig profilerConfig, final
builder.setChannelTypeEnum(profilerConfig.readString(transportName + ".channel-type", ClientOption.DEFAULT_CHANNEL_TYPE));
builder.setMaxTraceEvent(profilerConfig.readInt(transportName + ".maxtraceevent", ClientOption.DEFAULT_MAX_TRACE_EVENT));

builder.setLimitCount(profilerConfig.readInt(transportName + ".limitcount", ClientOption.DEFAULT_LIMIT_COUNT));
builder.setLimitTime(profilerConfig.readInt(transportName + ".limittime", ClientOption.DEFAULT_LIMIT_TIME));

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* @author jaehong.kim
*/
@BindingAnnotation
@Target(PARAMETER)
@Target({PARAMETER, METHOD})
@Retention(RUNTIME)
public @interface AgentDataSender {
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
import com.google.protobuf.GeneratedMessageV3;

import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig;
import com.navercorp.pinpoint.common.util.Assert;
import com.navercorp.pinpoint.profiler.context.grpc.GrpcTransportConfig;
import com.navercorp.pinpoint.grpc.client.HeaderFactory;
import com.navercorp.pinpoint.grpc.trace.PSpan;
import com.navercorp.pinpoint.grpc.trace.PSpanChunk;
Expand All @@ -34,6 +32,7 @@
import com.navercorp.pinpoint.profiler.context.grpc.GrpcMetadataMessageConverterProvider;
import com.navercorp.pinpoint.profiler.context.grpc.GrpcSpanMessageConverterProvider;
import com.navercorp.pinpoint.profiler.context.grpc.GrpcStatMessageConverterProvider;
import com.navercorp.pinpoint.profiler.context.grpc.GrpcTransportConfig;
import com.navercorp.pinpoint.profiler.context.provider.grpc.AgentGrpcDataSenderProvider;
import com.navercorp.pinpoint.profiler.context.provider.grpc.AgentHeaderFactoryProvider;
import com.navercorp.pinpoint.profiler.context.provider.grpc.DnsExecutorServiceProvider;
Expand Down Expand Up @@ -92,7 +91,7 @@ protected void configure() {

// Agent
TypeLiteral<MessageConverter<GeneratedMessageV3>> metadataMessageConverter = new TypeLiteral<MessageConverter<GeneratedMessageV3>>() {};
Key<MessageConverter<GeneratedMessageV3>> metadataMessageConverterKey = Key.get(metadataMessageConverter, MetadataConverter.class);
Key<MessageConverter<GeneratedMessageV3>> metadataMessageConverterKey = Key.get(metadataMessageConverter, MetadataDataSender.class);
bind(metadataMessageConverterKey).toProvider(GrpcMetadataMessageConverterProvider.class ).in(Scopes.SINGLETON);

TypeLiteral<MessageConverter<ResultResponse>> resultMessageConverter = new TypeLiteral<MessageConverter<ResultResponse>>() {};
Expand All @@ -111,7 +110,7 @@ protected void configure() {

// Span
TypeLiteral<MessageConverter<GeneratedMessageV3>> protoMessageConverter = new TypeLiteral<MessageConverter<GeneratedMessageV3>>() {};
Key<MessageConverter<GeneratedMessageV3>> spanMessageConverterKey = Key.get(protoMessageConverter, SpanConverter.class);
Key<MessageConverter<GeneratedMessageV3>> spanMessageConverterKey = Key.get(protoMessageConverter, SpanDataSender.class);
// not singleton
bind(spanMessageConverterKey).toProvider(GrpcSpanMessageConverterProvider.class);

Expand All @@ -124,7 +123,7 @@ protected void configure() {

// Stat
TypeLiteral<MessageConverter<GeneratedMessageV3>> statMessageConverter = new TypeLiteral<MessageConverter<GeneratedMessageV3>>() {};
Key<MessageConverter<GeneratedMessageV3>> statMessageConverterKey = Key.get(statMessageConverter, StatConverter.class);
Key<MessageConverter<GeneratedMessageV3>> statMessageConverterKey = Key.get(statMessageConverter, StatDataSender.class);
bind(statMessageConverterKey).toProvider(GrpcStatMessageConverterProvider.class ).in(Scopes.SINGLETON);

Key<DataSender> statDataSender = Key.get(DataSender.class, StatDataSender.class);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* @author jaehong.kim
*/
@BindingAnnotation
@Target(PARAMETER)
@Target({PARAMETER, METHOD})
@Retention(RUNTIME)
public @interface MetadataDataSender {
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* @author Woonduk Kang(emeroad)
*/
@BindingAnnotation
@Target(PARAMETER)
@Target({PARAMETER, METHOD})
@Retention(RUNTIME)
public @interface SpanDataSender {
}
Loading

0 comments on commit b24f9e7

Please sign in to comment.