Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-11713][SDK] Optimize BaseMsgSenderFactory and TimeCostInfo implementation #11714

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public void testDataProxyCluster() {
Assertions.assertNotNull(id);

// save cluster node
String ip = "127.0.0.1";
String ip = "127.0.0.2";
Integer port1 = 46800;
Integer nodeId1 =
this.saveDataProxyClusterNode(id, ClusterType.DATAPROXY, ip, port1, ProtocolType.TCP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public BaseMsgSenderFactory(MsgSenderFactory msgSenderFactory, String factoryNo)
public void close() {
int totalSenderCnt;
int totalTDBankCnt;
logger.info("MsgSenderFactory({}) is closing", this.factoryNo);
senderCacheLock.writeLock().lock();
try {
// release groupId mapped senders
Expand Down Expand Up @@ -197,7 +198,7 @@ public InLongTcpMsgSender genTcpSenderByClusterId(
validProxyConfigNotNull(configure);
// get groupId's clusterIdKey
ProcessResult procResult = new ProcessResult();
ProxyConfigEntry proxyConfigEntry = qryProxyMetaConfigure(configure, procResult);;
ProxyConfigEntry proxyConfigEntry = qryProxyMetaConfigure(configure, procResult);
String clusterIdKey = ProxyUtils.buildClusterIdKey(
configure.getDataRptProtocol(), configure.getRegionName(), proxyConfigEntry.getClusterId());
// get local built sender
Expand Down Expand Up @@ -288,7 +289,7 @@ private ProxyConfigEntry qryProxyMetaConfigure(
&& !inlongMetaQryMgr.getEncryptConfigure(true, procResult)) {
throw new ProxySdkException("Failed to query remote encrypt config: " + procResult);
}
return inlongMetaQryMgr.getProxyConfigEntry();
return (ProxyConfigEntry) procResult.getRetData();
}

private boolean removeGroupIdSender(BaseSender msgSender, Map<String, BaseSender> senderMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ public void addTimeCostInMs(long timeInMs) {
}

public void getAndResetValue(StringBuilder strBuff) {
long curCnt = totalCnt.sumThenReset();
if (curCnt == 0) {
long curTotalCnt = totalCnt.sumThenReset();
if (curTotalCnt == 0) {
strBuff.append("\"").append(name)
.append("\":{\"bucketT\":{},\"min\":0,\"max\":0,\"avgT\":0,\"cnt\":0}");
} else {
curCnt = 0;
long bucketCnt = 0;
strBuff.append("\"").append(name).append("\":{\"bucketT\":{");
for (Map.Entry<String, LongAdder> entry : sendTimeBucketT.entrySet()) {
if (curCnt++ > 0) {
if (bucketCnt++ > 0) {
strBuff.append(",");
}
strBuff.append("\"").append(entry.getKey()).append("\":").append(entry.getValue());
}
strBuff.append("},\"min\":").append(this.minValue.getAndSet(Long.MAX_VALUE))
.append(",\"max\":").append(this.maxValue.getAndSet(Long.MIN_VALUE))
.append(",\"avgT\":").append(sumTime.sumThenReset() / curCnt).append("}");
.append(",\"avgT\":").append(sumTime.sumThenReset() / curTotalCnt).append("}");
sendTimeBucketT.clear();
}
}
Expand Down
Loading