Skip to content

Commit

Permalink
feat:代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
lemondark committed Oct 17, 2023
1 parent 731af1a commit b233f9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/tencent/msdk/dns/DnsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void run() {
* 设置UserId, 进行数据上报时区分用户, 出现问题时, 依赖该Id进行单用户问题排查
*
* @param userId 用户的唯一标识符, 腾讯业务建议直接使用OpenId, 腾讯云客户建议传入长度50位以内, 由字母数字下划线组合而成的字符串
* @return 是否设置成功, true为设置成功, false为设置失败
* @throws IllegalStateException 没有初始化时抛出
* @throws IllegalArgumentException userId为空时抛出
*/
Expand Down Expand Up @@ -171,8 +170,8 @@ public static synchronized void setCachedIpEnable(boolean mCachedIpEnable) {
/**
* 设置是否上报,是否启用域名服务(获取底层配置)
*
* @param mEnableReport
* @param mEnableDomainServer
* @param mEnableReport 启用日志上报
* @param mEnableDomainServer 启用域名服务
*/
public static void setDnsConfigFromServer(boolean mEnableReport, boolean mEnableDomainServer) {
if (!sInited) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/tencent/msdk/dns/report/ReportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public final class ReportHelper {
@Override
public void run() {
// atta上报统计数据
Map<String, Object[]> cacheStatisticsMap = CacheStatisticsReport.offerAll();
attaReportStatisticsEvent(cacheStatisticsMap);
attaReportStatisticsEvent();
DnsExecutors.MAIN.cancel(sReportAsyncLookupEventTask);
DnsExecutors.MAIN.schedule(
sReportAsyncLookupEventTask, REPORT_ASYNC_LOOKUP_EVENT_INTERVAL_MILLS);
Expand Down Expand Up @@ -223,8 +222,9 @@ private static void attaReportLookupEvent(String eventName, LookupResult lookupR
}


private static void attaReportStatisticsEvent(Map<String, Object[]> cacheStatisticsMap) {
if (!sDnsConfig.enableReport) {
private static void attaReportStatisticsEvent() {
Map<String, Object[]> cacheStatisticsMap = CacheStatisticsReport.offerAll();
if (!sDnsConfig.enableReport || cacheStatisticsMap.isEmpty()) {
return;
}
for (Map.Entry<String, Object[]> item : cacheStatisticsMap.entrySet()) {
Expand Down

0 comments on commit b233f9c

Please sign in to comment.