Hi,
I'm still working on collecting the CpuUsage for Load Balancer decision.
After a PR review, this week we prefer to use call back param to achieve
this. I've some questions:
https://github.com/apache/dubbo/pull/4195/files#diff-e2ec27b1471dff73dc73a9959d85c2c7
1) Is ok to create a listener inside MetricsFilter? I'll receive the CPU
usage from the provider.
2) How can I update a Gauge<Float> inside MetricManager? At
MetricRegistryImpl an exception "A metric named ... already exists" is
thrown if I try to call MetricManager.register with the same metricName.
CpuUsageService cpuUsageService = new CpuUsageServiceImpl(100L,
500L);
cpuUsageService.addListener("foo.bar", cpu -> {
SortedMap<MetricName, Gauge> gauges =
MetricManager.getIMetricManager().getGauges(DUBBO_GROUP, MetricFilter.ALL);
Gauge<Float> cpuUser = gauges.get(new
MetricName("dubbo.cpu." + invoker.getUrl().getHost(), MetricLevel.MAJOR));
if (cpuUser == null) {
MetricName metricName = new MetricName("dubbo.cpu." +
invoker.getUrl().getHost(), MetricLevel.MAJOR);
MetricManager.register(DUBBO_GROUP, metricName, cpu);
}
});
--
Daniela Morais
Computer Science student at the University Of Campinas
danielammorais.com <https://www.danielammorais.com>