Browse Source

Fix ComponentLifecycleMsg: message and builder

pull/12707/head
Andrii Landiak 1 year ago
parent
commit
44a7bf82c4
  1. 4
      common/message/src/main/java/org/thingsboard/server/common/msg/plugin/ComponentLifecycleMsg.java
  2. 7
      common/proto/src/main/java/org/thingsboard/server/common/util/ProtoUtils.java
  3. 4
      common/proto/src/main/proto/queue.proto

4
common/message/src/main/java/org/thingsboard/server/common/msg/plugin/ComponentLifecycleMsg.java

@ -26,6 +26,7 @@ import org.thingsboard.server.common.msg.MsgType;
import org.thingsboard.server.common.msg.aware.TenantAwareMsg;
import org.thingsboard.server.common.msg.cluster.ToAllNodesMsg;
import java.io.Serial;
import java.util.Optional;
/**
@ -33,6 +34,8 @@ import java.util.Optional;
*/
@Data
public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg {
@Serial
private static final long serialVersionUID = -5303421482781273062L;
private final TenantId tenantId;
@ -66,4 +69,5 @@ public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg {
public MsgType getMsgType() {
return MsgType.COMPONENT_LIFE_CYCLE_MSG;
}
}

7
common/proto/src/main/java/org/thingsboard/server/common/util/ProtoUtils.java

@ -134,7 +134,7 @@ public class ProtoUtils {
builder.setName(msg.getName());
}
if (msg.getOldName() != null) {
builder.setName(msg.getOldName());
builder.setOldName(msg.getOldName());
}
return builder.build();
}
@ -149,8 +149,8 @@ public class ProtoUtils {
.tenantId(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())))
.entityId(entityId)
.event(ComponentLifecycleEvent.values()[proto.getEventValue()])
.name(proto.getName())
.oldName(proto.getOldName());
.name(proto.hasName() ? proto.getName() : null)
.oldName(proto.hasOldName() ? proto.getOldName() : null);
if (proto.getProfileIdMSB() != 0 || proto.getProfileIdLSB() != 0) {
var profileType = EntityType.DEVICE.equals(entityId.getEntityType()) ? EntityType.DEVICE_PROFILE : EntityType.ASSET_PROFILE;
builder.profileId(EntityIdFactory.getByTypeAndUuid(profileType, new UUID(proto.getProfileIdMSB(), proto.getProfileIdLSB())));
@ -166,7 +166,6 @@ public class ProtoUtils {
return entityTypeByProtoNumber[entityType.getNumber()];
}
public static TransportProtos.ToEdgeSyncRequestMsgProto toProto(ToEdgeSyncRequest request) {
return TransportProtos.ToEdgeSyncRequestMsgProto.newBuilder()
.setTenantIdMSB(request.getTenantId().getId().getMostSignificantBits())

4
common/proto/src/main/proto/queue.proto

@ -1188,8 +1188,8 @@ message ComponentLifecycleMsgProto {
int64 entityIdLSB = 5;
ComponentLifecycleEvent event = 6;
//Since 4.0. To replace the
string oldName = 7;
string name = 8;
optional string oldName = 7;
optional string name = 8;
int64 oldProfileIdMSB = 9;
int64 oldProfileIdLSB = 10;
int64 profileIdMSB = 11;

Loading…
Cancel
Save