Merge pull request #9461 from AndriiLandiak/feature/core-proto-subtype-implementation
Core msg proto implementation as replacement of raw byte encoding
This commit is contained in:
commit
c6be73d77b
@ -16,9 +16,9 @@
|
|||||||
package org.thingsboard.server.actors.device;
|
package org.thingsboard.server.actors.device;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceEdgeUpdateMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceEdgeUpdateMsg;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceNameOrTypeUpdateMsg;
|
||||||
import org.thingsboard.server.actors.ActorSystemContext;
|
import org.thingsboard.server.actors.ActorSystemContext;
|
||||||
import org.thingsboard.server.actors.TbActorCtx;
|
import org.thingsboard.server.actors.TbActorCtx;
|
||||||
import org.thingsboard.server.actors.TbActorException;
|
import org.thingsboard.server.actors.TbActorException;
|
||||||
@ -27,9 +27,9 @@ import org.thingsboard.server.common.data.id.DeviceId;
|
|||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.TbActorMsg;
|
import org.thingsboard.server.common.msg.TbActorMsg;
|
||||||
import org.thingsboard.server.common.msg.timeout.DeviceActorServerSideRpcTimeoutMsg;
|
import org.thingsboard.server.common.msg.timeout.DeviceActorServerSideRpcTimeoutMsg;
|
||||||
import org.thingsboard.server.service.rpc.FromDeviceRpcResponseActorMsg;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponseActorMsg;
|
||||||
import org.thingsboard.server.service.rpc.RemoveRpcActorMsg;
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg;
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
import org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper;
|
import org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|||||||
@ -25,10 +25,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.common.util.LinkedHashMapRemoveEldest;
|
import org.thingsboard.common.util.LinkedHashMapRemoveEldest;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceCredentialsUpdateNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceCredentialsUpdateNotificationMsg;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceEdgeUpdateMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceEdgeUpdateMsg;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceNameOrTypeUpdateMsg;
|
||||||
import org.thingsboard.server.actors.ActorSystemContext;
|
import org.thingsboard.server.actors.ActorSystemContext;
|
||||||
import org.thingsboard.server.actors.TbActorCtx;
|
import org.thingsboard.server.actors.TbActorCtx;
|
||||||
import org.thingsboard.server.actors.shared.AbstractContextAwareMsgProcessor;
|
import org.thingsboard.server.actors.shared.AbstractContextAwareMsgProcessor;
|
||||||
@ -87,10 +87,10 @@ import org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg;
|
|||||||
import org.thingsboard.server.gen.transport.TransportProtos.ToTransportUpdateCredentialsProto;
|
import org.thingsboard.server.gen.transport.TransportProtos.ToTransportUpdateCredentialsProto;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos.TransportToDeviceActorMsg;
|
import org.thingsboard.server.gen.transport.TransportProtos.TransportToDeviceActorMsg;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos.TsKvProto;
|
import org.thingsboard.server.gen.transport.TransportProtos.TsKvProto;
|
||||||
import org.thingsboard.server.service.rpc.FromDeviceRpcResponseActorMsg;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponseActorMsg;
|
||||||
import org.thingsboard.server.service.rpc.RemoveRpcActorMsg;
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
import org.thingsboard.server.service.rpc.RpcSubmitStrategy;
|
import org.thingsboard.server.service.rpc.RpcSubmitStrategy;
|
||||||
import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg;
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
import org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper;
|
import org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
package org.thingsboard.server.actors.device;
|
package org.thingsboard.server.actors.device;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg;
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrew Shvayka
|
* @author Andrew Shvayka
|
||||||
|
|||||||
@ -47,7 +47,7 @@ import org.thingsboard.server.common.msg.TbMsg;
|
|||||||
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
||||||
import org.thingsboard.server.exception.ToErrorResponseEntity;
|
import org.thingsboard.server.exception.ToErrorResponseEntity;
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.rpc.RemoveRpcActorMsg;
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
import org.thingsboard.server.service.security.permission.Operation;
|
import org.thingsboard.server.service.security.permission.Operation;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|||||||
@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.StringUtils;
|
import org.thingsboard.server.common.data.StringUtils;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
|
|||||||
import org.thingsboard.server.queue.TbQueueCallback;
|
import org.thingsboard.server.queue.TbQueueCallback;
|
||||||
import org.thingsboard.server.queue.TbQueueMsgMetadata;
|
import org.thingsboard.server.queue.TbQueueMsgMetadata;
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.rpc.FromDeviceRpcResponseActorMsg;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponseActorMsg;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
import org.thingsboard.server.common.data.DeviceProfile;
|
import org.thingsboard.server.common.data.DeviceProfile;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceCredentialsUpdateNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceCredentialsUpdateNotificationMsg;
|
||||||
import org.thingsboard.server.cluster.TbClusterService;
|
import org.thingsboard.server.cluster.TbClusterService;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
import org.thingsboard.server.common.data.HasName;
|
import org.thingsboard.server.common.data.HasName;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.rule.engine.api.RuleEngineTelemetryService;
|
import org.thingsboard.rule.engine.api.RuleEngineTelemetryService;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.server.cluster.TbClusterService;
|
import org.thingsboard.server.cluster.TbClusterService;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
|
|||||||
@ -23,8 +23,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceEdgeUpdateMsg;
|
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg;
|
|
||||||
import org.thingsboard.server.cluster.TbClusterService;
|
import org.thingsboard.server.cluster.TbClusterService;
|
||||||
import org.thingsboard.server.common.data.ApiUsageState;
|
import org.thingsboard.server.common.data.ApiUsageState;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
@ -57,6 +55,8 @@ import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
|
|||||||
import org.thingsboard.server.common.msg.queue.ServiceType;
|
import org.thingsboard.server.common.msg.queue.ServiceType;
|
||||||
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
||||||
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceEdgeUpdateMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceNameOrTypeUpdateMsg;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos.FromDeviceRPCResponseProto;
|
import org.thingsboard.server.gen.transport.TransportProtos.FromDeviceRPCResponseProto;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos.ToCoreMsg;
|
import org.thingsboard.server.gen.transport.TransportProtos.ToCoreMsg;
|
||||||
@ -81,6 +81,8 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.thingsboard.server.service.queue.ProtoUtils.toProto;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -132,8 +134,7 @@ public class DefaultTbClusterService implements TbClusterService {
|
|||||||
public void pushMsgToCore(ToDeviceActorNotificationMsg msg, TbQueueCallback callback) {
|
public void pushMsgToCore(ToDeviceActorNotificationMsg msg, TbQueueCallback callback) {
|
||||||
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, msg.getTenantId(), msg.getDeviceId());
|
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, msg.getTenantId(), msg.getDeviceId());
|
||||||
log.trace("PUSHING msg: {} to:{}", msg, tpi);
|
log.trace("PUSHING msg: {} to:{}", msg, tpi);
|
||||||
byte[] msgBytes = encodingService.encode(msg);
|
ToCoreMsg toCoreMsg = ToCoreMsg.newBuilder().setToDeviceActorNotification(toProto(msg)).build();
|
||||||
ToCoreMsg toCoreMsg = ToCoreMsg.newBuilder().setToDeviceActorNotificationMsg(ByteString.copyFrom(msgBytes)).build();
|
|
||||||
producerProvider.getTbCoreMsgProducer().send(tpi, new TbProtoQueueMsg<>(msg.getDeviceId().getId(), toCoreMsg), callback);
|
producerProvider.getTbCoreMsgProducer().send(tpi, new TbProtoQueueMsg<>(msg.getDeviceId().getId(), toCoreMsg), callback);
|
||||||
toCoreMsgs.incrementAndGet();
|
toCoreMsgs.incrementAndGet();
|
||||||
}
|
}
|
||||||
@ -363,24 +364,21 @@ public class DefaultTbClusterService implements TbClusterService {
|
|||||||
public void onEdgeEventUpdate(TenantId tenantId, EdgeId edgeId) {
|
public void onEdgeEventUpdate(TenantId tenantId, EdgeId edgeId) {
|
||||||
log.trace("[{}] Processing edge {} event update ", tenantId, edgeId);
|
log.trace("[{}] Processing edge {} event update ", tenantId, edgeId);
|
||||||
EdgeEventUpdateMsg msg = new EdgeEventUpdateMsg(tenantId, edgeId);
|
EdgeEventUpdateMsg msg = new EdgeEventUpdateMsg(tenantId, edgeId);
|
||||||
byte[] msgBytes = encodingService.encode(msg);
|
ToCoreNotificationMsg toCoreMsg = ToCoreNotificationMsg.newBuilder().setEdgeEventUpdate(toProto(msg)).build();
|
||||||
ToCoreNotificationMsg toCoreMsg = ToCoreNotificationMsg.newBuilder().setEdgeEventUpdateMsg(ByteString.copyFrom(msgBytes)).build();
|
|
||||||
pushEdgeSyncMsgToCore(edgeId, toCoreMsg);
|
pushEdgeSyncMsgToCore(edgeId, toCoreMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pushEdgeSyncRequestToCore(ToEdgeSyncRequest toEdgeSyncRequest) {
|
public void pushEdgeSyncRequestToCore(ToEdgeSyncRequest toEdgeSyncRequest) {
|
||||||
log.trace("[{}] Processing edge sync request {} ", toEdgeSyncRequest.getTenantId(), toEdgeSyncRequest);
|
log.trace("[{}] Processing edge sync request {} ", toEdgeSyncRequest.getTenantId(), toEdgeSyncRequest);
|
||||||
byte[] msgBytes = encodingService.encode(toEdgeSyncRequest);
|
ToCoreNotificationMsg toCoreMsg = ToCoreNotificationMsg.newBuilder().setToEdgeSyncRequest(toProto(toEdgeSyncRequest)).build();
|
||||||
ToCoreNotificationMsg toCoreMsg = ToCoreNotificationMsg.newBuilder().setToEdgeSyncRequestMsg(ByteString.copyFrom(msgBytes)).build();
|
|
||||||
pushEdgeSyncMsgToCore(toEdgeSyncRequest.getEdgeId(), toCoreMsg);
|
pushEdgeSyncMsgToCore(toEdgeSyncRequest.getEdgeId(), toCoreMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pushEdgeSyncResponseToCore(FromEdgeSyncResponse fromEdgeSyncResponse) {
|
public void pushEdgeSyncResponseToCore(FromEdgeSyncResponse fromEdgeSyncResponse) {
|
||||||
log.trace("[{}] Processing edge sync response {}", fromEdgeSyncResponse.getTenantId(), fromEdgeSyncResponse);
|
log.trace("[{}] Processing edge sync response {}", fromEdgeSyncResponse.getTenantId(), fromEdgeSyncResponse);
|
||||||
byte[] msgBytes = encodingService.encode(fromEdgeSyncResponse);
|
ToCoreNotificationMsg toCoreMsg = ToCoreNotificationMsg.newBuilder().setFromEdgeSyncResponse(toProto(fromEdgeSyncResponse)).build();
|
||||||
ToCoreNotificationMsg toCoreMsg = ToCoreNotificationMsg.newBuilder().setFromEdgeSyncResponseMsg(ByteString.copyFrom(msgBytes)).build();
|
|
||||||
pushEdgeSyncMsgToCore(fromEdgeSyncResponse.getEdgeId(), toCoreMsg);
|
pushEdgeSyncMsgToCore(fromEdgeSyncResponse.getEdgeId(), toCoreMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +393,7 @@ public class DefaultTbClusterService implements TbClusterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void broadcast(ComponentLifecycleMsg msg) {
|
private void broadcast(ComponentLifecycleMsg msg) {
|
||||||
TransportProtos.ComponentLifecycleMsgProto componentLifecycleMsgProto = ProtoUtils.toProto(msg);
|
TransportProtos.ComponentLifecycleMsgProto componentLifecycleMsgProto = toProto(msg);
|
||||||
TbQueueProducer<TbProtoQueueMsg<ToRuleEngineNotificationMsg>> toRuleEngineProducer = producerProvider.getRuleEngineNotificationsMsgProducer();
|
TbQueueProducer<TbProtoQueueMsg<ToRuleEngineNotificationMsg>> toRuleEngineProducer = producerProvider.getRuleEngineNotificationsMsgProducer();
|
||||||
Set<String> tbRuleEngineServices = partitionService.getAllServiceIds(ServiceType.TB_RULE_ENGINE);
|
Set<String> tbRuleEngineServices = partitionService.getAllServiceIds(ServiceType.TB_RULE_ENGINE);
|
||||||
EntityType entityType = msg.getEntityId().getEntityType();
|
EntityType entityType = msg.getEntityId().getEntityType();
|
||||||
|
|||||||
@ -83,7 +83,7 @@ import org.thingsboard.server.service.profile.TbDeviceProfileCache;
|
|||||||
import org.thingsboard.server.service.queue.processing.AbstractConsumerService;
|
import org.thingsboard.server.service.queue.processing.AbstractConsumerService;
|
||||||
import org.thingsboard.server.service.queue.processing.IdMsgPair;
|
import org.thingsboard.server.service.queue.processing.IdMsgPair;
|
||||||
import org.thingsboard.server.service.rpc.TbCoreDeviceRpcService;
|
import org.thingsboard.server.service.rpc.TbCoreDeviceRpcService;
|
||||||
import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg;
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
import org.thingsboard.server.service.security.auth.jwt.settings.JwtSettingsService;
|
import org.thingsboard.server.service.security.auth.jwt.settings.JwtSettingsService;
|
||||||
import org.thingsboard.server.service.state.DeviceStateService;
|
import org.thingsboard.server.service.state.DeviceStateService;
|
||||||
import org.thingsboard.server.service.subscription.SubscriptionManagerService;
|
import org.thingsboard.server.service.subscription.SubscriptionManagerService;
|
||||||
@ -268,7 +268,19 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
|
|||||||
} else if (toCoreMsg.hasDeviceActivityMsg()) {
|
} else if (toCoreMsg.hasDeviceActivityMsg()) {
|
||||||
log.trace("[{}] Forwarding message to device state service {}", id, toCoreMsg.getDeviceActivityMsg());
|
log.trace("[{}] Forwarding message to device state service {}", id, toCoreMsg.getDeviceActivityMsg());
|
||||||
forwardToStateService(toCoreMsg.getDeviceActivityMsg(), callback);
|
forwardToStateService(toCoreMsg.getDeviceActivityMsg(), callback);
|
||||||
|
} else if (toCoreMsg.hasToDeviceActorNotification()) {
|
||||||
|
TbActorMsg actorMsg = ProtoUtils.fromProto(toCoreMsg.getToDeviceActorNotification());
|
||||||
|
if (actorMsg != null) {
|
||||||
|
if (actorMsg.getMsgType().equals(MsgType.DEVICE_RPC_REQUEST_TO_DEVICE_ACTOR_MSG)) {
|
||||||
|
tbCoreDeviceRpcService.forwardRpcRequestToDeviceActor((ToDeviceRpcRequestActorMsg) actorMsg);
|
||||||
|
} else {
|
||||||
|
log.trace("[{}] Forwarding message to App Actor {}", id, actorMsg);
|
||||||
|
actorContext.tell(actorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback.onSuccess();
|
||||||
} else if (!toCoreMsg.getToDeviceActorNotificationMsg().isEmpty()) {
|
} else if (!toCoreMsg.getToDeviceActorNotificationMsg().isEmpty()) {
|
||||||
|
// will be removed in 3.6.1 in favour of hasToDeviceActorNotification()
|
||||||
Optional<TbActorMsg> actorMsg = encodingService.decode(toCoreMsg.getToDeviceActorNotificationMsg().toByteArray());
|
Optional<TbActorMsg> actorMsg = encodingService.decode(toCoreMsg.getToDeviceActorNotificationMsg().toByteArray());
|
||||||
if (actorMsg.isPresent()) {
|
if (actorMsg.isPresent()) {
|
||||||
TbActorMsg tbActorMsg = actorMsg.get();
|
TbActorMsg tbActorMsg = actorMsg.get();
|
||||||
@ -357,11 +369,23 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
|
|||||||
//will be removed in 3.6.1 in favour of hasComponentLifecycle()
|
//will be removed in 3.6.1 in favour of hasComponentLifecycle()
|
||||||
handleComponentLifecycleMsg(id, toCoreNotification.getComponentLifecycleMsg());
|
handleComponentLifecycleMsg(id, toCoreNotification.getComponentLifecycleMsg());
|
||||||
callback.onSuccess();
|
callback.onSuccess();
|
||||||
|
} else if (toCoreNotification.hasEdgeEventUpdate()) {
|
||||||
|
forwardToAppActor(id, ProtoUtils.fromProto(toCoreNotification.getEdgeEventUpdate()));
|
||||||
|
callback.onSuccess();
|
||||||
} else if (!toCoreNotification.getEdgeEventUpdateMsg().isEmpty()) {
|
} else if (!toCoreNotification.getEdgeEventUpdateMsg().isEmpty()) {
|
||||||
|
//will be removed in 3.6.1 in favour of hasEdgeEventUpdate()
|
||||||
forwardToAppActor(id, encodingService.decode(toCoreNotification.getEdgeEventUpdateMsg().toByteArray()), callback);
|
forwardToAppActor(id, encodingService.decode(toCoreNotification.getEdgeEventUpdateMsg().toByteArray()), callback);
|
||||||
|
} else if (toCoreNotification.hasToEdgeSyncRequest()) {
|
||||||
|
forwardToAppActor(id, ProtoUtils.fromProto(toCoreNotification.getToEdgeSyncRequest()));
|
||||||
|
callback.onSuccess();
|
||||||
} else if (!toCoreNotification.getToEdgeSyncRequestMsg().isEmpty()) {
|
} else if (!toCoreNotification.getToEdgeSyncRequestMsg().isEmpty()) {
|
||||||
|
//will be removed in 3.6.1 in favour of hasToEdgeSyncRequest()
|
||||||
forwardToAppActor(id, encodingService.decode(toCoreNotification.getToEdgeSyncRequestMsg().toByteArray()), callback);
|
forwardToAppActor(id, encodingService.decode(toCoreNotification.getToEdgeSyncRequestMsg().toByteArray()), callback);
|
||||||
|
} else if (toCoreNotification.hasFromEdgeSyncResponse()) {
|
||||||
|
forwardToAppActor(id, ProtoUtils.fromProto(toCoreNotification.getFromEdgeSyncResponse()));
|
||||||
|
callback.onSuccess();
|
||||||
} else if (!toCoreNotification.getFromEdgeSyncResponseMsg().isEmpty()) {
|
} else if (!toCoreNotification.getFromEdgeSyncResponseMsg().isEmpty()) {
|
||||||
|
//will be removed in 3.6.1 in favour of hasFromEdgeSyncResponse()
|
||||||
forwardToAppActor(id, encodingService.decode(toCoreNotification.getFromEdgeSyncResponseMsg().toByteArray()), callback);
|
forwardToAppActor(id, encodingService.decode(toCoreNotification.getFromEdgeSyncResponseMsg().toByteArray()), callback);
|
||||||
} else if (toCoreNotification.hasQueueUpdateMsg()) {
|
} else if (toCoreNotification.hasQueueUpdateMsg()) {
|
||||||
TransportProtos.QueueUpdateMsg queue = toCoreNotification.getQueueUpdateMsg();
|
TransportProtos.QueueUpdateMsg queue = toCoreNotification.getQueueUpdateMsg();
|
||||||
@ -641,12 +665,16 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
|
|||||||
|
|
||||||
private void forwardToAppActor(UUID id, Optional<TbActorMsg> actorMsg, TbCallback callback) {
|
private void forwardToAppActor(UUID id, Optional<TbActorMsg> actorMsg, TbCallback callback) {
|
||||||
if (actorMsg.isPresent()) {
|
if (actorMsg.isPresent()) {
|
||||||
log.trace("[{}] Forwarding message to App Actor {}", id, actorMsg.get());
|
forwardToAppActor(id, actorMsg.get());
|
||||||
actorContext.tell(actorMsg.get());
|
|
||||||
}
|
}
|
||||||
callback.onSuccess();
|
callback.onSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void forwardToAppActor(UUID id, TbActorMsg actorMsg) {
|
||||||
|
log.trace("[{}] Forwarding message to App Actor {}", id, actorMsg);
|
||||||
|
actorContext.tell(actorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
private void forwardToEventService(ErrorEventProto eventProto, TbCallback callback) {
|
private void forwardToEventService(ErrorEventProto eventProto, TbCallback callback) {
|
||||||
Event event = ErrorEvent.builder()
|
Event event = ErrorEvent.builder()
|
||||||
.tenantId(toTenantId(eventProto.getTenantIdMSB(), eventProto.getTenantIdLSB()))
|
.tenantId(toTenantId(eventProto.getTenantIdMSB(), eventProto.getTenantIdLSB()))
|
||||||
|
|||||||
@ -16,14 +16,46 @@
|
|||||||
package org.thingsboard.server.service.queue;
|
package org.thingsboard.server.service.queue;
|
||||||
|
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.EntityIdFactory;
|
import org.thingsboard.server.common.data.id.EntityIdFactory;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
import org.thingsboard.server.common.data.kv.AttributeKey;
|
||||||
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.BooleanDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.DoubleDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.JsonDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.KvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.LongDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.StringDataEntry;
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
|
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
|
||||||
|
import org.thingsboard.server.common.data.rpc.RpcError;
|
||||||
|
import org.thingsboard.server.common.data.rpc.ToDeviceRpcRequestBody;
|
||||||
|
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||||
|
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
||||||
|
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
||||||
|
import org.thingsboard.server.common.msg.edge.EdgeEventUpdateMsg;
|
||||||
|
import org.thingsboard.server.common.msg.edge.FromEdgeSyncResponse;
|
||||||
|
import org.thingsboard.server.common.msg.edge.ToEdgeSyncRequest;
|
||||||
import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
|
import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponseActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceCredentialsUpdateNotificationMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceEdgeUpdateMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceNameOrTypeUpdateMsg;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ProtoUtils {
|
public class ProtoUtils {
|
||||||
|
|
||||||
@ -62,4 +94,377 @@ public class ProtoUtils {
|
|||||||
return entityTypeByProtoNumber[entityType.getNumber()];
|
return entityTypeByProtoNumber[entityType.getNumber()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static TransportProtos.ToEdgeSyncRequestMsgProto toProto(ToEdgeSyncRequest request) {
|
||||||
|
return TransportProtos.ToEdgeSyncRequestMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(request.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(request.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setRequestIdMSB(request.getId().getMostSignificantBits())
|
||||||
|
.setRequestIdLSB(request.getId().getLeastSignificantBits())
|
||||||
|
.setEdgeIdMSB(request.getEdgeId().getId().getMostSignificantBits())
|
||||||
|
.setEdgeIdLSB(request.getEdgeId().getId().getLeastSignificantBits())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToEdgeSyncRequest fromProto(TransportProtos.ToEdgeSyncRequestMsgProto proto) {
|
||||||
|
return new ToEdgeSyncRequest(
|
||||||
|
new UUID(proto.getRequestIdMSB(), proto.getRequestIdLSB()),
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new EdgeId(new UUID(proto.getEdgeIdMSB(), proto.getEdgeIdLSB()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TransportProtos.FromEdgeSyncResponseMsgProto toProto(FromEdgeSyncResponse response) {
|
||||||
|
return TransportProtos.FromEdgeSyncResponseMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(response.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(response.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setResponseIdMSB(response.getId().getMostSignificantBits())
|
||||||
|
.setResponseIdLSB(response.getId().getLeastSignificantBits())
|
||||||
|
.setEdgeIdMSB(response.getEdgeId().getId().getMostSignificantBits())
|
||||||
|
.setEdgeIdLSB(response.getEdgeId().getId().getLeastSignificantBits())
|
||||||
|
.setSuccess(response.isSuccess())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FromEdgeSyncResponse fromProto(TransportProtos.FromEdgeSyncResponseMsgProto proto) {
|
||||||
|
return new FromEdgeSyncResponse(
|
||||||
|
new UUID(proto.getResponseIdMSB(), proto.getResponseIdLSB()),
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new EdgeId(new UUID(proto.getEdgeIdMSB(), proto.getEdgeIdLSB())),
|
||||||
|
proto.getSuccess()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TransportProtos.EdgeEventUpdateMsgProto toProto(EdgeEventUpdateMsg msg) {
|
||||||
|
return TransportProtos.EdgeEventUpdateMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setEdgeIdMSB(msg.getEdgeId().getId().getMostSignificantBits())
|
||||||
|
.setEdgeIdLSB(msg.getEdgeId().getId().getLeastSignificantBits())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EdgeEventUpdateMsg fromProto(TransportProtos.EdgeEventUpdateMsgProto proto) {
|
||||||
|
return new EdgeEventUpdateMsg(
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new EdgeId(new UUID(proto.getEdgeIdMSB(), proto.getEdgeIdLSB()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.DeviceEdgeUpdateMsgProto toProto(DeviceEdgeUpdateMsg msg) {
|
||||||
|
return TransportProtos.DeviceEdgeUpdateMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setEdgeIdMSB(msg.getEdgeId().getId().getMostSignificantBits())
|
||||||
|
.setEdgeIdLSB(msg.getEdgeId().getId().getLeastSignificantBits())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DeviceEdgeUpdateMsg fromProto(TransportProtos.DeviceEdgeUpdateMsgProto proto) {
|
||||||
|
return new DeviceEdgeUpdateMsg(
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
new EdgeId(new UUID(proto.getEdgeIdMSB(), proto.getEdgeIdLSB()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.DeviceNameOrTypeUpdateMsgProto toProto(DeviceNameOrTypeUpdateMsg msg) {
|
||||||
|
return TransportProtos.DeviceNameOrTypeUpdateMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceName(msg.getDeviceName())
|
||||||
|
.setDeviceType(msg.getDeviceType())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DeviceNameOrTypeUpdateMsg fromProto(TransportProtos.DeviceNameOrTypeUpdateMsgProto proto) {
|
||||||
|
return new DeviceNameOrTypeUpdateMsg(
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
proto.getDeviceName(),
|
||||||
|
proto.getDeviceType()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.DeviceAttributesEventMsgProto toProto(DeviceAttributesEventNotificationMsg msg) {
|
||||||
|
TransportProtos.DeviceAttributesEventMsgProto.Builder builder = TransportProtos.DeviceAttributesEventMsgProto.newBuilder();
|
||||||
|
builder.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setDeleted(msg.isDeleted());
|
||||||
|
|
||||||
|
if (msg.getScope() != null) {
|
||||||
|
builder.setScope(TransportProtos.AttributeScopeProto.valueOf(msg.getScope()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.getDeletedKeys() != null) {
|
||||||
|
for (AttributeKey key : msg.getDeletedKeys()) {
|
||||||
|
builder.addDeletedKeys(TransportProtos.AttributeKey.newBuilder()
|
||||||
|
.setScope(TransportProtos.AttributeScopeProto.valueOf(key.getScope()))
|
||||||
|
.setAttributeKey(key.getAttributeKey())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.getValues() != null) {
|
||||||
|
for (AttributeKvEntry attributeKvEntry : msg.getValues()) {
|
||||||
|
TransportProtos.AttributeValueProto.Builder attributeValueBuilder = TransportProtos.AttributeValueProto.newBuilder()
|
||||||
|
.setLastUpdateTs(attributeKvEntry.getLastUpdateTs())
|
||||||
|
.setKey(attributeKvEntry.getKey());
|
||||||
|
switch (attributeKvEntry.getDataType()) {
|
||||||
|
case BOOLEAN:
|
||||||
|
attributeKvEntry.getBooleanValue().ifPresent(attributeValueBuilder::setBoolV);
|
||||||
|
attributeValueBuilder.setHasV(attributeKvEntry.getBooleanValue().isPresent());
|
||||||
|
attributeValueBuilder.setType(TransportProtos.KeyValueType.BOOLEAN_V);
|
||||||
|
break;
|
||||||
|
case STRING:
|
||||||
|
attributeKvEntry.getStrValue().ifPresent(attributeValueBuilder::setStringV);
|
||||||
|
attributeValueBuilder.setHasV(attributeKvEntry.getStrValue().isPresent());
|
||||||
|
attributeValueBuilder.setType(TransportProtos.KeyValueType.STRING_V);
|
||||||
|
break;
|
||||||
|
case DOUBLE:
|
||||||
|
attributeKvEntry.getDoubleValue().ifPresent(attributeValueBuilder::setDoubleV);
|
||||||
|
attributeValueBuilder.setHasV(attributeKvEntry.getDoubleValue().isPresent());
|
||||||
|
attributeValueBuilder.setType(TransportProtos.KeyValueType.DOUBLE_V);
|
||||||
|
break;
|
||||||
|
case LONG:
|
||||||
|
attributeKvEntry.getLongValue().ifPresent(attributeValueBuilder::setLongV);
|
||||||
|
attributeValueBuilder.setHasV(attributeKvEntry.getLongValue().isPresent());
|
||||||
|
attributeValueBuilder.setType(TransportProtos.KeyValueType.LONG_V);
|
||||||
|
break;
|
||||||
|
case JSON:
|
||||||
|
attributeKvEntry.getJsonValue().ifPresent(attributeValueBuilder::setJsonV);
|
||||||
|
attributeValueBuilder.setHasV(attributeKvEntry.getJsonValue().isPresent());
|
||||||
|
attributeValueBuilder.setType(TransportProtos.KeyValueType.JSON_V);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
builder.addValues(attributeValueBuilder.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ToDeviceActorNotificationMsg fromProto(TransportProtos.DeviceAttributesEventMsgProto proto) {
|
||||||
|
return new DeviceAttributesEventNotificationMsg(
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
getAttributeKeySetFromProto(proto.getDeletedKeysList()),
|
||||||
|
proto.hasScope() ? proto.getScope().name() : null,
|
||||||
|
getAttributesKvEntryFromProto(proto.getValuesList()),
|
||||||
|
proto.getDeleted()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.DeviceCredentialsUpdateMsgProto toProto(DeviceCredentialsUpdateNotificationMsg msg) {
|
||||||
|
TransportProtos.DeviceCredentialsProto.Builder protoBuilder = TransportProtos.DeviceCredentialsProto.newBuilder()
|
||||||
|
.setDeviceIdMSB(msg.getDeviceCredentials().getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceCredentials().getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setCredentialsId(msg.getDeviceCredentials().getCredentialsId())
|
||||||
|
.setCredentialsType(TransportProtos.CredentialsType.valueOf(msg.getDeviceCredentials().getCredentialsType().name()));
|
||||||
|
|
||||||
|
if (msg.getDeviceCredentials().getCredentialsValue() != null) {
|
||||||
|
protoBuilder.setCredentialsValue(msg.getDeviceCredentials().getCredentialsValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return TransportProtos.DeviceCredentialsUpdateMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceCredentials(protoBuilder.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ToDeviceActorNotificationMsg fromProto(TransportProtos.DeviceCredentialsUpdateMsgProto proto) {
|
||||||
|
DeviceCredentials deviceCredentials = new DeviceCredentials();
|
||||||
|
deviceCredentials.setDeviceId(new DeviceId(new UUID(proto.getDeviceCredentials().getDeviceIdMSB(), proto.getDeviceCredentials().getDeviceIdLSB())));
|
||||||
|
deviceCredentials.setCredentialsId(proto.getDeviceCredentials().getCredentialsId());
|
||||||
|
deviceCredentials.setCredentialsValue(proto.getDeviceCredentials().hasCredentialsValue() ? proto.getDeviceCredentials().getCredentialsValue() : null);
|
||||||
|
deviceCredentials.setCredentialsType(DeviceCredentialsType.valueOf(proto.getDeviceCredentials().getCredentialsType().name()));
|
||||||
|
return new DeviceCredentialsUpdateNotificationMsg(
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
deviceCredentials
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.ToDeviceRpcRequestActorMsgProto toProto(ToDeviceRpcRequestActorMsg msg) {
|
||||||
|
TransportProtos.ToDeviceRpcRequestMsg proto = TransportProtos.ToDeviceRpcRequestMsg.newBuilder()
|
||||||
|
.setMethodName(msg.getMsg().getBody().getMethod())
|
||||||
|
.setParams(msg.getMsg().getBody().getParams())
|
||||||
|
.setExpirationTime(msg.getMsg().getExpirationTime())
|
||||||
|
.setRequestIdMSB(msg.getMsg().getId().getMostSignificantBits())
|
||||||
|
.setRequestIdLSB(msg.getMsg().getId().getLeastSignificantBits())
|
||||||
|
.setOneway(msg.getMsg().isOneway())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return TransportProtos.ToDeviceRpcRequestActorMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setServiceId(msg.getServiceId())
|
||||||
|
.setToDeviceRpcRequestMsg(proto)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ToDeviceActorNotificationMsg fromProto(TransportProtos.ToDeviceRpcRequestActorMsgProto proto) {
|
||||||
|
TransportProtos.ToDeviceRpcRequestMsg toDeviceRpcRequestMsg = proto.getToDeviceRpcRequestMsg();
|
||||||
|
ToDeviceRpcRequest toDeviceRpcRequest = new ToDeviceRpcRequest(
|
||||||
|
new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB()),
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
toDeviceRpcRequestMsg.getOneway(),
|
||||||
|
toDeviceRpcRequestMsg.getExpirationTime(),
|
||||||
|
new ToDeviceRpcRequestBody(toDeviceRpcRequestMsg.getMethodName(), toDeviceRpcRequestMsg.getParams()),
|
||||||
|
toDeviceRpcRequestMsg.getPersisted(), 0, "");
|
||||||
|
return new ToDeviceRpcRequestActorMsg(proto.getServiceId(), toDeviceRpcRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.FromDeviceRpcResponseActorMsgProto toProto(FromDeviceRpcResponseActorMsg msg) {
|
||||||
|
TransportProtos.FromDeviceRPCResponseProto.Builder builder = TransportProtos.FromDeviceRPCResponseProto.newBuilder()
|
||||||
|
.setRequestIdMSB(msg.getMsg().getId().getMostSignificantBits())
|
||||||
|
.setRequestIdLSB(msg.getMsg().getId().getLeastSignificantBits())
|
||||||
|
.setError(msg.getMsg().getError().isPresent() ? msg.getMsg().getError().get().ordinal() : -1);
|
||||||
|
if (msg.getMsg().getResponse().isPresent()) {
|
||||||
|
builder.setResponse(msg.getMsg().getResponse().get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return TransportProtos.FromDeviceRpcResponseActorMsgProto.newBuilder()
|
||||||
|
.setRequestId(msg.getRequestId())
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setRpcResponse(builder.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ToDeviceActorNotificationMsg fromProto(TransportProtos.FromDeviceRpcResponseActorMsgProto proto) {
|
||||||
|
FromDeviceRpcResponse fromDeviceRpcResponse = new FromDeviceRpcResponse(
|
||||||
|
new UUID(proto.getRpcResponse().getRequestIdMSB(), proto.getRpcResponse().getRequestIdLSB()),
|
||||||
|
proto.getRpcResponse().getResponse(),
|
||||||
|
proto.getRpcResponse().getError() >= 0 ? RpcError.values()[proto.getRpcResponse().getError()] : null);
|
||||||
|
return new FromDeviceRpcResponseActorMsg(
|
||||||
|
proto.getRequestId(),
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
fromDeviceRpcResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransportProtos.RemoveRpcActorMsgProto toProto(RemoveRpcActorMsg msg) {
|
||||||
|
return TransportProtos.RemoveRpcActorMsgProto.newBuilder()
|
||||||
|
.setTenantIdMSB(msg.getTenantId().getId().getMostSignificantBits())
|
||||||
|
.setTenantIdLSB(msg.getTenantId().getId().getLeastSignificantBits())
|
||||||
|
.setDeviceIdMSB(msg.getDeviceId().getId().getMostSignificantBits())
|
||||||
|
.setDeviceIdLSB(msg.getDeviceId().getId().getLeastSignificantBits())
|
||||||
|
.setRequestIdMSB(msg.getRequestId().getMostSignificantBits())
|
||||||
|
.setRequestIdLSB(msg.getRequestId().getLeastSignificantBits())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ToDeviceActorNotificationMsg fromProto(TransportProtos.RemoveRpcActorMsgProto proto) {
|
||||||
|
return new RemoveRpcActorMsg(
|
||||||
|
TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())),
|
||||||
|
new DeviceId(new UUID(proto.getDeviceIdMSB(), proto.getDeviceIdLSB())),
|
||||||
|
new UUID(proto.getRequestIdMSB(), proto.getRequestIdLSB())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TransportProtos.ToDeviceActorNotificationMsgProto toProto(ToDeviceActorNotificationMsg msg) {
|
||||||
|
if (msg instanceof DeviceEdgeUpdateMsg) {
|
||||||
|
DeviceEdgeUpdateMsg updateMsg = (DeviceEdgeUpdateMsg) msg;
|
||||||
|
TransportProtos.DeviceEdgeUpdateMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setDeviceEdgeUpdateMsg(proto).build();
|
||||||
|
} else if (msg instanceof DeviceNameOrTypeUpdateMsg) {
|
||||||
|
DeviceNameOrTypeUpdateMsg updateMsg = (DeviceNameOrTypeUpdateMsg) msg;
|
||||||
|
TransportProtos.DeviceNameOrTypeUpdateMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setDeviceNameOrTypeMsg(proto).build();
|
||||||
|
} else if (msg instanceof DeviceAttributesEventNotificationMsg) {
|
||||||
|
DeviceAttributesEventNotificationMsg updateMsg = (DeviceAttributesEventNotificationMsg) msg;
|
||||||
|
TransportProtos.DeviceAttributesEventMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setDeviceAttributesEventMsg(proto).build();
|
||||||
|
} else if (msg instanceof DeviceCredentialsUpdateNotificationMsg) {
|
||||||
|
DeviceCredentialsUpdateNotificationMsg updateMsg = (DeviceCredentialsUpdateNotificationMsg) msg;
|
||||||
|
TransportProtos.DeviceCredentialsUpdateMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setDeviceCredentialsUpdateMsg(proto).build();
|
||||||
|
} else if (msg instanceof ToDeviceRpcRequestActorMsg) {
|
||||||
|
ToDeviceRpcRequestActorMsg updateMsg = (ToDeviceRpcRequestActorMsg) msg;
|
||||||
|
TransportProtos.ToDeviceRpcRequestActorMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setToDeviceRpcRequestMsg(proto).build();
|
||||||
|
} else if (msg instanceof FromDeviceRpcResponseActorMsg) {
|
||||||
|
FromDeviceRpcResponseActorMsg updateMsg = (FromDeviceRpcResponseActorMsg) msg;
|
||||||
|
TransportProtos.FromDeviceRpcResponseActorMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setFromDeviceRpcResponseMsg(proto).build();
|
||||||
|
} else if (msg instanceof RemoveRpcActorMsg) {
|
||||||
|
RemoveRpcActorMsg updateMsg = (RemoveRpcActorMsg) msg;
|
||||||
|
TransportProtos.RemoveRpcActorMsgProto proto = toProto(updateMsg);
|
||||||
|
return TransportProtos.ToDeviceActorNotificationMsgProto.newBuilder().setRemoveRpcActorMsg(proto).build();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToDeviceActorNotificationMsg fromProto(TransportProtos.ToDeviceActorNotificationMsgProto proto) {
|
||||||
|
if (proto.hasDeviceEdgeUpdateMsg()) {
|
||||||
|
return fromProto(proto.getDeviceEdgeUpdateMsg());
|
||||||
|
} else if (proto.hasDeviceNameOrTypeMsg()) {
|
||||||
|
return fromProto(proto.getDeviceNameOrTypeMsg());
|
||||||
|
} else if (proto.hasDeviceAttributesEventMsg()) {
|
||||||
|
return fromProto(proto.getDeviceAttributesEventMsg());
|
||||||
|
} else if (proto.hasDeviceCredentialsUpdateMsg()) {
|
||||||
|
return fromProto(proto.getDeviceCredentialsUpdateMsg());
|
||||||
|
} else if (proto.hasToDeviceRpcRequestMsg()) {
|
||||||
|
return fromProto(proto.getToDeviceRpcRequestMsg());
|
||||||
|
} else if (proto.hasFromDeviceRpcResponseMsg()) {
|
||||||
|
return fromProto(proto.getFromDeviceRpcResponseMsg());
|
||||||
|
} else if (proto.hasRemoveRpcActorMsg()) {
|
||||||
|
return fromProto(proto.getRemoveRpcActorMsg());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<AttributeKey> getAttributeKeySetFromProto(List<TransportProtos.AttributeKey> deletedKeysList) {
|
||||||
|
if (deletedKeysList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return deletedKeysList.stream()
|
||||||
|
.map(attributeKey -> new AttributeKey(attributeKey.getScope().name(), attributeKey.getAttributeKey()))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<AttributeKvEntry> getAttributesKvEntryFromProto(List<TransportProtos.AttributeValueProto> valuesList) {
|
||||||
|
if (valuesList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<AttributeKvEntry> result = new ArrayList<>();
|
||||||
|
for (TransportProtos.AttributeValueProto kvEntry : valuesList) {
|
||||||
|
boolean hasValue = kvEntry.getHasV();
|
||||||
|
KvEntry entry = null;
|
||||||
|
switch (kvEntry.getType()) {
|
||||||
|
case BOOLEAN_V:
|
||||||
|
entry = new BooleanDataEntry(kvEntry.getKey(), hasValue ? kvEntry.getBoolV() : null);
|
||||||
|
break;
|
||||||
|
case LONG_V:
|
||||||
|
entry = new LongDataEntry(kvEntry.getKey(), hasValue ? kvEntry.getLongV() : null);
|
||||||
|
break;
|
||||||
|
case DOUBLE_V:
|
||||||
|
entry = new DoubleDataEntry(kvEntry.getKey(), hasValue ? kvEntry.getDoubleV() : null);
|
||||||
|
break;
|
||||||
|
case STRING_V:
|
||||||
|
entry = new StringDataEntry(kvEntry.getKey(), hasValue ? kvEntry.getStringV() : null);
|
||||||
|
break;
|
||||||
|
case JSON_V:
|
||||||
|
entry = new JsonDataEntry(kvEntry.getKey(), hasValue ? kvEntry.getJsonV() : null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.add(new BaseAttributeKvEntry(kvEntry.getLastUpdateTs(), entry));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -172,10 +172,16 @@ public class TbCoreConsumerStats {
|
|||||||
toCoreNfComponentLifecycleCounter.increment();
|
toCoreNfComponentLifecycleCounter.increment();
|
||||||
} else if (!msg.getComponentLifecycleMsg().isEmpty()) {
|
} else if (!msg.getComponentLifecycleMsg().isEmpty()) {
|
||||||
toCoreNfComponentLifecycleCounter.increment();
|
toCoreNfComponentLifecycleCounter.increment();
|
||||||
|
} else if (msg.hasEdgeEventUpdate()) {
|
||||||
|
toCoreNfEdgeEventUpdateCounter.increment();
|
||||||
} else if (!msg.getEdgeEventUpdateMsg().isEmpty()) {
|
} else if (!msg.getEdgeEventUpdateMsg().isEmpty()) {
|
||||||
toCoreNfEdgeEventUpdateCounter.increment();
|
toCoreNfEdgeEventUpdateCounter.increment();
|
||||||
|
} else if (msg.hasToEdgeSyncRequest()) {
|
||||||
|
toCoreNfEdgeSyncRequestCounter.increment();
|
||||||
} else if (!msg.getToEdgeSyncRequestMsg().isEmpty()) {
|
} else if (!msg.getToEdgeSyncRequestMsg().isEmpty()) {
|
||||||
toCoreNfEdgeSyncRequestCounter.increment();
|
toCoreNfEdgeSyncRequestCounter.increment();
|
||||||
|
} else if (msg.hasFromEdgeSyncResponse()) {
|
||||||
|
toCoreNfEdgeSyncResponseCounter.increment();
|
||||||
} else if (!msg.getFromEdgeSyncResponseMsg().isEmpty()) {
|
} else if (!msg.getFromEdgeSyncResponseMsg().isEmpty()) {
|
||||||
toCoreNfEdgeSyncResponseCounter.increment();
|
toCoreNfEdgeSyncResponseCounter.increment();
|
||||||
} else if (msg.hasQueueUpdateMsg()) {
|
} else if (msg.hasQueueUpdateMsg()) {
|
||||||
|
|||||||
@ -31,6 +31,8 @@ import org.thingsboard.server.common.data.rpc.RpcError;
|
|||||||
import org.thingsboard.server.common.msg.TbMsg;
|
import org.thingsboard.server.common.msg.TbMsg;
|
||||||
import org.thingsboard.server.common.msg.TbMsgDataType;
|
import org.thingsboard.server.common.msg.TbMsgDataType;
|
||||||
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
||||||
import org.thingsboard.server.dao.device.DeviceService;
|
import org.thingsboard.server.dao.device.DeviceService;
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
|||||||
import org.thingsboard.server.common.data.rpc.Rpc;
|
import org.thingsboard.server.common.data.rpc.Rpc;
|
||||||
import org.thingsboard.server.common.data.rpc.RpcError;
|
import org.thingsboard.server.common.data.rpc.RpcError;
|
||||||
import org.thingsboard.server.common.data.rpc.ToDeviceRpcRequestBody;
|
import org.thingsboard.server.common.data.rpc.ToDeviceRpcRequestBody;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
import org.thingsboard.server.common.msg.queue.ServiceType;
|
import org.thingsboard.server.common.msg.queue.ServiceType;
|
||||||
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
||||||
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.rpc;
|
package org.thingsboard.server.service.rpc;
|
||||||
|
|
||||||
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
||||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.common.util.DonAsynchron;
|
import org.thingsboard.common.util.DonAsynchron;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
||||||
import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.server.cluster.TbClusterService;
|
import org.thingsboard.server.cluster.TbClusterService;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
|
|||||||
@ -15,14 +15,42 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.queue;
|
package org.thingsboard.server.service.queue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
import org.thingsboard.server.common.data.kv.AttributeKey;
|
||||||
|
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.BooleanDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.DoubleDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.JsonDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.StringDataEntry;
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
|
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
|
||||||
|
import org.thingsboard.server.common.data.rpc.RpcError;
|
||||||
|
import org.thingsboard.server.common.data.rpc.ToDeviceRpcRequestBody;
|
||||||
|
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||||
|
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
||||||
|
import org.thingsboard.server.common.msg.edge.EdgeEventUpdateMsg;
|
||||||
|
import org.thingsboard.server.common.msg.edge.FromEdgeSyncResponse;
|
||||||
|
import org.thingsboard.server.common.msg.edge.ToEdgeSyncRequest;
|
||||||
import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
|
import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponseActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.RemoveRpcActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
||||||
|
import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequestActorMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceCredentialsUpdateNotificationMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceEdgeUpdateMsg;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceNameOrTypeUpdateMsg;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -31,6 +59,10 @@ class ProtoUtilsTest {
|
|||||||
|
|
||||||
TenantId tenantId = TenantId.fromUUID(UUID.fromString("35e10f77-16e7-424d-ae46-ee780f87ac4f"));
|
TenantId tenantId = TenantId.fromUUID(UUID.fromString("35e10f77-16e7-424d-ae46-ee780f87ac4f"));
|
||||||
EntityId entityId = new RuleChainId(UUID.fromString("c640b635-4f0f-41e6-b10b-25a86003094e"));
|
EntityId entityId = new RuleChainId(UUID.fromString("c640b635-4f0f-41e6-b10b-25a86003094e"));
|
||||||
|
DeviceId deviceId = new DeviceId(UUID.fromString("ceebb9e5-4239-437c-a507-dc5f71f1232d"));
|
||||||
|
EdgeId edgeId = new EdgeId(UUID.fromString("364be452-2183-459b-af93-1ddb325feac1"));
|
||||||
|
UUID id = UUID.fromString("31a07d85-6ed5-46f8-83c0-6715cb0a8782");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void protoComponentLifecycleSerialization() {
|
void protoComponentLifecycleSerialization() {
|
||||||
ComponentLifecycleMsg msg = new ComponentLifecycleMsg(tenantId, entityId, ComponentLifecycleEvent.UPDATED);
|
ComponentLifecycleMsg msg = new ComponentLifecycleMsg(tenantId, entityId, ComponentLifecycleEvent.UPDATED);
|
||||||
@ -46,4 +78,105 @@ class ProtoUtilsTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoEdgeEventUpdateSerialization() {
|
||||||
|
EdgeEventUpdateMsg msg = new EdgeEventUpdateMsg(tenantId, edgeId);
|
||||||
|
assertThat(ProtoUtils.fromProto(ProtoUtils.toProto(msg))).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoToEdgeSyncRequestSerialization() {
|
||||||
|
ToEdgeSyncRequest msg = new ToEdgeSyncRequest(id, tenantId, edgeId);
|
||||||
|
assertThat(ProtoUtils.fromProto(ProtoUtils.toProto(msg))).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoFromEdgeSyncResponseSerialization() {
|
||||||
|
FromEdgeSyncResponse msg = new FromEdgeSyncResponse(id, tenantId, edgeId, true);
|
||||||
|
assertThat(ProtoUtils.fromProto(ProtoUtils.toProto(msg))).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoDeviceEdgeUpdateSerialization() {
|
||||||
|
DeviceEdgeUpdateMsg msg = new DeviceEdgeUpdateMsg(tenantId, deviceId, edgeId);
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoDeviceNameOrTypeSerialization() {
|
||||||
|
String deviceName = "test", deviceType = "test";
|
||||||
|
DeviceNameOrTypeUpdateMsg msg = new DeviceNameOrTypeUpdateMsg(tenantId, deviceId, deviceName, deviceType);
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoDeviceAttributesEventSerialization() {
|
||||||
|
DeviceAttributesEventNotificationMsg msg = new DeviceAttributesEventNotificationMsg(tenantId, deviceId, null, "CLIENT_SCOPE",
|
||||||
|
List.of(new BaseAttributeKvEntry(System.currentTimeMillis(), new StringDataEntry("key", "value"))), false);
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
|
||||||
|
msg = new DeviceAttributesEventNotificationMsg(tenantId, deviceId, null, "SERVER_SCOPE",
|
||||||
|
List.of(new BaseAttributeKvEntry(System.currentTimeMillis(), new DoubleDataEntry("doubleEntry", 231.5)),
|
||||||
|
new BaseAttributeKvEntry(System.currentTimeMillis(), new JsonDataEntry("jsonEntry", "jsonValue"))), false);
|
||||||
|
serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
|
||||||
|
msg = new DeviceAttributesEventNotificationMsg(tenantId, deviceId, null, "SERVER_SCOPE",
|
||||||
|
List.of(new BaseAttributeKvEntry(System.currentTimeMillis(), new DoubleDataEntry("entry", 11.3)),
|
||||||
|
new BaseAttributeKvEntry(System.currentTimeMillis(), new BooleanDataEntry("jsonEntry", true))), false);
|
||||||
|
serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
|
||||||
|
msg = new DeviceAttributesEventNotificationMsg(tenantId, deviceId, Set.of(new AttributeKey("SHARED_SCOPE", "attributeKey")), null, null, true);
|
||||||
|
serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoDeviceCredentialsUpdateSerialization() {
|
||||||
|
DeviceCredentials deviceCredentials = new DeviceCredentials();
|
||||||
|
deviceCredentials.setDeviceId(deviceId);
|
||||||
|
deviceCredentials.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN);
|
||||||
|
deviceCredentials.setCredentialsValue("test");
|
||||||
|
deviceCredentials.setCredentialsId("test");
|
||||||
|
DeviceCredentialsUpdateNotificationMsg msg = new DeviceCredentialsUpdateNotificationMsg(tenantId, deviceId, deviceCredentials);
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoToDeviceRpcRequestSerialization() {
|
||||||
|
String serviceId = "cadcaac6-85c3-4211-9756-f074dcd1e7f7";
|
||||||
|
ToDeviceRpcRequest request = new ToDeviceRpcRequest(id, tenantId, deviceId, true, 0, new ToDeviceRpcRequestBody("method", "params"), false, 0, "");
|
||||||
|
ToDeviceRpcRequestActorMsg msg = new ToDeviceRpcRequestActorMsg(serviceId, request);
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoFromDeviceRpcResponseSerialization() {
|
||||||
|
FromDeviceRpcResponseActorMsg msg = new FromDeviceRpcResponseActorMsg(23, tenantId, deviceId, new FromDeviceRpcResponse(id, "response", RpcError.NOT_FOUND));
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void protoRemoveRpcActorSerialization() {
|
||||||
|
RemoveRpcActorMsg msg = new RemoveRpcActorMsg(tenantId, deviceId, id);
|
||||||
|
TransportProtos.ToDeviceActorNotificationMsgProto serializedMsg = ProtoUtils.toProto(msg);
|
||||||
|
Assertions.assertNotNull(serializedMsg);
|
||||||
|
assertThat(ProtoUtils.fromProto(serializedMsg)).as("deserialized").isEqualTo(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -132,6 +132,17 @@ message KeyValueProto {
|
|||||||
string json_v = 7;
|
string json_v = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AttributeScopeProto {
|
||||||
|
CLIENT_SCOPE = 0;
|
||||||
|
SERVER_SCOPE = 1;
|
||||||
|
SHARED_SCOPE = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AttributeKey {
|
||||||
|
AttributeScopeProto scope = 1;
|
||||||
|
string attributeKey = 2;
|
||||||
|
}
|
||||||
|
|
||||||
message AttributeValueProto {
|
message AttributeValueProto {
|
||||||
int64 lastUpdateTs = 1;
|
int64 lastUpdateTs = 1;
|
||||||
KeyValueType type = 2;
|
KeyValueType type = 2;
|
||||||
@ -141,6 +152,7 @@ message AttributeValueProto {
|
|||||||
double double_v = 6;
|
double double_v = 6;
|
||||||
string string_v = 7;
|
string string_v = 7;
|
||||||
string json_v = 8;
|
string json_v = 8;
|
||||||
|
optional string key = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message TsKvProto {
|
message TsKvProto {
|
||||||
@ -463,7 +475,7 @@ message DeviceCredentialsProto {
|
|||||||
int64 deviceIdLSB = 2;
|
int64 deviceIdLSB = 2;
|
||||||
CredentialsType credentialsType = 3;
|
CredentialsType credentialsType = 3;
|
||||||
string credentialsId = 4;
|
string credentialsId = 4;
|
||||||
string credentialsValue = 5;
|
optional string credentialsValue = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CredentialsDataProto {
|
message CredentialsDataProto {
|
||||||
@ -801,6 +813,106 @@ message EdgeNotificationMsgProto {
|
|||||||
PostAttributeMsg postAttributesMsg = 12;
|
PostAttributeMsg postAttributesMsg = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message EdgeEventUpdateMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 edgeIdMSB = 3;
|
||||||
|
int64 edgeIdLSB = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ToEdgeSyncRequestMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 requestIdMSB = 3;
|
||||||
|
int64 requestIdLSB = 4;
|
||||||
|
int64 edgeIdMSB = 5;
|
||||||
|
int64 edgeIdLSB = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FromEdgeSyncResponseMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 responseIdMSB = 3;
|
||||||
|
int64 responseIdLSB = 4;
|
||||||
|
int64 edgeIdMSB = 5;
|
||||||
|
int64 edgeIdLSB = 6;
|
||||||
|
bool success = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeviceEdgeUpdateMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 deviceIdMSB = 3;
|
||||||
|
int64 deviceIdLSB = 4;
|
||||||
|
int64 edgeIdMSB = 5;
|
||||||
|
int64 edgeIdLSB = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeviceNameOrTypeUpdateMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 deviceIdMSB = 3;
|
||||||
|
int64 deviceIdLSB = 4;
|
||||||
|
string deviceName = 5;
|
||||||
|
string deviceType = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeviceAttributesEventMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 deviceIdMSB = 3;
|
||||||
|
int64 deviceIdLSB = 4;
|
||||||
|
repeated AttributeKey deletedKeys = 5;
|
||||||
|
optional AttributeScopeProto scope = 6;
|
||||||
|
repeated AttributeValueProto values = 7;
|
||||||
|
bool deleted = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeviceCredentialsUpdateMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 deviceIdMSB = 3;
|
||||||
|
int64 deviceIdLSB = 4;
|
||||||
|
DeviceCredentialsProto deviceCredentials = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ToDeviceRpcRequestActorMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 deviceIdMSB = 3;
|
||||||
|
int64 deviceIdLSB = 4;
|
||||||
|
string serviceId = 5;
|
||||||
|
ToDeviceRpcRequestMsg toDeviceRpcRequestMsg = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FromDeviceRpcResponseActorMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 deviceIdMSB = 3;
|
||||||
|
int64 deviceIdLSB = 4;
|
||||||
|
int32 requestId = 5;
|
||||||
|
FromDeviceRPCResponseProto rpcResponse = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoveRpcActorMsgProto {
|
||||||
|
int64 tenantIdMSB = 1;
|
||||||
|
int64 tenantIdLSB = 2;
|
||||||
|
int64 requestIdMSB = 3;
|
||||||
|
int64 requestIdLSB = 4;
|
||||||
|
int64 deviceIdMSB = 5;
|
||||||
|
int64 deviceIdLSB = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ToDeviceActorNotificationMsgProto {
|
||||||
|
DeviceEdgeUpdateMsgProto deviceEdgeUpdateMsg = 1;
|
||||||
|
DeviceNameOrTypeUpdateMsgProto deviceNameOrTypeMsg = 2;
|
||||||
|
DeviceAttributesEventMsgProto deviceAttributesEventMsg = 3;
|
||||||
|
DeviceCredentialsUpdateMsgProto deviceCredentialsUpdateMsg = 4;
|
||||||
|
ToDeviceRpcRequestActorMsgProto toDeviceRpcRequestMsg = 5;
|
||||||
|
FromDeviceRpcResponseActorMsgProto fromDeviceRpcResponseMsg = 6;
|
||||||
|
RemoveRpcActorMsgProto removeRpcActorMsg = 7;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
TB Core to Version Control Service
|
TB Core to Version Control Service
|
||||||
*/
|
*/
|
||||||
@ -1026,12 +1138,13 @@ message ToCoreMsg {
|
|||||||
TransportToDeviceActorMsg toDeviceActorMsg = 1;
|
TransportToDeviceActorMsg toDeviceActorMsg = 1;
|
||||||
DeviceStateServiceMsgProto deviceStateServiceMsg = 2;
|
DeviceStateServiceMsgProto deviceStateServiceMsg = 2;
|
||||||
SubscriptionMgrMsgProto toSubscriptionMgrMsg = 3;
|
SubscriptionMgrMsgProto toSubscriptionMgrMsg = 3;
|
||||||
bytes toDeviceActorNotificationMsg = 4;
|
bytes toDeviceActorNotificationMsg = 4 [deprecated = true];
|
||||||
EdgeNotificationMsgProto edgeNotificationMsg = 5;
|
EdgeNotificationMsgProto edgeNotificationMsg = 5;
|
||||||
DeviceActivityProto deviceActivityMsg = 6;
|
DeviceActivityProto deviceActivityMsg = 6;
|
||||||
NotificationSchedulerServiceMsg notificationSchedulerServiceMsg = 7;
|
NotificationSchedulerServiceMsg notificationSchedulerServiceMsg = 7;
|
||||||
LifecycleEventProto lifecycleEventMsg = 8;
|
LifecycleEventProto lifecycleEventMsg = 8;
|
||||||
ErrorEventProto errorEventMsg = 9;
|
ErrorEventProto errorEventMsg = 9;
|
||||||
|
ToDeviceActorNotificationMsgProto toDeviceActorNotification = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* High priority messages with low latency are handled by ThingsBoard Core Service separately */
|
/* High priority messages with low latency are handled by ThingsBoard Core Service separately */
|
||||||
@ -1039,16 +1152,19 @@ message ToCoreMsg {
|
|||||||
message ToCoreNotificationMsg {
|
message ToCoreNotificationMsg {
|
||||||
LocalSubscriptionServiceMsgProto toLocalSubscriptionServiceMsg = 1;
|
LocalSubscriptionServiceMsgProto toLocalSubscriptionServiceMsg = 1;
|
||||||
FromDeviceRPCResponseProto fromDeviceRpcResponse = 2;
|
FromDeviceRPCResponseProto fromDeviceRpcResponse = 2;
|
||||||
bytes componentLifecycleMsg = 3; //will be removed in 3.6.1 in favour of ComponentLifecycleMsgProto
|
bytes componentLifecycleMsg = 3 [deprecated = true];
|
||||||
bytes edgeEventUpdateMsg = 4;
|
bytes edgeEventUpdateMsg = 4 [deprecated = true];
|
||||||
QueueUpdateMsg queueUpdateMsg = 5;
|
QueueUpdateMsg queueUpdateMsg = 5;
|
||||||
QueueDeleteMsg queueDeleteMsg = 6;
|
QueueDeleteMsg queueDeleteMsg = 6;
|
||||||
VersionControlResponseMsg vcResponseMsg = 7;
|
VersionControlResponseMsg vcResponseMsg = 7;
|
||||||
bytes toEdgeSyncRequestMsg = 8;
|
bytes toEdgeSyncRequestMsg = 8 [deprecated = true];
|
||||||
bytes fromEdgeSyncResponseMsg = 9;
|
bytes fromEdgeSyncResponseMsg = 9 [deprecated = true];
|
||||||
SubscriptionMgrMsgProto toSubscriptionMgrMsg = 10;
|
SubscriptionMgrMsgProto toSubscriptionMgrMsg = 10;
|
||||||
NotificationRuleProcessorMsg notificationRuleProcessorMsg = 11;
|
NotificationRuleProcessorMsg notificationRuleProcessorMsg = 11;
|
||||||
ComponentLifecycleMsgProto componentLifecycle = 12;
|
ComponentLifecycleMsgProto componentLifecycle = 12;
|
||||||
|
EdgeEventUpdateMsgProto edgeEventUpdate = 13;
|
||||||
|
ToEdgeSyncRequestMsgProto toEdgeSyncRequest = 14;
|
||||||
|
FromEdgeSyncResponseMsgProto fromEdgeSyncResponse = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Messages that are handled by ThingsBoard RuleEngine Service */
|
/* Messages that are handled by ThingsBoard RuleEngine Service */
|
||||||
@ -1061,7 +1177,7 @@ message ToRuleEngineMsg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message ToRuleEngineNotificationMsg {
|
message ToRuleEngineNotificationMsg {
|
||||||
bytes componentLifecycleMsg = 1; // will be removed in 3.6.1 in favour of ComponentLifecycleMsgProto
|
bytes componentLifecycleMsg = 1 [deprecated = true];
|
||||||
FromDeviceRPCResponseProto fromDeviceRpcResponse = 2;
|
FromDeviceRPCResponseProto fromDeviceRpcResponse = 2;
|
||||||
QueueUpdateMsg queueUpdateMsg = 3;
|
QueueUpdateMsg queueUpdateMsg = 3;
|
||||||
QueueDeleteMsg queueDeleteMsg = 4;
|
QueueDeleteMsg queueDeleteMsg = 4;
|
||||||
|
|||||||
@ -15,23 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.msg.edge;
|
package org.thingsboard.server.common.msg.edge;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.MsgType;
|
import org.thingsboard.server.common.msg.MsgType;
|
||||||
|
|
||||||
@ToString
|
@Data
|
||||||
public class EdgeEventUpdateMsg implements EdgeSessionMsg {
|
public class EdgeEventUpdateMsg implements EdgeSessionMsg {
|
||||||
@Getter
|
|
||||||
private final TenantId tenantId;
|
|
||||||
@Getter
|
|
||||||
private final EdgeId edgeId;
|
|
||||||
|
|
||||||
public EdgeEventUpdateMsg(TenantId tenantId, EdgeId edgeId) {
|
private static final long serialVersionUID = -8050114506822836537L;
|
||||||
this.tenantId = tenantId;
|
|
||||||
this.edgeId = edgeId;
|
private final TenantId tenantId;
|
||||||
}
|
private final EdgeId edgeId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MsgType getMsgType() {
|
public MsgType getMsgType() {
|
||||||
|
|||||||
@ -15,18 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.msg.edge;
|
package org.thingsboard.server.common.msg.edge;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.MsgType;
|
import org.thingsboard.server.common.msg.MsgType;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@Data
|
||||||
@Getter
|
|
||||||
public class FromEdgeSyncResponse implements EdgeSessionMsg {
|
public class FromEdgeSyncResponse implements EdgeSessionMsg {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -6360890886315347486L;
|
||||||
|
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
private final TenantId tenantId;
|
private final TenantId tenantId;
|
||||||
private final EdgeId edgeId;
|
private final EdgeId edgeId;
|
||||||
|
|||||||
@ -15,17 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.msg.edge;
|
package org.thingsboard.server.common.msg.edge;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.MsgType;
|
import org.thingsboard.server.common.msg.MsgType;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@Data
|
||||||
@Getter
|
|
||||||
public class ToEdgeSyncRequest implements EdgeSessionMsg {
|
public class ToEdgeSyncRequest implements EdgeSessionMsg {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7624597032448212259L;
|
||||||
|
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
private final TenantId tenantId;
|
private final TenantId tenantId;
|
||||||
private final EdgeId edgeId;
|
private final EdgeId edgeId;
|
||||||
|
|||||||
@ -15,9 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.common.msg.rpc;
|
package org.thingsboard.server.common.msg.rpc;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.rpc.RpcError;
|
import org.thingsboard.server.common.data.rpc.RpcError;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -27,10 +25,11 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* @author Andrew Shvayka
|
* @author Andrew Shvayka
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@Data
|
||||||
@ToString
|
|
||||||
public class FromDeviceRpcResponse implements Serializable {
|
public class FromDeviceRpcResponse implements Serializable {
|
||||||
@Getter
|
|
||||||
|
private static final long serialVersionUID = -3799452502112373491L;
|
||||||
|
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
private final String response;
|
private final String response;
|
||||||
private final RpcError error;
|
private final RpcError error;
|
||||||
|
|||||||
@ -13,29 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.rpc;
|
package org.thingsboard.server.common.msg.rpc;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.MsgType;
|
import org.thingsboard.server.common.msg.MsgType;
|
||||||
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
||||||
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
||||||
|
|
||||||
@ToString
|
@Data
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class FromDeviceRpcResponseActorMsg implements ToDeviceActorNotificationMsg {
|
public class FromDeviceRpcResponseActorMsg implements ToDeviceActorNotificationMsg {
|
||||||
|
|
||||||
@Getter
|
private static final long serialVersionUID = -6648120137236354987L;
|
||||||
private final Integer requestId;
|
|
||||||
@Getter
|
|
||||||
private final TenantId tenantId;
|
|
||||||
@Getter
|
|
||||||
private final DeviceId deviceId;
|
|
||||||
|
|
||||||
@Getter
|
private final Integer requestId;
|
||||||
|
private final TenantId tenantId;
|
||||||
|
private final DeviceId deviceId;
|
||||||
private final FromDeviceRpcResponse msg;
|
private final FromDeviceRpcResponse msg;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -13,11 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.rpc;
|
package org.thingsboard.server.common.msg.rpc;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.MsgType;
|
import org.thingsboard.server.common.msg.MsgType;
|
||||||
@ -25,16 +23,13 @@ import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ToString
|
@Data
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class RemoveRpcActorMsg implements ToDeviceActorNotificationMsg {
|
public class RemoveRpcActorMsg implements ToDeviceActorNotificationMsg {
|
||||||
|
|
||||||
@Getter
|
private static final long serialVersionUID = -6112720854949677477L;
|
||||||
private final TenantId tenantId;
|
|
||||||
@Getter
|
|
||||||
private final DeviceId deviceId;
|
|
||||||
|
|
||||||
@Getter
|
private final TenantId tenantId;
|
||||||
|
private final DeviceId deviceId;
|
||||||
private final UUID requestId;
|
private final UUID requestId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,6 +29,9 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ToDeviceRpcRequest implements Serializable {
|
public class ToDeviceRpcRequest implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7089247105087346214L;
|
||||||
|
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
private final TenantId tenantId;
|
private final TenantId tenantId;
|
||||||
private final DeviceId deviceId;
|
private final DeviceId deviceId;
|
||||||
@ -40,4 +43,3 @@ public class ToDeviceRpcRequest implements Serializable {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private final String additionalInfo;
|
private final String additionalInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.rpc;
|
package org.thingsboard.server.common.msg.rpc;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.msg.MsgType;
|
import org.thingsboard.server.common.msg.MsgType;
|
||||||
@ -27,15 +25,12 @@ import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest;
|
|||||||
/**
|
/**
|
||||||
* Created by ashvayka on 16.04.18.
|
* Created by ashvayka on 16.04.18.
|
||||||
*/
|
*/
|
||||||
@ToString
|
@Data
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ToDeviceRpcRequestActorMsg implements ToDeviceActorNotificationMsg {
|
public class ToDeviceRpcRequestActorMsg implements ToDeviceActorNotificationMsg {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8592877558138716589L;
|
private static final long serialVersionUID = -8592877558138716589L;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final String serviceId;
|
private final String serviceId;
|
||||||
@Getter
|
|
||||||
private final ToDeviceRpcRequest msg;
|
private final ToDeviceRpcRequest msg;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.rule.engine.api.msg;
|
package org.thingsboard.server.common.msg.rule.engine;
|
||||||
|
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.kv.AttributeKey;
|
import org.thingsboard.server.common.data.kv.AttributeKey;
|
||||||
@ -13,11 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.rule.engine.api.msg;
|
package org.thingsboard.server.common.msg.rule.engine;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.kv.AttributeKey;
|
import org.thingsboard.server.common.data.kv.AttributeKey;
|
||||||
@ -32,21 +30,16 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* @author Andrew Shvayka
|
* @author Andrew Shvayka
|
||||||
*/
|
*/
|
||||||
@ToString
|
@Data
|
||||||
@AllArgsConstructor
|
|
||||||
public class DeviceAttributesEventNotificationMsg implements ToDeviceActorNotificationMsg {
|
public class DeviceAttributesEventNotificationMsg implements ToDeviceActorNotificationMsg {
|
||||||
|
|
||||||
@Getter
|
private static final long serialVersionUID = 2422071590415277039L;
|
||||||
|
|
||||||
private final TenantId tenantId;
|
private final TenantId tenantId;
|
||||||
@Getter
|
|
||||||
private final DeviceId deviceId;
|
private final DeviceId deviceId;
|
||||||
@Getter
|
|
||||||
private final Set<AttributeKey> deletedKeys;
|
private final Set<AttributeKey> deletedKeys;
|
||||||
@Getter
|
|
||||||
private final String scope;
|
private final String scope;
|
||||||
@Getter
|
|
||||||
private final List<AttributeKvEntry> values;
|
private final List<AttributeKvEntry> values;
|
||||||
@Getter
|
|
||||||
private final boolean deleted;
|
private final boolean deleted;
|
||||||
|
|
||||||
public static DeviceAttributesEventNotificationMsg onUpdate(TenantId tenantId, DeviceId deviceId, String scope, List<AttributeKvEntry> values) {
|
public static DeviceAttributesEventNotificationMsg onUpdate(TenantId tenantId, DeviceId deviceId, String scope, List<AttributeKvEntry> values) {
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.rule.engine.api.msg;
|
package org.thingsboard.server.common.msg.rule.engine;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
@ -13,9 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.rule.engine.api.msg;
|
package org.thingsboard.server.common.msg.rule.engine;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
@ -24,9 +23,10 @@ import org.thingsboard.server.common.msg.MsgType;
|
|||||||
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
|
||||||
public class DeviceEdgeUpdateMsg implements ToDeviceActorNotificationMsg {
|
public class DeviceEdgeUpdateMsg implements ToDeviceActorNotificationMsg {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 4679029228395462172L;
|
||||||
|
|
||||||
private final TenantId tenantId;
|
private final TenantId tenantId;
|
||||||
private final DeviceId deviceId;
|
private final DeviceId deviceId;
|
||||||
private final EdgeId edgeId;
|
private final EdgeId edgeId;
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.rule.engine.api.msg;
|
package org.thingsboard.server.common.msg.rule.engine;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
@ -13,9 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.thingsboard.rule.engine.api.msg;
|
package org.thingsboard.server.common.msg.rule.engine;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -23,7 +22,6 @@ import org.thingsboard.server.common.msg.MsgType;
|
|||||||
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
import org.thingsboard.server.common.msg.ToDeviceActorNotificationMsg;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
|
||||||
public class DeviceNameOrTypeUpdateMsg implements ToDeviceActorNotificationMsg {
|
public class DeviceNameOrTypeUpdateMsg implements ToDeviceActorNotificationMsg {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5738949227650536685L;
|
private static final long serialVersionUID = -5738949227650536685L;
|
||||||
Loading…
x
Reference in New Issue
Block a user