Commit 4a71e8e6a441d8b580712e3fe3dba2b1ed89ef68
1 parent
6aa5655e
Rename edgeEventAction and edgeEventType to action and type
Showing
6 changed files
with
110 additions
and
110 deletions
@@ -747,65 +747,65 @@ public abstract class BaseController { | @@ -747,65 +747,65 @@ public abstract class BaseController { | ||
747 | return null; | 747 | return null; |
748 | } | 748 | } |
749 | 749 | ||
750 | - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, ActionType edgeEventAction) { | 750 | + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, ActionType action) { |
751 | if (!edgesSupportEnabled) { | 751 | if (!edgesSupportEnabled) { |
752 | return; | 752 | return; |
753 | } | 753 | } |
754 | try { | 754 | try { |
755 | - sendNotificationMsgToEdgeService(tenantId, edgeId, null, json.writeValueAsString(customerId), EdgeEventType.EDGE, edgeEventAction); | 755 | + sendNotificationMsgToEdgeService(tenantId, edgeId, null, json.writeValueAsString(customerId), EdgeEventType.EDGE, action); |
756 | } catch (Exception e) { | 756 | } catch (Exception e) { |
757 | log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e); | 757 | log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e); |
758 | } | 758 | } |
759 | } | 759 | } |
760 | 760 | ||
761 | - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, ActionType edgeEventAction) { | 761 | + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, ActionType action) { |
762 | if (!edgesSupportEnabled) { | 762 | if (!edgesSupportEnabled) { |
763 | return; | 763 | return; |
764 | } | 764 | } |
765 | - EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); | 765 | + EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); |
766 | try { | 766 | try { |
767 | - if (edgeEventType != null) { | ||
768 | - sendNotificationMsgToEdgeService(tenantId, null, entityId, json.writeValueAsString(customerId), edgeEventType, edgeEventAction); | 767 | + if (type != null) { |
768 | + sendNotificationMsgToEdgeService(tenantId, null, entityId, json.writeValueAsString(customerId), type, action); | ||
769 | } | 769 | } |
770 | } catch (Exception e) { | 770 | } catch (Exception e) { |
771 | log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e); | 771 | log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e); |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
775 | - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, ActionType edgeEventAction) { | 775 | + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, ActionType action) { |
776 | if (!edgesSupportEnabled) { | 776 | if (!edgesSupportEnabled) { |
777 | return; | 777 | return; |
778 | } | 778 | } |
779 | try { | 779 | try { |
780 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && | 780 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
781 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { | 781 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
782 | - sendNotificationMsgToEdgeService(tenantId, null, null, json.writeValueAsString(relation), EdgeEventType.RELATION, edgeEventAction); | 782 | + sendNotificationMsgToEdgeService(tenantId, null, null, json.writeValueAsString(relation), EdgeEventType.RELATION, action); |
783 | } | 783 | } |
784 | } catch (Exception e) { | 784 | } catch (Exception e) { |
785 | log.warn("Failed to push relation to core: {}", relation, e); | 785 | log.warn("Failed to push relation to core: {}", relation, e); |
786 | } | 786 | } |
787 | } | 787 | } |
788 | 788 | ||
789 | - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, ActionType edgeEventAction) { | ||
790 | - sendNotificationMsgToEdgeService(tenantId, null, entityId, edgeEventAction); | 789 | + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, ActionType action) { |
790 | + sendNotificationMsgToEdgeService(tenantId, null, entityId, action); | ||
791 | } | 791 | } |
792 | 792 | ||
793 | - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType edgeEventAction) { | 793 | + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType action) { |
794 | if (!edgesSupportEnabled) { | 794 | if (!edgesSupportEnabled) { |
795 | return; | 795 | return; |
796 | } | 796 | } |
797 | - EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); | ||
798 | - if (edgeEventType != null) { | ||
799 | - sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, edgeEventType, edgeEventAction); | 797 | + EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); |
798 | + if (type != null) { | ||
799 | + sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, type, action); | ||
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | - private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String entityBody, EdgeEventType edgeEventType, ActionType edgeEventAction) { | 803 | + private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, ActionType action) { |
804 | TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder(); | 804 | TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder(); |
805 | builder.setTenantIdMSB(tenantId.getId().getMostSignificantBits()); | 805 | builder.setTenantIdMSB(tenantId.getId().getMostSignificantBits()); |
806 | builder.setTenantIdLSB(tenantId.getId().getLeastSignificantBits()); | 806 | builder.setTenantIdLSB(tenantId.getId().getLeastSignificantBits()); |
807 | - builder.setEdgeEventType(edgeEventType.name()); | ||
808 | - builder.setEdgeEventAction(edgeEventAction.name()); | 807 | + builder.setType(type.name()); |
808 | + builder.setAction(action.name()); | ||
809 | if (entityId != null) { | 809 | if (entityId != null) { |
810 | builder.setEntityIdMSB(entityId.getId().getMostSignificantBits()); | 810 | builder.setEntityIdMSB(entityId.getId().getMostSignificantBits()); |
811 | builder.setEntityIdLSB(entityId.getId().getLeastSignificantBits()); | 811 | builder.setEntityIdLSB(entityId.getId().getLeastSignificantBits()); |
@@ -815,8 +815,8 @@ public abstract class BaseController { | @@ -815,8 +815,8 @@ public abstract class BaseController { | ||
815 | builder.setEdgeIdMSB(edgeId.getId().getMostSignificantBits()); | 815 | builder.setEdgeIdMSB(edgeId.getId().getMostSignificantBits()); |
816 | builder.setEdgeIdLSB(edgeId.getId().getLeastSignificantBits()); | 816 | builder.setEdgeIdLSB(edgeId.getId().getLeastSignificantBits()); |
817 | } | 817 | } |
818 | - if (entityBody != null) { | ||
819 | - builder.setEntityBody(entityBody); | 818 | + if (body != null) { |
819 | + builder.setBody(body); | ||
820 | } | 820 | } |
821 | TransportProtos.EdgeNotificationMsgProto msg = builder.build(); | 821 | TransportProtos.EdgeNotificationMsgProto msg = builder.build(); |
822 | tbClusterService.pushMsgToCore(tenantId, entityId != null ? entityId : tenantId, | 822 | tbClusterService.pushMsgToCore(tenantId, entityId != null ? entityId : tenantId, |
@@ -122,22 +122,22 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -122,22 +122,22 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
122 | 122 | ||
123 | private void saveEdgeEvent(TenantId tenantId, | 123 | private void saveEdgeEvent(TenantId tenantId, |
124 | EdgeId edgeId, | 124 | EdgeId edgeId, |
125 | - EdgeEventType edgeEventType, | ||
126 | - ActionType edgeEventAction, | 125 | + EdgeEventType type, |
126 | + ActionType action, | ||
127 | EntityId entityId, | 127 | EntityId entityId, |
128 | - JsonNode entityBody) { | ||
129 | - log.debug("Pushing edge event to edge queue. tenantId [{}], edgeId [{}], edgeEventType [{}], edgeEventAction[{}], entityId [{}], entityBody [{}]", | ||
130 | - tenantId, edgeId, edgeEventType, edgeEventAction, entityId, entityBody); | 128 | + JsonNode body) { |
129 | + log.debug("Pushing edge event to edge queue. tenantId [{}], edgeId [{}], type [{}], action[{}], entityId [{}], body [{}]", | ||
130 | + tenantId, edgeId, type, action, entityId, body); | ||
131 | 131 | ||
132 | EdgeEvent edgeEvent = new EdgeEvent(); | 132 | EdgeEvent edgeEvent = new EdgeEvent(); |
133 | edgeEvent.setEdgeId(edgeId); | 133 | edgeEvent.setEdgeId(edgeId); |
134 | edgeEvent.setTenantId(tenantId); | 134 | edgeEvent.setTenantId(tenantId); |
135 | - edgeEvent.setType(edgeEventType); | ||
136 | - edgeEvent.setAction(edgeEventAction.name()); | 135 | + edgeEvent.setType(type); |
136 | + edgeEvent.setAction(action.name()); | ||
137 | if (entityId != null) { | 137 | if (entityId != null) { |
138 | edgeEvent.setEntityId(entityId.getId()); | 138 | edgeEvent.setEntityId(entityId.getId()); |
139 | } | 139 | } |
140 | - edgeEvent.setBody(entityBody); | 140 | + edgeEvent.setBody(body); |
141 | edgeEventService.saveAsync(edgeEvent); | 141 | edgeEventService.saveAsync(edgeEvent); |
142 | } | 142 | } |
143 | 143 | ||
@@ -145,8 +145,8 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -145,8 +145,8 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
145 | public void pushNotificationToEdge(TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg, TbCallback callback) { | 145 | public void pushNotificationToEdge(TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg, TbCallback callback) { |
146 | try { | 146 | try { |
147 | TenantId tenantId = new TenantId(new UUID(edgeNotificationMsg.getTenantIdMSB(), edgeNotificationMsg.getTenantIdLSB())); | 147 | TenantId tenantId = new TenantId(new UUID(edgeNotificationMsg.getTenantIdMSB(), edgeNotificationMsg.getTenantIdLSB())); |
148 | - EdgeEventType edgeEventType = EdgeEventType.valueOf(edgeNotificationMsg.getEdgeEventType()); | ||
149 | - switch (edgeEventType) { | 148 | + EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); |
149 | + switch (type) { | ||
150 | case EDGE: | 150 | case EDGE: |
151 | processEdge(tenantId, edgeNotificationMsg); | 151 | processEdge(tenantId, edgeNotificationMsg); |
152 | break; | 152 | break; |
@@ -172,7 +172,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -172,7 +172,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
172 | processRelation(tenantId, edgeNotificationMsg); | 172 | processRelation(tenantId, edgeNotificationMsg); |
173 | break; | 173 | break; |
174 | default: | 174 | default: |
175 | - log.debug("Edge event type [{}] is not designed to be pushed to edge", edgeEventType); | 175 | + log.debug("Edge event type [{}] is not designed to be pushed to edge", type); |
176 | } | 176 | } |
177 | } catch (Exception e) { | 177 | } catch (Exception e) { |
178 | callback.onFailure(e); | 178 | callback.onFailure(e); |
@@ -184,12 +184,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -184,12 +184,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
184 | 184 | ||
185 | private void processEdge(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { | 185 | private void processEdge(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { |
186 | try { | 186 | try { |
187 | - ActionType edgeEventActionType = ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction()); | 187 | + ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction()); |
188 | EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); | 188 | EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); |
189 | ListenableFuture<Edge> edgeFuture; | 189 | ListenableFuture<Edge> edgeFuture; |
190 | - switch (edgeEventActionType) { | 190 | + switch (actionType) { |
191 | case ASSIGNED_TO_CUSTOMER: | 191 | case ASSIGNED_TO_CUSTOMER: |
192 | - CustomerId customerId = mapper.readValue(edgeNotificationMsg.getEntityBody(), CustomerId.class); | 192 | + CustomerId customerId = mapper.readValue(edgeNotificationMsg.getBody(), CustomerId.class); |
193 | edgeFuture = edgeService.findEdgeByIdAsync(tenantId, edgeId); | 193 | edgeFuture = edgeService.findEdgeByIdAsync(tenantId, edgeId); |
194 | Futures.addCallback(edgeFuture, new FutureCallback<Edge>() { | 194 | Futures.addCallback(edgeFuture, new FutureCallback<Edge>() { |
195 | @Override | 195 | @Override |
@@ -213,7 +213,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -213,7 +213,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
213 | }, dbCallbackExecutorService); | 213 | }, dbCallbackExecutorService); |
214 | break; | 214 | break; |
215 | case UNASSIGNED_FROM_CUSTOMER: | 215 | case UNASSIGNED_FROM_CUSTOMER: |
216 | - CustomerId customerIdToDelete = mapper.readValue(edgeNotificationMsg.getEntityBody(), CustomerId.class); | 216 | + CustomerId customerIdToDelete = mapper.readValue(edgeNotificationMsg.getBody(), CustomerId.class); |
217 | edgeFuture = edgeService.findEdgeByIdAsync(tenantId, edgeId); | 217 | edgeFuture = edgeService.findEdgeByIdAsync(tenantId, edgeId); |
218 | Futures.addCallback(edgeFuture, new FutureCallback<Edge>() { | 218 | Futures.addCallback(edgeFuture, new FutureCallback<Edge>() { |
219 | @Override | 219 | @Override |
@@ -236,17 +236,17 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -236,17 +236,17 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
236 | } | 236 | } |
237 | 237 | ||
238 | private void processWidgetBundleOrWidgetType(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { | 238 | private void processWidgetBundleOrWidgetType(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { |
239 | - ActionType edgeEventActionType = ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction()); | ||
240 | - EdgeEventType edgeEventType = EdgeEventType.valueOf(edgeNotificationMsg.getEdgeEventType()); | ||
241 | - EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(edgeEventType, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | ||
242 | - switch (edgeEventActionType) { | 239 | + ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction()); |
240 | + EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); | ||
241 | + EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | ||
242 | + switch (actionType) { | ||
243 | case ADDED: | 243 | case ADDED: |
244 | case UPDATED: | 244 | case UPDATED: |
245 | case DELETED: | 245 | case DELETED: |
246 | TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE)); | 246 | TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE)); |
247 | if (edgesByTenantId != null && edgesByTenantId.getData() != null && !edgesByTenantId.getData().isEmpty()) { | 247 | if (edgesByTenantId != null && edgesByTenantId.getData() != null && !edgesByTenantId.getData().isEmpty()) { |
248 | for (Edge edge : edgesByTenantId.getData()) { | 248 | for (Edge edge : edgesByTenantId.getData()) { |
249 | - saveEdgeEvent(tenantId, edge.getId(), edgeEventType, edgeEventActionType, entityId, null); | 249 | + saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | break; | 252 | break; |
@@ -254,20 +254,20 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -254,20 +254,20 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
254 | } | 254 | } |
255 | 255 | ||
256 | private void processCustomer(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { | 256 | private void processCustomer(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { |
257 | - ActionType edgeEventActionType = ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction()); | ||
258 | - EdgeEventType edgeEventType = EdgeEventType.valueOf(edgeNotificationMsg.getEdgeEventType()); | ||
259 | - EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(edgeEventType, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | 257 | + ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction()); |
258 | + EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); | ||
259 | + EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | ||
260 | TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE)); | 260 | TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE)); |
261 | if (edgesByTenantId != null && edgesByTenantId.getData() != null && !edgesByTenantId.getData().isEmpty()) { | 261 | if (edgesByTenantId != null && edgesByTenantId.getData() != null && !edgesByTenantId.getData().isEmpty()) { |
262 | for (Edge edge : edgesByTenantId.getData()) { | 262 | for (Edge edge : edgesByTenantId.getData()) { |
263 | - switch (edgeEventActionType) { | 263 | + switch (actionType) { |
264 | case UPDATED: | 264 | case UPDATED: |
265 | if (!edge.getCustomerId().isNullUid() && edge.getCustomerId().equals(entityId)) { | 265 | if (!edge.getCustomerId().isNullUid() && edge.getCustomerId().equals(entityId)) { |
266 | - saveEdgeEvent(tenantId, edge.getId(), edgeEventType, edgeEventActionType, entityId, null); | 266 | + saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); |
267 | } | 267 | } |
268 | break; | 268 | break; |
269 | case DELETED: | 269 | case DELETED: |
270 | - saveEdgeEvent(tenantId, edge.getId(), edgeEventType, edgeEventActionType, entityId, null); | 270 | + saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); |
271 | break; | 271 | break; |
272 | } | 272 | } |
273 | } | 273 | } |
@@ -275,12 +275,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -275,12 +275,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
275 | } | 275 | } |
276 | 276 | ||
277 | private void processEntity(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { | 277 | private void processEntity(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { |
278 | - ActionType edgeEventActionType = ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction()); | ||
279 | - EdgeEventType edgeEventType = EdgeEventType.valueOf(edgeNotificationMsg.getEdgeEventType()); | ||
280 | - EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(edgeEventType, | 278 | + ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction()); |
279 | + EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); | ||
280 | + EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, | ||
281 | new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | 281 | new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); |
282 | ListenableFuture<List<EdgeId>> edgeIdsFuture; | 282 | ListenableFuture<List<EdgeId>> edgeIdsFuture; |
283 | - switch (edgeEventActionType) { | 283 | + switch (actionType) { |
284 | case ADDED: // used only for USER entity | 284 | case ADDED: // used only for USER entity |
285 | case UPDATED: | 285 | case UPDATED: |
286 | case CREDENTIALS_UPDATED: | 286 | case CREDENTIALS_UPDATED: |
@@ -290,7 +290,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -290,7 +290,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
290 | public void onSuccess(@Nullable List<EdgeId> edgeIds) { | 290 | public void onSuccess(@Nullable List<EdgeId> edgeIds) { |
291 | if (edgeIds != null && !edgeIds.isEmpty()) { | 291 | if (edgeIds != null && !edgeIds.isEmpty()) { |
292 | for (EdgeId edgeId : edgeIds) { | 292 | for (EdgeId edgeId : edgeIds) { |
293 | - saveEdgeEvent(tenantId, edgeId, edgeEventType, edgeEventActionType, entityId, null); | 293 | + saveEdgeEvent(tenantId, edgeId, type, actionType, entityId, null); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | } | 296 | } |
@@ -309,14 +309,14 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -309,14 +309,14 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
309 | if (edgeIds != null && !edgeIds.isEmpty()) { | 309 | if (edgeIds != null && !edgeIds.isEmpty()) { |
310 | for (EdgeId edgeId : edgeIds) { | 310 | for (EdgeId edgeId : edgeIds) { |
311 | try { | 311 | try { |
312 | - CustomerId customerId = mapper.readValue(edgeNotificationMsg.getEntityBody(), CustomerId.class); | 312 | + CustomerId customerId = mapper.readValue(edgeNotificationMsg.getBody(), CustomerId.class); |
313 | ListenableFuture<Edge> future = edgeService.findEdgeByIdAsync(tenantId, edgeId); | 313 | ListenableFuture<Edge> future = edgeService.findEdgeByIdAsync(tenantId, edgeId); |
314 | Futures.addCallback(future, new FutureCallback<Edge>() { | 314 | Futures.addCallback(future, new FutureCallback<Edge>() { |
315 | @Override | 315 | @Override |
316 | public void onSuccess(@Nullable Edge edge) { | 316 | public void onSuccess(@Nullable Edge edge) { |
317 | if (edge != null && edge.getCustomerId() != null && | 317 | if (edge != null && edge.getCustomerId() != null && |
318 | !edge.getCustomerId().isNullUid() && edge.getCustomerId().equals(customerId)) { | 318 | !edge.getCustomerId().isNullUid() && edge.getCustomerId().equals(customerId)) { |
319 | - saveEdgeEvent(tenantId, edgeId, edgeEventType, edgeEventActionType, entityId, null); | 319 | + saveEdgeEvent(tenantId, edgeId, type, actionType, entityId, null); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | @Override | 322 | @Override |
@@ -341,15 +341,15 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -341,15 +341,15 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
341 | TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE)); | 341 | TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE)); |
342 | if (edgesByTenantId != null && edgesByTenantId.getData() != null && !edgesByTenantId.getData().isEmpty()) { | 342 | if (edgesByTenantId != null && edgesByTenantId.getData() != null && !edgesByTenantId.getData().isEmpty()) { |
343 | for (Edge edge : edgesByTenantId.getData()) { | 343 | for (Edge edge : edgesByTenantId.getData()) { |
344 | - saveEdgeEvent(tenantId, edge.getId(), edgeEventType, edgeEventActionType, entityId, null); | 344 | + saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | break; | 347 | break; |
348 | case ASSIGNED_TO_EDGE: | 348 | case ASSIGNED_TO_EDGE: |
349 | case UNASSIGNED_FROM_EDGE: | 349 | case UNASSIGNED_FROM_EDGE: |
350 | EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); | 350 | EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); |
351 | - saveEdgeEvent(tenantId, edgeId, edgeEventType, edgeEventActionType, entityId, null); | ||
352 | - if (edgeEventType.equals(EdgeEventType.RULE_CHAIN)) { | 351 | + saveEdgeEvent(tenantId, edgeId, type, actionType, entityId, null); |
352 | + if (type.equals(EdgeEventType.RULE_CHAIN)) { | ||
353 | updateDependentRuleChains(tenantId, new RuleChainId(entityId.getId()), edgeId); | 353 | updateDependentRuleChains(tenantId, new RuleChainId(entityId.getId()), edgeId); |
354 | } | 354 | } |
355 | break; | 355 | break; |
@@ -395,8 +395,8 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -395,8 +395,8 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
395 | ListenableFuture<Alarm> alarmFuture = alarmService.findAlarmByIdAsync(tenantId, alarmId); | 395 | ListenableFuture<Alarm> alarmFuture = alarmService.findAlarmByIdAsync(tenantId, alarmId); |
396 | Futures.transform(alarmFuture, alarm -> { | 396 | Futures.transform(alarmFuture, alarm -> { |
397 | if (alarm != null) { | 397 | if (alarm != null) { |
398 | - EdgeEventType edgeEventType = getEdgeQueueTypeByEntityType(alarm.getOriginator().getEntityType()); | ||
399 | - if (edgeEventType != null) { | 398 | + EdgeEventType type = getEdgeQueueTypeByEntityType(alarm.getOriginator().getEntityType()); |
399 | + if (type != null) { | ||
400 | ListenableFuture<List<EdgeId>> relatedEdgeIdsByEntityIdFuture = edgeService.findRelatedEdgeIdsByEntityId(tenantId, alarm.getOriginator()); | 400 | ListenableFuture<List<EdgeId>> relatedEdgeIdsByEntityIdFuture = edgeService.findRelatedEdgeIdsByEntityId(tenantId, alarm.getOriginator()); |
401 | Futures.transform(relatedEdgeIdsByEntityIdFuture, relatedEdgeIdsByEntityId -> { | 401 | Futures.transform(relatedEdgeIdsByEntityIdFuture, relatedEdgeIdsByEntityId -> { |
402 | if (relatedEdgeIdsByEntityId != null) { | 402 | if (relatedEdgeIdsByEntityId != null) { |
@@ -404,7 +404,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -404,7 +404,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
404 | saveEdgeEvent(tenantId, | 404 | saveEdgeEvent(tenantId, |
405 | edgeId, | 405 | edgeId, |
406 | EdgeEventType.ALARM, | 406 | EdgeEventType.ALARM, |
407 | - ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction()), | 407 | + ActionType.valueOf(edgeNotificationMsg.getAction()), |
408 | alarmId, | 408 | alarmId, |
409 | null); | 409 | null); |
410 | } | 410 | } |
@@ -418,7 +418,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -418,7 +418,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
418 | } | 418 | } |
419 | 419 | ||
420 | private void processRelation(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) throws JsonProcessingException { | 420 | private void processRelation(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) throws JsonProcessingException { |
421 | - EntityRelation relation = mapper.readValue(edgeNotificationMsg.getEntityBody(), EntityRelation.class); | 421 | + EntityRelation relation = mapper.readValue(edgeNotificationMsg.getBody(), EntityRelation.class); |
422 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && | 422 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
423 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { | 423 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
424 | List<ListenableFuture<List<EdgeId>>> futures = new ArrayList<>(); | 424 | List<ListenableFuture<List<EdgeId>>> futures = new ArrayList<>(); |
@@ -439,7 +439,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -439,7 +439,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
439 | saveEdgeEvent(tenantId, | 439 | saveEdgeEvent(tenantId, |
440 | edgeId, | 440 | edgeId, |
441 | EdgeEventType.RELATION, | 441 | EdgeEventType.RELATION, |
442 | - ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction()), | 442 | + ActionType.valueOf(edgeNotificationMsg.getAction()), |
443 | null, | 443 | null, |
444 | mapper.valueToTree(relation)); | 444 | mapper.valueToTree(relation)); |
445 | } | 445 | } |
@@ -309,8 +309,8 @@ public final class EdgeGrpcSession implements Closeable { | @@ -309,8 +309,8 @@ public final class EdgeGrpcSession implements Closeable { | ||
309 | log.trace("Processing edge event [{}]", edgeEvent); | 309 | log.trace("Processing edge event [{}]", edgeEvent); |
310 | try { | 310 | try { |
311 | DownlinkMsg downlinkMsg = null; | 311 | DownlinkMsg downlinkMsg = null; |
312 | - ActionType edgeEventAction = ActionType.valueOf(edgeEvent.getAction()); | ||
313 | - switch (edgeEventAction) { | 312 | + ActionType action = ActionType.valueOf(edgeEvent.getAction()); |
313 | + switch (action) { | ||
314 | case UPDATED: | 314 | case UPDATED: |
315 | case ADDED: | 315 | case ADDED: |
316 | case DELETED: | 316 | case DELETED: |
@@ -323,7 +323,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -323,7 +323,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
323 | case RELATION_DELETED: | 323 | case RELATION_DELETED: |
324 | case ASSIGNED_TO_CUSTOMER: | 324 | case ASSIGNED_TO_CUSTOMER: |
325 | case UNASSIGNED_FROM_CUSTOMER: | 325 | case UNASSIGNED_FROM_CUSTOMER: |
326 | - downlinkMsg = processEntityMessage(edgeEvent, edgeEventAction); | 326 | + downlinkMsg = processEntityMessage(edgeEvent, action); |
327 | break; | 327 | break; |
328 | case ATTRIBUTES_UPDATED: | 328 | case ATTRIBUTES_UPDATED: |
329 | case ATTRIBUTES_DELETED: | 329 | case ATTRIBUTES_DELETED: |
@@ -444,37 +444,37 @@ public final class EdgeGrpcSession implements Closeable { | @@ -444,37 +444,37 @@ public final class EdgeGrpcSession implements Closeable { | ||
444 | return downlinkMsg; | 444 | return downlinkMsg; |
445 | } | 445 | } |
446 | 446 | ||
447 | - private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, ActionType edgeEventAction) { | 447 | + private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, ActionType action) { |
448 | UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getAction())); | 448 | UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getAction())); |
449 | - log.trace("Executing processEntityMessage, edgeEvent [{}], edgeEventAction [{}], msgType [{}]", edgeEvent, edgeEventAction, msgType); | 449 | + log.trace("Executing processEntityMessage, edgeEvent [{}], action [{}], msgType [{}]", edgeEvent, action, msgType); |
450 | switch (edgeEvent.getType()) { | 450 | switch (edgeEvent.getType()) { |
451 | case EDGE: | 451 | case EDGE: |
452 | // TODO: voba - add edge update logic | 452 | // TODO: voba - add edge update logic |
453 | return null; | 453 | return null; |
454 | case DEVICE: | 454 | case DEVICE: |
455 | - return processDevice(edgeEvent, msgType, edgeEventAction); | 455 | + return processDevice(edgeEvent, msgType, action); |
456 | case ASSET: | 456 | case ASSET: |
457 | - return processAsset(edgeEvent, msgType, edgeEventAction); | 457 | + return processAsset(edgeEvent, msgType, action); |
458 | case ENTITY_VIEW: | 458 | case ENTITY_VIEW: |
459 | - return processEntityView(edgeEvent, msgType, edgeEventAction); | 459 | + return processEntityView(edgeEvent, msgType, action); |
460 | case DASHBOARD: | 460 | case DASHBOARD: |
461 | - return processDashboard(edgeEvent, msgType, edgeEventAction); | 461 | + return processDashboard(edgeEvent, msgType, action); |
462 | case CUSTOMER: | 462 | case CUSTOMER: |
463 | - return processCustomer(edgeEvent, msgType, edgeEventAction); | 463 | + return processCustomer(edgeEvent, msgType, action); |
464 | case RULE_CHAIN: | 464 | case RULE_CHAIN: |
465 | - return processRuleChain(edgeEvent, msgType, edgeEventAction); | 465 | + return processRuleChain(edgeEvent, msgType, action); |
466 | case RULE_CHAIN_METADATA: | 466 | case RULE_CHAIN_METADATA: |
467 | return processRuleChainMetadata(edgeEvent, msgType); | 467 | return processRuleChainMetadata(edgeEvent, msgType); |
468 | case ALARM: | 468 | case ALARM: |
469 | return processAlarm(edgeEvent, msgType); | 469 | return processAlarm(edgeEvent, msgType); |
470 | case USER: | 470 | case USER: |
471 | - return processUser(edgeEvent, msgType, edgeEventAction); | 471 | + return processUser(edgeEvent, msgType, action); |
472 | case RELATION: | 472 | case RELATION: |
473 | return processRelation(edgeEvent, msgType); | 473 | return processRelation(edgeEvent, msgType); |
474 | case WIDGETS_BUNDLE: | 474 | case WIDGETS_BUNDLE: |
475 | - return processWidgetsBundle(edgeEvent, msgType, edgeEventAction); | 475 | + return processWidgetsBundle(edgeEvent, msgType, action); |
476 | case WIDGET_TYPE: | 476 | case WIDGET_TYPE: |
477 | - return processWidgetType(edgeEvent, msgType, edgeEventAction); | 477 | + return processWidgetType(edgeEvent, msgType, action); |
478 | case ADMIN_SETTINGS: | 478 | case ADMIN_SETTINGS: |
479 | return processAdminSettings(edgeEvent); | 479 | return processAdminSettings(edgeEvent); |
480 | default: | 480 | default: |
@@ -524,10 +524,10 @@ public final class EdgeGrpcSession implements Closeable { | @@ -524,10 +524,10 @@ public final class EdgeGrpcSession implements Closeable { | ||
524 | return downlinkMsg; | 524 | return downlinkMsg; |
525 | } | 525 | } |
526 | 526 | ||
527 | - private DownlinkMsg processAsset(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) { | 527 | + private DownlinkMsg processAsset(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) { |
528 | AssetId assetId = new AssetId(edgeEvent.getEntityId()); | 528 | AssetId assetId = new AssetId(edgeEvent.getEntityId()); |
529 | DownlinkMsg downlinkMsg = null; | 529 | DownlinkMsg downlinkMsg = null; |
530 | - switch (edgeEventAction) { | 530 | + switch (action) { |
531 | case ADDED: | 531 | case ADDED: |
532 | case UPDATED: | 532 | case UPDATED: |
533 | case ASSIGNED_TO_EDGE: | 533 | case ASSIGNED_TO_EDGE: |
@@ -555,10 +555,10 @@ public final class EdgeGrpcSession implements Closeable { | @@ -555,10 +555,10 @@ public final class EdgeGrpcSession implements Closeable { | ||
555 | return downlinkMsg; | 555 | return downlinkMsg; |
556 | } | 556 | } |
557 | 557 | ||
558 | - private DownlinkMsg processEntityView(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) { | 558 | + private DownlinkMsg processEntityView(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) { |
559 | EntityViewId entityViewId = new EntityViewId(edgeEvent.getEntityId()); | 559 | EntityViewId entityViewId = new EntityViewId(edgeEvent.getEntityId()); |
560 | DownlinkMsg downlinkMsg = null; | 560 | DownlinkMsg downlinkMsg = null; |
561 | - switch (edgeEventAction) { | 561 | + switch (action) { |
562 | case ADDED: | 562 | case ADDED: |
563 | case UPDATED: | 563 | case UPDATED: |
564 | case ASSIGNED_TO_EDGE: | 564 | case ASSIGNED_TO_EDGE: |
@@ -586,10 +586,10 @@ public final class EdgeGrpcSession implements Closeable { | @@ -586,10 +586,10 @@ public final class EdgeGrpcSession implements Closeable { | ||
586 | return downlinkMsg; | 586 | return downlinkMsg; |
587 | } | 587 | } |
588 | 588 | ||
589 | - private DownlinkMsg processDashboard(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) { | 589 | + private DownlinkMsg processDashboard(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) { |
590 | DashboardId dashboardId = new DashboardId(edgeEvent.getEntityId()); | 590 | DashboardId dashboardId = new DashboardId(edgeEvent.getEntityId()); |
591 | DownlinkMsg downlinkMsg = null; | 591 | DownlinkMsg downlinkMsg = null; |
592 | - switch (edgeEventAction) { | 592 | + switch (action) { |
593 | case ADDED: | 593 | case ADDED: |
594 | case UPDATED: | 594 | case UPDATED: |
595 | case ASSIGNED_TO_EDGE: | 595 | case ASSIGNED_TO_EDGE: |
@@ -620,10 +620,10 @@ public final class EdgeGrpcSession implements Closeable { | @@ -620,10 +620,10 @@ public final class EdgeGrpcSession implements Closeable { | ||
620 | return downlinkMsg; | 620 | return downlinkMsg; |
621 | } | 621 | } |
622 | 622 | ||
623 | - private DownlinkMsg processCustomer(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) { | 623 | + private DownlinkMsg processCustomer(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) { |
624 | CustomerId customerId = new CustomerId(edgeEvent.getEntityId()); | 624 | CustomerId customerId = new CustomerId(edgeEvent.getEntityId()); |
625 | DownlinkMsg downlinkMsg = null; | 625 | DownlinkMsg downlinkMsg = null; |
626 | - switch (edgeEventAction) { | 626 | + switch (action) { |
627 | case ADDED: | 627 | case ADDED: |
628 | case UPDATED: | 628 | case UPDATED: |
629 | Customer customer = ctx.getCustomerService().findCustomerById(edgeEvent.getTenantId(), customerId); | 629 | Customer customer = ctx.getCustomerService().findCustomerById(edgeEvent.getTenantId(), customerId); |
@@ -646,10 +646,10 @@ public final class EdgeGrpcSession implements Closeable { | @@ -646,10 +646,10 @@ public final class EdgeGrpcSession implements Closeable { | ||
646 | return downlinkMsg; | 646 | return downlinkMsg; |
647 | } | 647 | } |
648 | 648 | ||
649 | - private DownlinkMsg processRuleChain(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeEventAction) { | 649 | + private DownlinkMsg processRuleChain(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) { |
650 | RuleChainId ruleChainId = new RuleChainId(edgeEvent.getEntityId()); | 650 | RuleChainId ruleChainId = new RuleChainId(edgeEvent.getEntityId()); |
651 | DownlinkMsg downlinkMsg = null; | 651 | DownlinkMsg downlinkMsg = null; |
652 | - switch (edgeEventAction) { | 652 | + switch (action) { |
653 | case ADDED: | 653 | case ADDED: |
654 | case UPDATED: | 654 | case UPDATED: |
655 | case ASSIGNED_TO_EDGE: | 655 | case ASSIGNED_TO_EDGE: |
@@ -412,8 +412,8 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | @@ -412,8 +412,8 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | ||
412 | EntityId entityId = EntityIdFactory.getByTypeAndUuid( | 412 | EntityId entityId = EntityIdFactory.getByTypeAndUuid( |
413 | EntityType.valueOf(attributesRequestMsg.getEntityType()), | 413 | EntityType.valueOf(attributesRequestMsg.getEntityType()), |
414 | new UUID(attributesRequestMsg.getEntityIdMSB(), attributesRequestMsg.getEntityIdLSB())); | 414 | new UUID(attributesRequestMsg.getEntityIdMSB(), attributesRequestMsg.getEntityIdLSB())); |
415 | - final EdgeEventType edgeEventType = getEdgeQueueTypeByEntityType(entityId.getEntityType()); | ||
416 | - if (edgeEventType != null) { | 415 | + final EdgeEventType type = getEdgeQueueTypeByEntityType(entityId.getEntityType()); |
416 | + if (type != null) { | ||
417 | SettableFuture<Void> futureToSet = SettableFuture.create(); | 417 | SettableFuture<Void> futureToSet = SettableFuture.create(); |
418 | ListenableFuture<List<AttributeKvEntry>> ssAttrFuture = attributesService.findAll(edge.getTenantId(), entityId, DataConstants.SERVER_SCOPE); | 418 | ListenableFuture<List<AttributeKvEntry>> ssAttrFuture = attributesService.findAll(edge.getTenantId(), entityId, DataConstants.SERVER_SCOPE); |
419 | Futures.addCallback(ssAttrFuture, new FutureCallback<List<AttributeKvEntry>>() { | 419 | Futures.addCallback(ssAttrFuture, new FutureCallback<List<AttributeKvEntry>>() { |
@@ -436,14 +436,14 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | @@ -436,14 +436,14 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | ||
436 | } | 436 | } |
437 | entityData.put("kv", attributes); | 437 | entityData.put("kv", attributes); |
438 | entityData.put("scope", DataConstants.SERVER_SCOPE); | 438 | entityData.put("scope", DataConstants.SERVER_SCOPE); |
439 | - JsonNode entityBody = mapper.valueToTree(entityData); | ||
440 | - log.debug("Sending attributes data msg, entityId [{}], attributes [{}]", entityId, entityBody); | 439 | + JsonNode body = mapper.valueToTree(entityData); |
440 | + log.debug("Sending attributes data msg, entityId [{}], attributes [{}]", entityId, body); | ||
441 | saveEdgeEvent(edge.getTenantId(), | 441 | saveEdgeEvent(edge.getTenantId(), |
442 | edge.getId(), | 442 | edge.getId(), |
443 | - edgeEventType, | 443 | + type, |
444 | ActionType.ATTRIBUTES_UPDATED, | 444 | ActionType.ATTRIBUTES_UPDATED, |
445 | entityId, | 445 | entityId, |
446 | - entityBody); | 446 | + body); |
447 | } catch (Exception e) { | 447 | } catch (Exception e) { |
448 | log.error("[{}] Failed to send attribute updates to the edge", edge.getName(), e); | 448 | log.error("[{}] Failed to send attribute updates to the edge", edge.getName(), e); |
449 | throw new RuntimeException("[" + edge.getName() + "] Failed to send attribute updates to the edge", e); | 449 | throw new RuntimeException("[" + edge.getName() + "] Failed to send attribute updates to the edge", e); |
@@ -572,22 +572,22 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | @@ -572,22 +572,22 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | ||
572 | 572 | ||
573 | private ListenableFuture<EdgeEvent> saveEdgeEvent(TenantId tenantId, | 573 | private ListenableFuture<EdgeEvent> saveEdgeEvent(TenantId tenantId, |
574 | EdgeId edgeId, | 574 | EdgeId edgeId, |
575 | - EdgeEventType edgeEventType, | ||
576 | - ActionType edgeEventAction, | 575 | + EdgeEventType type, |
576 | + ActionType action, | ||
577 | EntityId entityId, | 577 | EntityId entityId, |
578 | - JsonNode entityBody) { | ||
579 | - log.debug("Pushing edge event to edge queue. tenantId [{}], edgeId [{}], edgeEventType [{}], edgeEventAction[{}], entityId [{}], entityBody [{}]", | ||
580 | - tenantId, edgeId, edgeEventType, edgeEventAction, entityId, entityBody); | 578 | + JsonNode body) { |
579 | + log.debug("Pushing edge event to edge queue. tenantId [{}], edgeId [{}], type [{}], action[{}], entityId [{}], body [{}]", | ||
580 | + tenantId, edgeId, type, action, entityId, body); | ||
581 | 581 | ||
582 | EdgeEvent edgeEvent = new EdgeEvent(); | 582 | EdgeEvent edgeEvent = new EdgeEvent(); |
583 | edgeEvent.setTenantId(tenantId); | 583 | edgeEvent.setTenantId(tenantId); |
584 | edgeEvent.setEdgeId(edgeId); | 584 | edgeEvent.setEdgeId(edgeId); |
585 | - edgeEvent.setType(edgeEventType); | ||
586 | - edgeEvent.setAction(edgeEventAction.name()); | 585 | + edgeEvent.setType(type); |
586 | + edgeEvent.setAction(action.name()); | ||
587 | if (entityId != null) { | 587 | if (entityId != null) { |
588 | edgeEvent.setEntityId(entityId.getId()); | 588 | edgeEvent.setEntityId(entityId.getId()); |
589 | } | 589 | } |
590 | - edgeEvent.setBody(entityBody); | 590 | + edgeEvent.setBody(body); |
591 | return edgeEventService.saveAsync(edgeEvent); | 591 | return edgeEventService.saveAsync(edgeEvent); |
592 | } | 592 | } |
593 | } | 593 | } |
@@ -91,23 +91,23 @@ public abstract class BaseProcessor { | @@ -91,23 +91,23 @@ public abstract class BaseProcessor { | ||
91 | 91 | ||
92 | protected ListenableFuture<EdgeEvent> saveEdgeEvent(TenantId tenantId, | 92 | protected ListenableFuture<EdgeEvent> saveEdgeEvent(TenantId tenantId, |
93 | EdgeId edgeId, | 93 | EdgeId edgeId, |
94 | - EdgeEventType edgeEventType, | ||
95 | - ActionType edgeEventAction, | 94 | + EdgeEventType type, |
95 | + ActionType action, | ||
96 | EntityId entityId, | 96 | EntityId entityId, |
97 | - JsonNode entityBody) { | ||
98 | - log.debug("Pushing event to edge queue. tenantId [{}], edgeId [{}], edgeEventType[{}], " + | ||
99 | - "edgeEventAction [{}], entityId [{}], entityBody [{}]", | ||
100 | - tenantId, edgeId, edgeEventType, edgeEventAction, entityId, entityBody); | 97 | + JsonNode body) { |
98 | + log.debug("Pushing event to edge queue. tenantId [{}], edgeId [{}], type[{}], " + | ||
99 | + "action [{}], entityId [{}], body [{}]", | ||
100 | + tenantId, edgeId, type, action, entityId, body); | ||
101 | 101 | ||
102 | EdgeEvent edgeEvent = new EdgeEvent(); | 102 | EdgeEvent edgeEvent = new EdgeEvent(); |
103 | edgeEvent.setTenantId(tenantId); | 103 | edgeEvent.setTenantId(tenantId); |
104 | edgeEvent.setEdgeId(edgeId); | 104 | edgeEvent.setEdgeId(edgeId); |
105 | - edgeEvent.setType(edgeEventType); | ||
106 | - edgeEvent.setAction(edgeEventAction.name()); | 105 | + edgeEvent.setType(type); |
106 | + edgeEvent.setAction(action.name()); | ||
107 | if (entityId != null) { | 107 | if (entityId != null) { |
108 | edgeEvent.setEntityId(entityId.getId()); | 108 | edgeEvent.setEntityId(entityId.getId()); |
109 | } | 109 | } |
110 | - edgeEvent.setBody(entityBody); | 110 | + edgeEvent.setBody(body); |
111 | return edgeEventService.saveAsync(edgeEvent); | 111 | return edgeEventService.saveAsync(edgeEvent); |
112 | } | 112 | } |
113 | } | 113 | } |
@@ -357,12 +357,12 @@ message EdgeNotificationMsgProto { | @@ -357,12 +357,12 @@ message EdgeNotificationMsgProto { | ||
357 | int64 tenantIdLSB = 2; | 357 | int64 tenantIdLSB = 2; |
358 | int64 edgeIdMSB = 3; | 358 | int64 edgeIdMSB = 3; |
359 | int64 edgeIdLSB = 4; | 359 | int64 edgeIdLSB = 4; |
360 | - string edgeEventType = 5; | ||
361 | - string edgeEventAction = 6; | 360 | + string type = 5; |
361 | + string action = 6; | ||
362 | int64 entityIdMSB = 7; | 362 | int64 entityIdMSB = 7; |
363 | int64 entityIdLSB = 8; | 363 | int64 entityIdLSB = 8; |
364 | string entityType = 9; | 364 | string entityType = 9; |
365 | - string entityBody = 10; | 365 | + string body = 10; |
366 | PostTelemetryMsg postTelemetryMsg = 11; | 366 | PostTelemetryMsg postTelemetryMsg = 11; |
367 | PostAttributeMsg postAttributesMsg = 12; | 367 | PostAttributeMsg postAttributesMsg = 12; |
368 | } | 368 | } |