minor refactoring due to comments
This commit is contained in:
parent
914d4b8ca3
commit
e65fc9d55e
@ -57,7 +57,7 @@ import static org.thingsboard.server.common.data.device.profile.MqttTopics.DEVIC
|
||||
import static org.thingsboard.server.common.data.device.profile.MqttTopics.GATEWAY_CONNECT_TOPIC;
|
||||
import static org.thingsboard.server.common.data.device.profile.MqttTopics.GATEWAY_METRICS_TOPIC;
|
||||
import static org.thingsboard.server.common.data.device.profile.MqttTopics.GATEWAY_TELEMETRY_TOPIC;
|
||||
import static org.thingsboard.server.transport.mqtt.gateway.GatewayMetricsService.METRICS_CHECK;
|
||||
import static org.thingsboard.server.transport.mqtt.gateway.GatewayMetricsService.GATEWAY_METRICS;
|
||||
|
||||
@Slf4j
|
||||
public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqttIntegrationTest {
|
||||
@ -148,13 +148,13 @@ public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqtt
|
||||
|
||||
gatewayMetricsService.reportMetrics();
|
||||
|
||||
List<String> actualKeys = getActualKeysList(savedGateway.getId(), List.of(METRICS_CHECK));
|
||||
assertEquals(METRICS_CHECK, actualKeys.get(0));
|
||||
List<String> actualKeys = getActualKeysList(savedGateway.getId(), List.of(GATEWAY_METRICS));
|
||||
assertEquals(GATEWAY_METRICS, actualKeys.get(0));
|
||||
|
||||
String telemetryUrl = String.format("/api/plugins/telemetry/DEVICE/%s/values/timeseries?startTs=%d&endTs=%d&keys=%s", savedGateway.getId(), 0, System.currentTimeMillis(), METRICS_CHECK);
|
||||
String telemetryUrl = String.format("/api/plugins/telemetry/DEVICE/%s/values/timeseries?startTs=%d&endTs=%d&keys=%s", savedGateway.getId(), 0, System.currentTimeMillis(), GATEWAY_METRICS);
|
||||
|
||||
Map<String, List<Map<String, Object>>> gatewayTelemetry = doGetAsyncTyped(telemetryUrl, new TypeReference<>() {});
|
||||
Map<String, Object> latencyCheckTelemetry = gatewayTelemetry.get(METRICS_CHECK).get(0);
|
||||
Map<String, Object> latencyCheckTelemetry = gatewayTelemetry.get(GATEWAY_METRICS).get(0);
|
||||
Map<String, GatewayMetricsState.ConnectorMetricsResult> latencyCheckValue = JacksonUtil.fromString((String) latencyCheckTelemetry.get("value"), new TypeReference<>() {});
|
||||
assertNotNull(latencyCheckValue);
|
||||
|
||||
|
||||
@ -424,7 +424,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
|
||||
gatewaySessionHandler.onDeviceDisconnect(mqttMsg);
|
||||
break;
|
||||
case MqttTopics.GATEWAY_METRICS_TOPIC:
|
||||
gatewaySessionHandler.onGatewayLatency(mqttMsg);
|
||||
gatewaySessionHandler.onGatewayMetrics(mqttMsg);
|
||||
break;
|
||||
default:
|
||||
ack(ctx, msgId, MqttReasonCodes.PubAck.TOPIC_NAME_INVALID);
|
||||
|
||||
@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@TbMqttTransportComponent
|
||||
public class GatewayMetricsService {
|
||||
|
||||
public static final String METRICS_CHECK = "metricsCheck";
|
||||
public static final String GATEWAY_METRICS = "gatewayMetrics";
|
||||
|
||||
@Value("${transport.mqtt.gateway_metrics_report_interval_sec:3600}")
|
||||
private int metricsReportIntervalSec;
|
||||
@ -100,7 +100,7 @@ public class GatewayMetricsService {
|
||||
}
|
||||
var result = state.getStateResult();
|
||||
var kvProto = TransportProtos.KeyValueProto.newBuilder()
|
||||
.setKey(METRICS_CHECK)
|
||||
.setKey(GATEWAY_METRICS)
|
||||
.setType(TransportProtos.KeyValueType.JSON_V)
|
||||
.setJsonV(JacksonUtil.toString(result))
|
||||
.build();
|
||||
|
||||
@ -84,7 +84,7 @@ public class GatewaySessionHandler extends AbstractGatewaySessionHandler<Gateway
|
||||
gatewayMetricsService.onDeviceDelete(deviceId);
|
||||
}
|
||||
|
||||
public void onGatewayLatency(MqttPublishMessage mqttMsg) throws AdaptorException {
|
||||
public void onGatewayMetrics(MqttPublishMessage mqttMsg) throws AdaptorException {
|
||||
int msgId = getMsgId(mqttMsg);
|
||||
ByteBuf payloadData = mqttMsg.payload();
|
||||
String payload = payloadData.toString(UTF8);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user