Skip to content

Commit 58591fd

Browse files
committed
[#noissue] Refactor Application handling to include Service
1 parent c3abf0d commit 58591fd

File tree

21 files changed

+254
-91
lines changed

21 files changed

+254
-91
lines changed

batch/src/main/java/com/navercorp/pinpoint/batch/alarm/AlarmProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private List<String> fetchActiveAgents(Application application, Range activeRang
104104
return agentList
105105
.stream()
106106
.filter(id -> {
107-
Application agent = new Application(id, application.getServiceType());
107+
Application agent = new Application(application.getService(), id, application.getServiceType());
108108
return batchAgentService.isActive(agent, activeRange);
109109
})
110110
.toList();

web/src/main/java/com/navercorp/pinpoint/web/agentlist/controller/AgentsController.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@
2121
import com.navercorp.pinpoint.common.timeseries.window.TimeWindow;
2222
import com.navercorp.pinpoint.common.trace.ServiceType;
2323
import com.navercorp.pinpoint.loader.service.ServiceTypeRegistryService;
24+
import com.navercorp.pinpoint.web.agentlist.AgentsFactory;
25+
import com.navercorp.pinpoint.web.agentlist.service.AgentsService;
2426
import com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary;
2527
import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramService;
2628
import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramServiceOption;
2729
import com.navercorp.pinpoint.web.component.ApplicationFactory;
2830
import com.navercorp.pinpoint.web.config.ConfigProperties;
2931
import com.navercorp.pinpoint.web.hyperlink.HyperLinkFactory;
30-
import com.navercorp.pinpoint.web.agentlist.service.AgentsService;
3132
import com.navercorp.pinpoint.web.service.ApplicationAgentListQueryRule;
3233
import com.navercorp.pinpoint.web.vo.Application;
3334
import com.navercorp.pinpoint.web.vo.ApplicationPair;
3435
import com.navercorp.pinpoint.web.vo.ApplicationPairs;
36+
import com.navercorp.pinpoint.web.vo.Service;
3537
import com.navercorp.pinpoint.web.vo.agent.AgentInfoFilters;
3638
import com.navercorp.pinpoint.web.vo.agent.AgentStatusAndLink;
37-
import com.navercorp.pinpoint.web.agentlist.AgentsFactory;
3839
import jakarta.validation.constraints.NotBlank;
3940
import jakarta.validation.constraints.PositiveOrZero;
4041
import org.springframework.security.access.prepost.PreAuthorize;
@@ -97,7 +98,7 @@ public List<AgentStatusAndLink> getAgentsList(
9798
final ApplicationAgentListQueryRule applicationAgentListQueryRule = ApplicationAgentListQueryRule
9899
.getByValue(query, ApplicationAgentListQueryRule.ALL);
99100
final long timestamp = System.currentTimeMillis();
100-
final Application application = createApplication(applicationName, serviceTypeCode, serviceTypeName);
101+
final Application application = createApplication(Service.DEFAULT, applicationName, serviceTypeCode, serviceTypeName);
101102
Range between = Range.between(timestamp, timestamp);
102103
TimeWindow timeWindow = new TimeWindow(between);
103104
return agentsService.getAgentsByApplicationName(
@@ -118,7 +119,7 @@ public List<AgentStatusAndLink> getAgentsList(
118119
@RequestParam("to") @PositiveOrZero long to,
119120
@RequestParam(value = "query", required = false) String query) {
120121
final ApplicationAgentListQueryRule applicationAgentListQueryRule = ApplicationAgentListQueryRule.getByValue(query, ApplicationAgentListQueryRule.ACTIVE_STATUS);
121-
final Application application = createApplication(applicationName, serviceTypeCode, serviceTypeName);
122+
final Application application = createApplication(Service.DEFAULT, applicationName, serviceTypeCode, serviceTypeName);
122123
Range range = Range.between(from, to);
123124
rangeValidator.validate(range);
124125
TimeWindow timeWindow = new TimeWindow(range);
@@ -180,19 +181,19 @@ private List<Application> pairsToList(List<ApplicationPair> applicationPairs) {
180181
final List<Application> applications = new ArrayList<>(applicationPairs.size());
181182
for (ApplicationPair applicationPair : applicationPairs) {
182183
final String applicationName = applicationPair.getApplicationName();
183-
final short serviceTypeCode = applicationPair.getServiceTypeCode();
184-
final Application application = this.applicationFactory.createApplication(applicationName, serviceTypeCode);
184+
final int serviceTypeCode = applicationPair.getServiceTypeCode();
185+
final Application application = this.applicationFactory.createApplication(Service.DEFAULT, applicationName, serviceTypeCode);
185186
applications.add(application);
186187
}
187188
return applications;
188189
}
189190

190-
private Application createApplication(String applicationName, Short serviceTypeCode, String serviceTypeName) {
191+
private Application createApplication(Service service, String applicationName, Short serviceTypeCode, String serviceTypeName) {
191192
if (StringUtils.hasLength(applicationName)) {
192193
if (serviceTypeCode != null) {
193-
return applicationFactory.createApplication(applicationName, serviceTypeCode);
194+
return applicationFactory.createApplication(service, applicationName, serviceTypeCode);
194195
} else if (serviceTypeName != null) {
195-
return applicationFactory.createApplicationByTypeName(applicationName, serviceTypeName);
196+
return applicationFactory.createApplicationByTypeName(service, applicationName, serviceTypeName);
196197
}
197198
}
198199
// return application without service type

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/config/MapV3DaoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ public ResultExtractorFactory<List<ResponseTime>> agentResponseTimeResultExtract
144144

145145
@Bean
146146
public ResultExtractorFactory<ApplicationResponse> applicationResponseTimeResultExtractor(ServiceTypeRegistryService registry,
147+
ApplicationFactory applicationFactory,
147148
RowKeyDecoder<UidAppRowKey> rowKeyDecoder) {
148149
HbaseColumnFamily table = HbaseTables.MAP_APP_SELF;
149150
return (windowFunction, application) -> {
150151
Predicate<UidAppRowKey> rowFilter = new RowFilter<>(application);
151-
return new ApplicationResponseTimeV3ResultExtractor(table, registry, rowKeyDecoder, windowFunction, rowFilter);
152+
return new ApplicationResponseTimeV3ResultExtractor(table, applicationFactory, rowKeyDecoder, windowFunction, rowFilter);
152153
};
153154
}
154155

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapHistogramController.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.navercorp.pinpoint.web.vo.Application;
4242
import com.navercorp.pinpoint.web.vo.ApplicationPair;
4343
import com.navercorp.pinpoint.web.vo.ApplicationPairs;
44+
import com.navercorp.pinpoint.web.vo.Service;
4445
import jakarta.validation.Valid;
4546
import org.apache.logging.log4j.LogManager;
4647
import org.apache.logging.log4j.Logger;
@@ -198,8 +199,11 @@ public NodeHistogramSummaryView getResponseTimeHistogramDataV2(
198199
private List<Application> toApplications(List<String> applicationNames, List<Short> serviceTypeCodes) {
199200
final List<Application> result = new ArrayList<>(applicationNames.size());
200201
for (int i = 0; i < applicationNames.size(); i++) {
202+
String applicationName = applicationNames.get(i);
203+
int serviceTypeCode = serviceTypeCodes.get(i);
204+
201205
final Application application =
202-
this.applicationFactory.createApplication(applicationNames.get(i), serviceTypeCodes.get(i));
206+
this.applicationFactory.createApplication(Service.DEFAULT, applicationName, serviceTypeCode);
203207
result.add(application);
204208
}
205209
return result;
@@ -212,8 +216,8 @@ private List<Application> mapApplicationPairsToApplications(List<ApplicationPair
212216
final List<Application> applications = new ArrayList<>(applicationPairs.size());
213217
for (ApplicationPair applicationPair : applicationPairs) {
214218
final String applicationName = applicationPair.getApplicationName();
215-
final short serviceTypeCode = applicationPair.getServiceTypeCode();
216-
final Application application = this.applicationFactory.createApplication(applicationName, serviceTypeCode);
219+
final int serviceTypeCode = applicationPair.getServiceTypeCode();
220+
final Application application = this.applicationFactory.createApplication(Service.DEFAULT, applicationName, serviceTypeCode);
217221
applications.add(application);
218222
}
219223
return applications;
@@ -232,20 +236,20 @@ public LinkHistogramSummaryView getLinkTimeHistogramData(
232236
this.rangeValidator.validate(range);
233237
TimeWindow timeWindow = new TimeWindow(range);
234238

235-
final Application fromApplication = this.createApplication(fromApplicationName, fromServiceTypeCode);
236-
final Application toApplication = this.createApplication(toApplicationName, toServiceTypeCode);
239+
final Application fromApplication = this.createApplication(Service.DEFAULT, fromApplicationName, fromServiceTypeCode);
240+
final Application toApplication = this.createApplication(Service.DEFAULT,toApplicationName, toServiceTypeCode);
237241
final LinkHistogramSummary linkHistogramSummary =
238242
responseTimeHistogramService.selectLinkHistogramData(fromApplication, toApplication, timeWindow);
239243

240244
return new LinkHistogramSummaryView(linkHistogramSummary, timeWindow, TimeHistogramView.ResponseTime);
241245
}
242246

243247
@Nullable
244-
private Application createApplication(@Nullable String name, Short serviceTypeCode) {
248+
private Application createApplication(Service serviceUid, @Nullable String name, Short serviceTypeCode) {
245249
if (name == null) {
246250
return null;
247251
}
248-
return this.applicationFactory.createApplication(name, serviceTypeCode);
252+
return this.applicationFactory.createApplication(serviceUid, name, serviceTypeCode);
249253
}
250254

251255
private Application getApplication(ApplicationForm appForm) {

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/ServerMapHistogramController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.navercorp.pinpoint.web.util.ApplicationValidator;
4343
import com.navercorp.pinpoint.web.vo.Application;
4444
import com.navercorp.pinpoint.web.vo.SearchOption;
45+
import com.navercorp.pinpoint.web.vo.Service;
4546
import jakarta.validation.Valid;
4647
import jakarta.validation.constraints.NotBlank;
4748
import org.apache.logging.log4j.LogManager;
@@ -281,11 +282,11 @@ public NodeHistogramSummaryView getNodeHistogramData(
281282
@RequestParam(value = "fromApplicationNames", defaultValue = "", required = false)
282283
List<String> fromApplicationNames,
283284
@RequestParam(value = "fromServiceTypeCodes", defaultValue = "", required = false)
284-
List<Short> fromServiceTypeCodes,
285+
List<Integer> fromServiceTypeCodes,
285286
@RequestParam(value = "toApplicationNames", defaultValue = "", required = false)
286287
List<String> toApplicationNames,
287288
@RequestParam(value = "toServiceTypeCodes", defaultValue = "", required = false)
288-
List<Short> toServiceTypeCodes,
289+
List<Integer> toServiceTypeCodes,
289290
@RequestParam(value = "useStatisticsAgentState", defaultValue = "true", required = false)
290291
boolean useStatisticsAgentState
291292
) {
@@ -318,11 +319,11 @@ public NodeHistogramSummaryView getNodeHistogramData(
318319
return new NodeHistogramSummaryView(nodeHistogramSummary, timeWindow, serverGroupListView, TimeHistogramView.TimeseriesHistogram);
319320
}
320321

321-
private List<Application> toApplications(List<String> applicationNames, List<Short> serviceTypeCodes) {
322+
private List<Application> toApplications(List<String> applicationNames, List<Integer> serviceTypeCodes) {
322323
final List<Application> result = new ArrayList<>(applicationNames.size());
323324
for (int i = 0; i < applicationNames.size(); i++) {
324325
final Application application =
325-
this.applicationFactory.createApplication(applicationNames.get(i), serviceTypeCodes.get(i));
326+
this.applicationFactory.createApplication(Service.DEFAULT, applicationNames.get(i), serviceTypeCodes.get(i));
326327
result.add(application);
327328
}
328329
return result;

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/dao/mapper/InLinkMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.navercorp.pinpoint.common.server.applicationmap.statistics.LinkRowKey;
2424
import com.navercorp.pinpoint.common.server.applicationmap.statistics.v2.InLinkV2ColumnName;
2525
import com.navercorp.pinpoint.common.server.bo.serializer.RowKeyDecoder;
26+
import com.navercorp.pinpoint.common.server.uid.ServiceUid;
2627
import com.navercorp.pinpoint.common.server.util.UserNodeUtils;
2728
import com.navercorp.pinpoint.common.timeseries.window.TimeWindowFunction;
2829
import com.navercorp.pinpoint.common.trace.ServiceType;
@@ -137,7 +138,7 @@ private Application readSelfApplication(String selfApplicationName, short selfSe
137138
if (registry.findServiceType(selfServiceType).isUser()) {
138139
selfApplicationName = UserNodeUtils.newUserNodeName(selfApplicationName, inServiceType);
139140
}
140-
return this.applicationFactory.createApplication(selfApplicationName, selfServiceType);
141+
return this.applicationFactory.createApplication(ServiceUid.DEFAULT.getUid(), selfApplicationName, selfServiceType);
141142
}
142143

143144
private Application readInApplication(LinkRowKey row) {

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/dao/v3/ApplicationResponseTimeV3ResultExtractor.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
import com.navercorp.pinpoint.common.server.applicationmap.statistics.UidAppRowKey;
2323
import com.navercorp.pinpoint.common.server.bo.serializer.RowKeyDecoder;
2424
import com.navercorp.pinpoint.common.timeseries.window.TimeWindowFunction;
25-
import com.navercorp.pinpoint.common.trace.ServiceType;
2625
import com.navercorp.pinpoint.common.trace.SlotCode;
27-
import com.navercorp.pinpoint.loader.service.ServiceTypeRegistryService;
2826
import com.navercorp.pinpoint.web.applicationmap.dao.ApplicationResponse;
27+
import com.navercorp.pinpoint.web.component.ApplicationFactory;
2928
import com.navercorp.pinpoint.web.vo.Application;
3029
import org.apache.hadoop.hbase.Cell;
3130
import org.apache.hadoop.hbase.CellUtil;
@@ -48,21 +47,20 @@ public class ApplicationResponseTimeV3ResultExtractor implements ResultsExtracto
4847

4948
private final HbaseColumnFamily table;
5049

51-
private final ServiceTypeRegistryService registry;
50+
private final ApplicationFactory applicationFactory;
5251

5352
private final RowKeyDecoder<UidAppRowKey> rowKeyDecoder;
5453

5554
private final TimeWindowFunction timeWindowFunction;
5655
private final Predicate<UidAppRowKey> rowFilter;
5756

58-
5957
public ApplicationResponseTimeV3ResultExtractor(HbaseColumnFamily table,
60-
ServiceTypeRegistryService registry,
58+
ApplicationFactory applicationFactory,
6159
RowKeyDecoder<UidAppRowKey> rowKeyDecoder,
6260
TimeWindowFunction timeWindowFunction,
6361
Predicate<UidAppRowKey> rowFilter) {
6462
this.table = Objects.requireNonNull(table, "table");
65-
this.registry = Objects.requireNonNull(registry, "registry");
63+
this.applicationFactory = Objects.requireNonNull(applicationFactory, "applicationFactory");
6664

6765
this.rowKeyDecoder = Objects.requireNonNull(rowKeyDecoder, "rowKeyDecoder");
6866
this.timeWindowFunction = Objects.requireNonNull(timeWindowFunction, "timeWindowFunction");
@@ -94,8 +92,7 @@ private ApplicationResponse.Builder mapRow(ApplicationResponse.Builder builder,
9492
final long timestamp = timeWindowFunction.refineTimestamp(uidRowKey.getTimestamp());
9593

9694
if (builder == null) {
97-
ServiceType serviceType = registry.findServiceType(uidRowKey.getServiceType());
98-
Application application = new Application(uidRowKey.getApplicationName(), serviceType);
95+
Application application = applicationFactory.createApplication(uidRowKey.getServiceUid(), uidRowKey.getApplicationName(), uidRowKey.getServiceType());
9996
builder = ApplicationResponse.newBuilder(application);
10097
}
10198
recordColumn(builder, timestamp, cell);

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/dao/v3/HostApplicationMapperV3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ private AcceptApplication createAcceptedApplication(Cell cell) {
8585
String bindApplicationName = reader.readPrefixedString();
8686
int bindServiceTypeCode = reader.readInt();
8787
// skip
88-
// int serviceUid = reader.readInt();
88+
int serviceUid = reader.readInt();
8989

90-
final Application bindApplication = applicationFactory.createApplication(bindApplicationName, bindServiceTypeCode);
90+
final Application bindApplication = applicationFactory.createApplication(serviceUid, bindApplicationName, bindServiceTypeCode);
9191
return new AcceptApplication(host, bindApplication);
9292
}
9393
}

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/dao/v3/InLinkV3Mapper.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
9898
final long timestamp = timeWindowFunction.refineTimestamp(inRowKey.getTimestamp());
9999
final Application inApplication = readInApplication(inRowKey);
100100

101-
int selfServiceType = inRowKey.getLinkServiceType();
102-
String selfApplicationName = inRowKey.getLinkApplicationName();
103-
final Application self = readSelfApplication(selfApplicationName, selfServiceType, inApplication.getServiceType());
101+
final Application self = readSelfApplication(inRowKey, inApplication.getServiceType());
104102
if (filter.filter(self)) {
105103
continue;
106104
}
@@ -145,20 +143,25 @@ private SlotCode readSlotCode(Cell cell) {
145143
return SlotCode.valueOf(slotCodeByte);
146144
}
147145

148-
private Application readSelfApplication(String selfApplicationName, int selfServiceType, ServiceType inServiceType) {
146+
private Application readSelfApplication(UidLinkRowKey self, ServiceType inServiceType) {
147+
int serviceUid = self.getServiceUid();
148+
String selfApplicationName = self.getLinkApplicationName();
149+
int selfServiceType = self.getLinkServiceType();
150+
149151
// Caller may be a user node, and user nodes may call nodes with the same application name but different service type.
150152
// To distinguish between these user nodes, append callee's service type to the application name.
151153
if (registry.findServiceType(selfServiceType).isUser()) {
152154
selfApplicationName = UserNodeUtils.newUserNodeName(selfApplicationName, inServiceType);
153155
}
154-
return this.applicationFactory.createApplication(selfApplicationName, selfServiceType);
156+
return this.applicationFactory.createApplication(serviceUid, selfApplicationName, selfServiceType);
155157
}
156158

157159
private Application readInApplication(UidRowKey rowKey) {
160+
int serviceUid = rowKey.getServiceUid();
158161
String selfApplicationName = rowKey.getApplicationName();
159162
int selfServiceType = rowKey.getServiceType();
160163

161-
return this.applicationFactory.createApplication(selfApplicationName, selfServiceType);
164+
return this.applicationFactory.createApplication(serviceUid, selfApplicationName, selfServiceType);
162165
}
163166

164167
}

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/dao/v3/OutLinkV3Mapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,17 @@ private SlotCode readSlotCode(Cell cell) {
122122

123123

124124
private Application inApplication(UidLinkRowKey rowKey) {
125+
int serviceUid = rowKey.getServiceUid();
125126
String inApplicationName = rowKey.getLinkApplicationName();
126127
int inServiceType = rowKey.getLinkServiceType();
127-
return applicationFactory.createApplication(inApplicationName, inServiceType);
128+
return applicationFactory.createApplication(serviceUid, inApplicationName, inServiceType);
128129
}
129130

130131
private Application getApplication(UidRowKey rowKey) {
132+
int serviceUid = rowKey.getServiceUid();
131133
String applicationName = rowKey.getApplicationName();
132134
int outServiceType = rowKey.getServiceType();
133-
return this.applicationFactory.createApplication(applicationName, outServiceType);
135+
return this.applicationFactory.createApplication(serviceUid, applicationName, outServiceType);
134136
}
135137

136138
}

0 commit comments

Comments
 (0)