-
Notifications
You must be signed in to change notification settings - Fork 51
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
Optimize application #9
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
============================================
- Coverage 41.64% 39.95% -1.69%
- Complexity 179 189 +10
============================================
Files 37 52 +15
Lines 1263 1907 +644
Branches 153 210 +57
============================================
+ Hits 526 762 +236
- Misses 676 1074 +398
- Partials 61 71 +10
Continue to review full report at Codecov.
|
# Conflicts: # sofa-dashboard-backend/sofa-dashboard-core/src/main/java/com/alipay/sofa/dashboard/constants/SofaDashboardConstants.java # sofa-dashboard-backend/sofa-dashboard-governance/src/main/java/com/alipay/sofa/dashboard/cache/RegistryDataCache.java # sofa-dashboard-backend/sofa-dashboard-web/src/main/java/com/alipay/sofa/dashboard/controller/ApplicationController.java
Master glmapper
# Conflicts: # sofa-dashboard-backend/sofa-dashboard-governance/src/main/java/com/alipay/sofa/dashboard/listener/sofa/SofaRegistryRestClient.java
|
||
@Override | ||
public List<MetricsInfo> fetchMetrics(Object source) { | ||
// do not support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不支持的话直接删除吧。
|
||
private RestTemplate restTemplate = new RestTemplate(); | ||
|
||
public static Map<String, FixedQueue<DetailThreadInfo>> cacheDetailThreads = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么写成 public static,是否有更面向对象的写法呢?
public static Map<String, FixedQueue<MemoryNonHeapInfo>> cacheNonHeapMemory = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public EnvironmentInfo fetchEnvironment(Object source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
传入的参数全部是 String,为什么把接口声明成 source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
传入的参数全部是 String,为什么把接口声明成 source?
引用数据源理论上是多样的,比如一个 rest 请求地址、文件、或者其他第三方服务。这里 source 类型使用 Object 对象用于描述数据来源,各个实现可以基于具体源定义具体类型,比如 ActuatorMonitorManager 实现 source 是请求地址,其 source 类型即为 String 类型;这样可以提供更加丰富的选择性。在对接其他 源时,source 可能会包括更多信息,比如是个 Map 或者 pojo 。
return sb.toString(); | ||
} | ||
|
||
public static String simpleDecode(String encodeAddress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个方法能不能加下注释呢,看不懂是什么意思。
*/ | ||
public static final String KEY = "g"; | ||
|
||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
常量要大写,但是 SimpleDateFormat 不建议作为常量,因为他不是线程安全的。
} | ||
} | ||
|
||
public static Map doRequest(Object source, String path, RestTemplate restTemplate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么是static,这个类实现了 MonitorManager 接口,不应该只暴露出 MonitorManager 的接口吗,这个接口为什么要放在这个类里面?
} | ||
|
||
public LinkedList<E> getQueue() { | ||
return queue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不要把queue对象暴露出去,暴露出去了外部 API 就可以随意添加了,应该新建一个 List 返回。
*/ | ||
void addConsumers(String serviceName, List<RpcConsumer> consumerList); | ||
void addConsumers(String serviceName, List<RpcConsumer> consumers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个修改是因为 master 没合过来的 diff 嚒?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个修改是因为 master 没合过来的 diff 嚒?
代码在Fix concurrency issues 这个 PR 中,还没有合入 master
private MonitorManager monitorManager; | ||
|
||
@RequestMapping("details") | ||
public Map baseDetails(@RequestParam("id") String targetHost) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果参数的意思是 targetHost,为什么不直接叫 targetHost,而是叫 id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果参数的意思是 targetHost,为什么不直接叫 targetHost,而是叫 id?
这个将 targetHost 改成 id,在 dashboard 中,前端返回的应用实例除“目标主机”概念之外,概念上应该更广义,所以 id 更适合
@@ -15,4 +15,4 @@ mybatis.config-location=classpath:spring/mybatis-configuration.xml | |||
# server port | |||
server.port=8099 | |||
|
|||
spring.profiles.active=localhost | |||
spring.profiles.active=alipay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不需要修改。
之前看的时候有几个建议:
|
是的,这部分已经抽出,重新定义了一个 RestTemplateClient 类负责用于与应用之间交互,ActuatorMonitorManager 将专注在数据解析与管理。 fetchInfo 这个在设计时没有使用 pojo 在于应用的 info 信息本身没有固定的属性,比如这样定义: info.app.name=spring-boot-hello
info.app.version=v1.0.0
info.test.a.b.c=abc
info.test.a.c.b=acb 在解析时会解析成普通的 k-v ,在模型上统一比较难,如果有什么好的建议,欢迎 PR |
请不要使用external library的方式引用 data-set 库,这样会导致离线用户无法使用应用界面。 比较简单的验证方法就是 npm install 之后在offline模式下执行 npm dev。清空浏览器缓存,进入应用detail界面,提示DataSet未定义。 因为该分支没有合并主线,所以如果方便的话请 cherry-pick 这一次提交进行修复 a30c6f https://github.com/chpengzh/sofa-dashboard/commits/optimize-application |
还有就是因为没有初始化eslint的配置,每次git提交的时候会报eslint的错误,只能通过 |
…veral invoke error
…veral invoke error
this pr will be closed and divide to multi sub pr |
增加应用面板信息展示. #10