Skip to content

Commit

Permalink
Bugfix: the listener will re-register when device in E2E agent discon…
Browse files Browse the repository at this point in the history
…nected (#334)
  • Loading branch information
zhou9584 authored Mar 7, 2023
1 parent 4f3940a commit d85a1da
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import com.microsoft.hydralab.common.entity.common.TestRun;
import com.microsoft.hydralab.common.entity.common.TestTask;
import com.microsoft.hydralab.common.entity.common.TestTaskSpec;
import com.microsoft.hydralab.common.file.StorageServiceClientProxy;
import com.microsoft.hydralab.common.monitor.MetricPushGateway;
import com.microsoft.hydralab.common.util.Const;
import com.microsoft.hydralab.common.util.GlobalConstant;
import com.microsoft.hydralab.common.file.StorageServiceClientProxy;
import com.microsoft.hydralab.common.util.ThreadUtils;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags;
Expand Down Expand Up @@ -72,6 +72,7 @@ public class AgentWebSocketClientService implements TestTaskRunCallback {
private boolean isPrometheusEnabled;
@Autowired(required = false)
private MetricPushGateway pushGateway;
boolean isAgentInit = false;

public void onMessage(Message message) {
log.info("onMessage Receive bytes message {}", message);
Expand All @@ -91,8 +92,11 @@ public void onMessage(Message message) {
* [agentUser.setTeamName -> meterRegistry.config().commonTags -> deviceManager.init
* -> (deviceControlService.provideDeviceList + deviceStatbilityMonitor.addDeviceMetricRegistration)].
*/
registerAgentMetrics();
deviceControlService.deviceManagerInit();
if (!isAgentInit) {
registerAgentMetrics();
deviceControlService.deviceManagerInit();
isAgentInit = true;
}
deviceControlService.provideDeviceList(agentUser.getBatteryStrategy());
return;
case Const.Path.HEARTBEAT:
Expand Down

0 comments on commit d85a1da

Please sign in to comment.