Skip to content

Commit dee0241

Browse files
committed
[#9666] Moved realtime module from starter into basic
1 parent ffb72ed commit dee0241

File tree

46 files changed

+597
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+597
-256
lines changed

collector/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
</properties>
3939

4040
<dependencies>
41+
<dependency>
42+
<groupId>com.navercorp.pinpoint</groupId>
43+
<artifactId>pinpoint-realtime-collector</artifactId>
44+
</dependency>
4145
<dependency>
4246
<groupId>com.navercorp.pinpoint</groupId>
4347
<artifactId>pinpoint-commons</artifactId>

collector/src/main/java/com/navercorp/pinpoint/collector/CollectorApp.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import com.navercorp.pinpoint.common.server.util.ServerBootLogger;
44
import org.springframework.boot.SpringBootConfiguration;
55
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6+
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
7+
import org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration;
8+
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
9+
import org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration;
610
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
711
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
812
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration;
@@ -14,10 +18,14 @@
1418
DataSourceAutoConfiguration.class,
1519
DataSourceTransactionManagerAutoConfiguration.class,
1620
TransactionAutoConfiguration.class,
17-
SqlInitializationAutoConfiguration.class
21+
SqlInitializationAutoConfiguration.class,
22+
SpringDataWebAutoConfiguration.class,
23+
RedisAutoConfiguration.class,
24+
RedisRepositoriesAutoConfiguration.class,
25+
RedisReactiveAutoConfiguration.class,
1826
})
1927
@Import({
20-
PinpointCollectorModule.class
28+
PinpointCollectorModule.class,
2129
})
2230
public class CollectorApp {
2331
private static final ServerBootLogger logger = ServerBootLogger.getLogger(CollectorApp.class);

collector/src/main/java/com/navercorp/pinpoint/collector/PinpointCollectorModule.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.navercorp.pinpoint.collector;
22

33

4+
import com.navercorp.pinpoint.collector.cluster.RealtimeCollectorModuleAdaptorConfig;
45
import com.navercorp.pinpoint.collector.config.ClusterModule;
56
import com.navercorp.pinpoint.collector.config.CollectorProperties;
67
import com.navercorp.pinpoint.collector.config.FlinkContextModule;
@@ -36,7 +37,9 @@
3637

3738
MetricConfiguration.class,
3839

39-
GrpcSslModule.class
40+
GrpcSslModule.class,
41+
42+
RealtimeCollectorModuleAdaptorConfig.class,
4043
})
4144
@ComponentScan(basePackages = {
4245
"com.navercorp.pinpoint.collector.handler",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright 2023 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.cluster;
17+
18+
import com.google.protobuf.GeneratedMessageV3;
19+
import com.navercorp.pinpoint.io.ResponseMessage;
20+
import com.navercorp.pinpoint.realtime.collector.service.AgentConnection;
21+
import com.navercorp.pinpoint.rpc.stream.ClientStreamChannel;
22+
import com.navercorp.pinpoint.rpc.stream.ClientStreamChannelEventHandler;
23+
import com.navercorp.pinpoint.rpc.stream.StreamException;
24+
import com.navercorp.pinpoint.thrift.sender.message.CommandGrpcToThriftMessageConverter;
25+
import org.apache.thrift.TBase;
26+
27+
import java.util.Objects;
28+
import java.util.concurrent.CompletableFuture;
29+
30+
/**
31+
* @author youngjin.kim2
32+
*/
33+
public class AgentConnectionImpl implements AgentConnection {
34+
35+
private final ClusterPoint<?> clusterPoint;
36+
private final CommandGrpcToThriftMessageConverter messageConverter;
37+
38+
public AgentConnectionImpl(ClusterPoint<?> clusterPoint, CommandGrpcToThriftMessageConverter messageConverter) {
39+
this.clusterPoint = Objects.requireNonNull(clusterPoint, "clusterPoint");
40+
this.messageConverter = Objects.requireNonNull(messageConverter, "messageConverter");
41+
}
42+
43+
@Override
44+
public ClientStreamChannel requestStream(ClientStreamChannelEventHandler handler, GeneratedMessageV3 command) {
45+
TBase<?, ?> tCommand = this.messageConverter.toMessage(command);
46+
if (!this.clusterPoint.isSupportCommand(tCommand)) {
47+
throw new RuntimeException("Unsupported command: " + command);
48+
}
49+
if (clusterPoint instanceof GrpcAgentConnection) {
50+
return openStream(handler, tCommand);
51+
}
52+
throw new RuntimeException("Invalid clusterPoint: " + clusterPoint);
53+
}
54+
55+
private ClientStreamChannel openStream(ClientStreamChannelEventHandler handler, TBase<?, ?> tCommand) {
56+
try {
57+
return ((GrpcAgentConnection) clusterPoint).openStream(tCommand, handler);
58+
} catch (StreamException e) {
59+
throw new RuntimeException("Failed to openStream " + tCommand);
60+
}
61+
}
62+
63+
@Override
64+
public CompletableFuture<ResponseMessage> request(GeneratedMessageV3 command) {
65+
TBase<?, ?> tCommand = this.messageConverter.toMessage(command);
66+
if (!this.clusterPoint.isSupportCommand(tCommand)) {
67+
throw new RuntimeException("Unsupported command: " + command);
68+
}
69+
if (clusterPoint instanceof GrpcAgentConnection) {
70+
return ((GrpcAgentConnection) this.clusterPoint).request(tCommand);
71+
}
72+
throw new RuntimeException("Invalid clusterPoint: " + clusterPoint);
73+
}
74+
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2023 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.cluster;
17+
18+
import com.navercorp.pinpoint.collector.cluster.route.StreamRouteHandler;
19+
import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
20+
import com.navercorp.pinpoint.realtime.collector.service.AgentConnection;
21+
import com.navercorp.pinpoint.realtime.collector.service.AgentConnectionRepository;
22+
import com.navercorp.pinpoint.thrift.sender.message.CommandGrpcToThriftMessageConverter;
23+
24+
import java.util.Objects;
25+
26+
/**
27+
* @author youngjin.kim2
28+
*/
29+
public class AgentConnectionRepositoryImpl implements AgentConnectionRepository {
30+
31+
private final StreamRouteHandler streamRouteHandler;
32+
33+
private final CommandGrpcToThriftMessageConverter messageConverter = new CommandGrpcToThriftMessageConverter();
34+
35+
public AgentConnectionRepositoryImpl(StreamRouteHandler streamRouteHandler) {
36+
this.streamRouteHandler = Objects.requireNonNull(streamRouteHandler, "streamRouteHandler");
37+
}
38+
39+
@Override
40+
public AgentConnection getConnection(ClusterKey key) {
41+
ClusterPoint<?> clusterPoint = this.streamRouteHandler.findClusterPoint(key);
42+
if (clusterPoint == null) {
43+
return null;
44+
}
45+
46+
return new AgentConnectionImpl(clusterPoint, this.messageConverter);
47+
}
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2023 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.cluster;
17+
18+
import com.navercorp.pinpoint.collector.cluster.route.StreamRouteHandler;
19+
import com.navercorp.pinpoint.realtime.collector.RealtimeCollectorModule;
20+
import com.navercorp.pinpoint.realtime.collector.service.AgentConnectionRepository;
21+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.context.annotation.Configuration;
25+
import org.springframework.context.annotation.Import;
26+
27+
/**
28+
* @author youngjin.kim2
29+
*/
30+
@Configuration(proxyBeanMethods = false)
31+
@ConditionalOnProperty(value = "pinpoint.modules.realtime.enabled", havingValue = "true")
32+
@Import(RealtimeCollectorModule.class)
33+
public class RealtimeCollectorModuleAdaptorConfig {
34+
35+
@Bean
36+
@ConditionalOnBean(StreamRouteHandler.class)
37+
AgentConnectionRepository agentConnectionRepository(StreamRouteHandler streamRouteHandler) {
38+
return new AgentConnectionRepositoryImpl(streamRouteHandler);
39+
}
40+
41+
}

web/src/main/java/com/navercorp/pinpoint/web/task/TimerTaskDecorator.java renamed to commons/src/main/java/com/navercorp/pinpoint/common/task/TimerTaskDecorator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.navercorp.pinpoint.web.task;
17+
package com.navercorp.pinpoint.common.task;
1818

1919
import java.util.TimerTask;
2020

web/src/main/java/com/navercorp/pinpoint/web/task/TimerTaskDecoratorFactory.java renamed to commons/src/main/java/com/navercorp/pinpoint/common/task/TimerTaskDecoratorFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.navercorp.pinpoint.web.task;
17+
package com.navercorp.pinpoint.common.task;
1818

1919
/**
2020
* @author HyunGil Jeong

metric-module/collector-starter/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
<groupId>com.navercorp.pinpoint</groupId>
3535
<artifactId>pinpoint-uristat-collector</artifactId>
3636
</dependency>
37-
<dependency>
38-
<groupId>com.navercorp.pinpoint</groupId>
39-
<artifactId>pinpoint-realtime-collector</artifactId>
40-
</dependency>
4137
<dependency>
4238
<groupId>com.navercorp.pinpoint</groupId>
4339
<artifactId>pinpoint-inspector-collector</artifactId>

metric-module/collector-starter/src/main/java/com/navercorp/pinpoint/collector/starter/multi/application/MultiApplication.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.navercorp.pinpoint.metric.collector.CollectorTypeParser;
1212
import com.navercorp.pinpoint.metric.collector.MetricCollectorApp;
1313
import com.navercorp.pinpoint.metric.collector.TypeSet;
14-
import com.navercorp.pinpoint.realtime.collector.RealtimeCollectorConfig;
1514
import com.navercorp.pinpoint.uristat.collector.UriStatCollectorConfig;
1615
import org.springframework.boot.Banner;
1716
import org.springframework.boot.SpringBootConfiguration;
@@ -61,8 +60,7 @@ public static void main(String[] args) {
6160
logger.info(String.format("Start %s collector", CollectorType.BASIC));
6261
SpringApplicationBuilder collectorAppBuilder = createAppBuilder(builder, 15400,
6362
BasicCollectorApp.class,
64-
UriStatCollectorConfig.class,
65-
RealtimeCollectorConfig.class
63+
UriStatCollectorConfig.class
6664
);
6765
collectorAppBuilder.listeners(new AdditionalProfileListener("metric"));
6866
collectorAppBuilder.listeners(new AdditionalProfileListener("uri"));
@@ -74,7 +72,6 @@ public static void main(String[] args) {
7472
SpringApplicationBuilder collectorAppBuilder = createAppBuilder(builder, 15400,
7573
BasicCollectorApp.class,
7674
UriStatCollectorConfig.class,
77-
RealtimeCollectorConfig.class,
7875
InspectorCollectorApp.class
7976
);
8077
collectorAppBuilder.build().run(args);

metric-module/web-starter/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
<groupId>com.navercorp.pinpoint</groupId>
4545
<artifactId>pinpoint-uristat-web</artifactId>
4646
</dependency>
47-
<dependency>
48-
<groupId>com.navercorp.pinpoint</groupId>
49-
<artifactId>pinpoint-realtime-web</artifactId>
50-
</dependency>
5147
<dependency>
5248
<groupId>com.navercorp.pinpoint</groupId>
5349
<artifactId>pinpoint-inspector-web</artifactId>

metric-module/web-starter/src/main/java/com/navercorp/pinpoint/web/starter/multi/MetricAndWebApp.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
package com.navercorp.pinpoint.web.starter.multi;
1818

1919
import com.navercorp.pinpoint.common.server.util.ServerBootLogger;
20-
import com.navercorp.pinpoint.login.basic.PinpointBasicLoginConfig;
2120
import com.navercorp.pinpoint.inspector.web.InspectorWebApp;
21+
import com.navercorp.pinpoint.login.basic.PinpointBasicLoginConfig;
2222
import com.navercorp.pinpoint.metric.web.MetricWebApp;
2323
import com.navercorp.pinpoint.uristat.web.UriStatWebConfig;
2424
import com.navercorp.pinpoint.web.AuthorizationConfig;
2525
import com.navercorp.pinpoint.web.PinpointWebModule;
2626
import com.navercorp.pinpoint.web.WebApp;
2727
import com.navercorp.pinpoint.web.WebStarter;
28-
import com.navercorp.pinpoint.web.realtime.RealtimeWebConfig;
2928
import org.springframework.boot.SpringBootConfiguration;
3029
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
3130
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
@@ -63,7 +62,6 @@ public static void main(String[] args) {
6362
AuthorizationConfig.class,
6463
MetricWebApp.class,
6564
UriStatWebConfig.class,
66-
RealtimeWebConfig.class,
6765
InspectorWebApp.class
6866
);
6967
starter.addProfiles("uri", "metric");

realtime/realtime-collector/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</dependency>
2424
<dependency>
2525
<groupId>com.navercorp.pinpoint</groupId>
26-
<artifactId>pinpoint-collector</artifactId>
26+
<artifactId>pinpoint-thrift-datasender</artifactId>
2727
</dependency>
2828
</dependencies>
2929

Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
CollectorActiveThreadDumpConfig.class,
3333
CollectorEchoConfig.class
3434
})
35-
public class RealtimeCollectorConfig {
35+
public class RealtimeCollectorModule {
3636
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2023 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.realtime.collector.service;
17+
18+
import com.google.protobuf.GeneratedMessageV3;
19+
import com.navercorp.pinpoint.io.ResponseMessage;
20+
import com.navercorp.pinpoint.rpc.stream.ClientStreamChannel;
21+
import com.navercorp.pinpoint.rpc.stream.ClientStreamChannelEventHandler;
22+
23+
import java.util.concurrent.CompletableFuture;
24+
25+
/**
26+
* @author youngjin.kim2
27+
*/
28+
public interface AgentConnection {
29+
30+
ClientStreamChannel requestStream(ClientStreamChannelEventHandler handler, GeneratedMessageV3 command);
31+
32+
CompletableFuture<ResponseMessage> request(GeneratedMessageV3 command);
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2023 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.realtime.collector.service;
17+
18+
import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
19+
20+
/**
21+
* @author youngjin.kim2
22+
*/
23+
public interface AgentConnectionRepository {
24+
25+
AgentConnection getConnection(ClusterKey key);
26+
27+
}

0 commit comments

Comments
 (0)