Skip to content

Commit c62fd96

Browse files
committed
[pinpoint-apm#9666] ActiveThreadCount durable of delayed querying agent list
1 parent 6874c01 commit c62fd96

23 files changed

+658
-600
lines changed

realtime/realtime-web/src/main/java/com/navercorp/pinpoint/web/realtime/RealtimeWebConfig.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
@Import({
3131
WebActiveThreadCountConfig.class,
3232
WebActiveThreadDumpConfig.class,
33-
WebEchoConfig.class
33+
WebEchoConfig.class,
34+
RealtimeWebPropertySources.class
3435
})
3536
public class RealtimeWebConfig {
3637

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.web.realtime;
17+
18+
import org.springframework.context.annotation.PropertySource;
19+
import org.springframework.context.annotation.PropertySources;
20+
21+
/**
22+
* @author youngjin.kim2
23+
*/
24+
@PropertySources({
25+
@PropertySource(name = "RealtimeWebPropertySourceRoot", value = {RealtimeWebPropertySources.ROOT}),
26+
})
27+
public class RealtimeWebPropertySources {
28+
29+
public static final String ROOT = "classpath:pinpoint-web-realtime.properties";
30+
31+
}
+6-11
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,15 @@
1515
*/
1616
package com.navercorp.pinpoint.web.realtime.activethread.count.dao;
1717

18+
import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
19+
import com.navercorp.pinpoint.realtime.dto.ATCSupply;
20+
import reactor.core.publisher.Flux;
21+
1822
/**
1923
* @author youngjin.kim2
2024
*/
21-
class ConstantFetcher<T> implements Fetcher<T>{
22-
23-
private final T value;
24-
25-
ConstantFetcher(T value) {
26-
this.value = value;
27-
}
25+
public interface ActiveThreadCountDao {
2826

29-
@Override
30-
public T fetch() {
31-
return value;
32-
}
27+
Flux<ATCSupply> getSupplies(ClusterKey agentKey);
3328

3429
}

realtime/realtime-web/src/main/java/com/navercorp/pinpoint/web/realtime/activethread/count/dao/ActiveThreadCountFetcherFactory.java

-69
This file was deleted.

realtime/realtime-web/src/main/java/com/navercorp/pinpoint/web/realtime/activethread/count/dao/ActiveThreadCountWebDaoConfig.java

+2-30
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,32 @@
1515
*/
1616
package com.navercorp.pinpoint.web.realtime.activethread.count.dao;
1717

18-
import com.google.common.cache.Cache;
19-
import com.google.common.cache.CacheBuilder;
20-
import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
2118
import com.navercorp.pinpoint.pubsub.endpoint.PubSubClientFactory;
2219
import com.navercorp.pinpoint.pubsub.endpoint.PubSubFluxClient;
2320
import com.navercorp.pinpoint.realtime.RealtimePubSubServiceDescriptors;
2421
import com.navercorp.pinpoint.realtime.dto.ATCDemand;
2522
import com.navercorp.pinpoint.realtime.dto.ATCSupply;
2623
import com.navercorp.pinpoint.redis.pubsub.RedisPubSubConfig;
2724
import com.navercorp.pinpoint.web.realtime.RealtimeWebCommonConfig;
28-
import org.springframework.beans.factory.annotation.Value;
2925
import org.springframework.context.annotation.Bean;
3026
import org.springframework.context.annotation.Configuration;
3127
import org.springframework.context.annotation.Import;
3228

33-
import java.util.concurrent.TimeUnit;
34-
3529
/**
3630
* @author youngjin.kim2
3731
*/
3832
@Configuration
3933
@Import({ RealtimeWebCommonConfig.class, RedisPubSubConfig.class })
4034
public class ActiveThreadCountWebDaoConfig {
4135

42-
@Value("${pinpoint.web.realtime.atc.supply.expireInMs:3000}")
43-
private long supplyExpireInMs;
44-
45-
@Value("${pinpoint.web.realtime.atc.supply.prepareInMs:10000}")
46-
private long prepareInMs;
47-
4836
@Bean
4937
PubSubFluxClient<ATCDemand, ATCSupply> atcEndpoint(PubSubClientFactory clientFactory) {
5038
return clientFactory.build(RealtimePubSubServiceDescriptors.ATC);
5139
}
5240

5341
@Bean
54-
Cache<ClusterKey, Fetcher<ATCSupply>> fetcherCache() {
55-
return CacheBuilder.newBuilder()
56-
.expireAfterAccess(1, TimeUnit.HOURS)
57-
.initialCapacity(512)
58-
.maximumSize(65536)
59-
.build();
60-
}
61-
62-
@Bean
63-
FetcherFactory<ClusterKey, ATCSupply> atcSupplyFetcherFactory(
64-
PubSubFluxClient<ATCDemand, ATCSupply> endpoint,
65-
Cache<ClusterKey, Fetcher<ATCSupply>> fetcherCache
66-
) {
67-
final long recordMaxAgeNanos = TimeUnit.MILLISECONDS.toNanos(supplyExpireInMs);
68-
final long prepareInNanos = TimeUnit.MILLISECONDS.toNanos(prepareInMs);
69-
final ActiveThreadCountFetcherFactory fetcherFactory
70-
= new ActiveThreadCountFetcherFactory(endpoint, recordMaxAgeNanos, prepareInNanos);
71-
return new CachedFetcherFactory<>(fetcherFactory, fetcherCache);
42+
ActiveThreadCountDao activeThreadCountDao(PubSubFluxClient<ATCDemand, ATCSupply> client) {
43+
return new PubSubActiveThreadCountDao(client);
7244
}
7345

7446
}

realtime/realtime-web/src/main/java/com/navercorp/pinpoint/web/realtime/activethread/count/dao/CachedFetcherFactory.java

-50
This file was deleted.

realtime/realtime-web/src/main/java/com/navercorp/pinpoint/web/realtime/activethread/count/dao/OptimisticFetcher.java

-112
This file was deleted.

0 commit comments

Comments
 (0)