|
|
|
@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
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.common.data.EdgeUtils; |
|
|
|
@ -455,6 +456,21 @@ public class DefaultTbClusterService implements TbClusterService { |
|
|
|
TransportProtos.EdgeNotificationMsgProto msg = builder.build(); |
|
|
|
log.trace("[{}] sending notification to edge service {}", tenantId.getId(), msg); |
|
|
|
pushMsgToCore(tenantId, entityId != null ? entityId : tenantId, TransportProtos.ToCoreMsg.newBuilder().setEdgeNotificationMsg(msg).build(), null); |
|
|
|
|
|
|
|
if (entityId != null && EntityType.DEVICE.equals(entityId.getEntityType())) { |
|
|
|
pushDeviceUpdateMessage(tenantId, edgeId, entityId, action); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void pushDeviceUpdateMessage(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventActionType action) { |
|
|
|
log.trace("{} Going to send edge update notification for device actor, device id {}, edge id {}", tenantId, entityId, edgeId); |
|
|
|
switch (action) { |
|
|
|
case ASSIGNED_TO_EDGE: |
|
|
|
pushMsgToCore(new DeviceEdgeUpdateMsg(tenantId, new DeviceId(entityId.getId()), edgeId), null); |
|
|
|
break; |
|
|
|
case UNASSIGNED_FROM_EDGE: |
|
|
|
pushMsgToCore(new DeviceEdgeUpdateMsg(tenantId, new DeviceId(entityId.getId()), null), null); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|