Fix queue.proto structure of EdgeEventMsg

This commit is contained in:
Andrii Landiak 2024-11-05 17:35:19 +02:00
parent 020d0182da
commit a6c8b9a526
3 changed files with 18 additions and 16 deletions

View File

@ -119,8 +119,7 @@ public abstract class BaseEdgeProcessor {
UPDATED_COMMENT -> true; UPDATED_COMMENT -> true;
default -> switch (type) { default -> switch (type) {
case ALARM, ALARM_COMMENT, RULE_CHAIN, RULE_CHAIN_METADATA, USER, CUSTOMER, TENANT, TENANT_PROFILE, case ALARM, ALARM_COMMENT, RULE_CHAIN, RULE_CHAIN_METADATA, USER, CUSTOMER, TENANT, TENANT_PROFILE,
WIDGETS_BUNDLE, WIDGET_TYPE, WIDGETS_BUNDLE, WIDGET_TYPE, ADMIN_SETTINGS, OTA_PACKAGE, QUEUE, RELATION, NOTIFICATION_TEMPLATE, NOTIFICATION_TARGET,
ADMIN_SETTINGS, OTA_PACKAGE, QUEUE, RELATION, NOTIFICATION_TEMPLATE, NOTIFICATION_TARGET,
NOTIFICATION_RULE -> true; NOTIFICATION_RULE -> true;
default -> false; default -> false;
}; };
@ -176,10 +175,8 @@ public abstract class BaseEdgeProcessor {
return switch (actionType) { return switch (actionType) {
case UPDATED, CREDENTIALS_UPDATED, ASSIGNED_TO_CUSTOMER, UNASSIGNED_FROM_CUSTOMER, UPDATED_COMMENT -> case UPDATED, CREDENTIALS_UPDATED, ASSIGNED_TO_CUSTOMER, UNASSIGNED_FROM_CUSTOMER, UPDATED_COMMENT ->
UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE; UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE;
case ADDED, ASSIGNED_TO_EDGE, RELATION_ADD_OR_UPDATE, ADDED_COMMENT -> case ADDED, ASSIGNED_TO_EDGE, RELATION_ADD_OR_UPDATE, ADDED_COMMENT -> UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE;
UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE; case DELETED, UNASSIGNED_FROM_EDGE, RELATION_DELETED, DELETED_COMMENT, ALARM_DELETE -> UpdateMsgType.ENTITY_DELETED_RPC_MESSAGE;
case DELETED, UNASSIGNED_FROM_EDGE, RELATION_DELETED, DELETED_COMMENT, ALARM_DELETE ->
UpdateMsgType.ENTITY_DELETED_RPC_MESSAGE;
case ALARM_ACK -> UpdateMsgType.ALARM_ACK_RPC_MESSAGE; case ALARM_ACK -> UpdateMsgType.ALARM_ACK_RPC_MESSAGE;
case ALARM_CLEAR -> UpdateMsgType.ALARM_CLEAR_RPC_MESSAGE; case ALARM_CLEAR -> UpdateMsgType.ALARM_CLEAR_RPC_MESSAGE;
default -> throw new RuntimeException("Unsupported actionType [" + actionType + "]"); default -> throw new RuntimeException("Unsupported actionType [" + actionType + "]");
@ -322,13 +319,10 @@ public abstract class BaseEdgeProcessor {
case TENANT -> edgeCtx.getTenantService().findTenantById(tenantId) != null; case TENANT -> edgeCtx.getTenantService().findTenantById(tenantId) != null;
case DEVICE -> edgeCtx.getDeviceService().findDeviceById(tenantId, new DeviceId(entityId.getId())) != null; case DEVICE -> edgeCtx.getDeviceService().findDeviceById(tenantId, new DeviceId(entityId.getId())) != null;
case ASSET -> edgeCtx.getAssetService().findAssetById(tenantId, new AssetId(entityId.getId())) != null; case ASSET -> edgeCtx.getAssetService().findAssetById(tenantId, new AssetId(entityId.getId())) != null;
case ENTITY_VIEW -> case ENTITY_VIEW -> edgeCtx.getEntityViewService().findEntityViewById(tenantId, new EntityViewId(entityId.getId())) != null;
edgeCtx.getEntityViewService().findEntityViewById(tenantId, new EntityViewId(entityId.getId())) != null; case CUSTOMER -> edgeCtx.getCustomerService().findCustomerById(tenantId, new CustomerId(entityId.getId())) != null;
case CUSTOMER ->
edgeCtx.getCustomerService().findCustomerById(tenantId, new CustomerId(entityId.getId())) != null;
case USER -> edgeCtx.getUserService().findUserById(tenantId, new UserId(entityId.getId())) != null; case USER -> edgeCtx.getUserService().findUserById(tenantId, new UserId(entityId.getId())) != null;
case DASHBOARD -> case DASHBOARD -> edgeCtx.getDashboardService().findDashboardById(tenantId, new DashboardId(entityId.getId())) != null;
edgeCtx.getDashboardService().findDashboardById(tenantId, new DashboardId(entityId.getId())) != null;
case EDGE -> edgeCtx.getEdgeService().findEdgeById(tenantId, new EdgeId(entityId.getId())) != null; case EDGE -> edgeCtx.getEdgeService().findEdgeById(tenantId, new EdgeId(entityId.getId())) != null;
default -> false; default -> false;
}; };

View File

@ -190,6 +190,10 @@ public class ProtoUtils {
builder.setEntityType(edgeEvent.getType().name()); builder.setEntityType(edgeEvent.getType().name());
builder.setAction(edgeEvent.getAction().name()); builder.setAction(edgeEvent.getAction().name());
if (edgeEvent.getEdgeId() != null) {
builder.setEdgeIdMSB(edgeEvent.getEdgeId().getId().getMostSignificantBits());
builder.setEdgeIdLSB(edgeEvent.getEdgeId().getId().getLeastSignificantBits());
}
if (edgeEvent.getEntityId() != null) { if (edgeEvent.getEntityId() != null) {
builder.setEntityIdMSB(edgeEvent.getEntityId().getMostSignificantBits()); builder.setEntityIdMSB(edgeEvent.getEntityId().getMostSignificantBits());
builder.setEntityIdLSB(edgeEvent.getEntityId().getLeastSignificantBits()); builder.setEntityIdLSB(edgeEvent.getEntityId().getLeastSignificantBits());
@ -208,10 +212,12 @@ public class ProtoUtils {
edgeEvent.setType(EdgeEventType.valueOf(proto.getEntityType())); edgeEvent.setType(EdgeEventType.valueOf(proto.getEntityType()));
edgeEvent.setAction(EdgeEventActionType.valueOf(proto.getAction())); edgeEvent.setAction(EdgeEventActionType.valueOf(proto.getAction()));
if (proto.hasEdgeIdMSB() && proto.hasEdgeIdLSB()) {
edgeEvent.setEdgeId(new EdgeId(new UUID(proto.getEdgeIdMSB(), proto.getEdgeIdLSB())));
}
if (proto.hasEntityIdMSB() && proto.hasEntityIdLSB()) { if (proto.hasEntityIdMSB() && proto.hasEntityIdLSB()) {
edgeEvent.setEntityId(new UUID(proto.getEntityIdMSB(), proto.getEntityIdLSB())); edgeEvent.setEntityId(new UUID(proto.getEntityIdMSB(), proto.getEntityIdLSB()));
} }
if (proto.hasBody()) { if (proto.hasBody()) {
edgeEvent.setBody(JacksonUtil.toJsonNode(proto.getBody())); edgeEvent.setBody(JacksonUtil.toJsonNode(proto.getBody()));
} }

View File

@ -1131,9 +1131,11 @@ message EdgeEventMsgProto {
int64 tenantIdLSB = 2; int64 tenantIdLSB = 2;
string entityType = 3; string entityType = 3;
string action = 4; string action = 4;
optional int64 entityIdMSB = 5; optional int64 edgeIdMSB = 5;
optional int64 entityIdLSB = 6; optional int64 edgeIdLSB = 6;
optional string body = 7; optional int64 entityIdMSB = 7;
optional int64 entityIdLSB = 8;
optional string body = 9;
} }
message EdgeNotificationMsgProto { message EdgeNotificationMsgProto {