Search in sources :

Example 6 with ToTransportMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.

the class DeviceActorMessageProcessor method processUplinkNotificationMsg.

private void processUplinkNotificationMsg(TbActorCtx context, SessionInfoProto sessionInfo, TransportProtos.UplinkNotificationMsg uplinkNotificationMsg) {
    String nodeId = sessionInfo.getNodeId();
    sessions.entrySet().stream().filter(kv -> kv.getValue().getSessionInfo().getNodeId().equals(nodeId) && (kv.getValue().isSubscribedToAttributes() || kv.getValue().isSubscribedToRPC())).forEach(kv -> {
        ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(kv.getKey().getMostSignificantBits()).setSessionIdLSB(kv.getKey().getLeastSignificantBits()).setUplinkNotificationMsg(uplinkNotificationMsg).build();
        systemContext.getTbCoreToTransportService().process(kv.getValue().getSessionInfo().getNodeId(), msg);
    });
}
Also used : Arrays(java.util.Arrays) RpcStatus(org.thingsboard.server.common.data.rpc.RpcStatus) KeyValueType(org.thingsboard.server.gen.transport.TransportProtos.KeyValueType) ToDeviceRpcRequestActorMsg(org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg) TenantId(org.thingsboard.server.common.data.id.TenantId) TbMsgMetaData(org.thingsboard.server.common.msg.TbMsgMetaData) EntityRelation(org.thingsboard.server.common.data.relation.EntityRelation) AttributeKvEntry(org.thingsboard.server.common.data.kv.AttributeKvEntry) SessionType(org.thingsboard.server.gen.transport.TransportProtos.SessionType) FromDeviceRpcResponseActorMsg(org.thingsboard.server.service.rpc.FromDeviceRpcResponseActorMsg) ActorSystemContext(org.thingsboard.server.actors.ActorSystemContext) Rpc(org.thingsboard.server.common.data.rpc.Rpc) AbstractContextAwareMsgProcessor(org.thingsboard.server.actors.shared.AbstractContextAwareMsgProcessor) SubscribeToAttributeUpdatesMsg(org.thingsboard.server.gen.transport.TransportProtos.SubscribeToAttributeUpdatesMsg) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) DeviceAttributesEventNotificationMsg(org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg) DeviceCredentialsUpdateNotificationMsg(org.thingsboard.rule.engine.api.msg.DeviceCredentialsUpdateNotificationMsg) EdgeId(org.thingsboard.server.common.data.id.EdgeId) GetAttributeResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.GetAttributeResponseMsg) TransportToDeviceActorMsg(org.thingsboard.server.gen.transport.TransportProtos.TransportToDeviceActorMsg) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ClaimDeviceMsg(org.thingsboard.server.gen.transport.TransportProtos.ClaimDeviceMsg) DeviceId(org.thingsboard.server.common.data.id.DeviceId) PageLink(org.thingsboard.server.common.data.page.PageLink) ToTransportUpdateCredentialsProto(org.thingsboard.server.gen.transport.TransportProtos.ToTransportUpdateCredentialsProto) StringUtils(org.thingsboard.server.common.data.StringUtils) Set(java.util.Set) TbActorCtx(org.thingsboard.server.actors.TbActorCtx) UUID(java.util.UUID) SortOrder(org.thingsboard.server.common.data.page.SortOrder) Collectors(java.util.stream.Collectors) EdgeEventActionType(org.thingsboard.server.common.data.edge.EdgeEventActionType) ToServerRpcResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ToServerRpcResponseMsg) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) SubscribeToRPCMsg(org.thingsboard.server.gen.transport.TransportProtos.SubscribeToRPCMsg) TbActorMsg(org.thingsboard.server.common.msg.TbActorMsg) KvEntry(org.thingsboard.server.common.data.kv.KvEntry) DeviceNameOrTypeUpdateMsg(org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg) TransportProtos(org.thingsboard.server.gen.transport.TransportProtos) GetAttributeRequestMsg(org.thingsboard.server.gen.transport.TransportProtos.GetAttributeRequestMsg) Optional(java.util.Optional) ToDeviceRpcRequestBody(org.thingsboard.server.common.data.rpc.ToDeviceRpcRequestBody) RemoveRpcActorMsg(org.thingsboard.server.service.rpc.RemoveRpcActorMsg) ConcurrentModificationException(java.util.ConcurrentModificationException) AttributeUpdateNotificationMsg(org.thingsboard.server.gen.transport.TransportProtos.AttributeUpdateNotificationMsg) DeviceActorServerSideRpcTimeoutMsg(org.thingsboard.server.common.msg.timeout.DeviceActorServerSideRpcTimeoutMsg) ToDeviceRpcRequestMsg(org.thingsboard.server.gen.transport.TransportProtos.ToDeviceRpcRequestMsg) TransportToDeviceActorMsgWrapper(org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ToDeviceRpcResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ToDeviceRpcResponseMsg) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ToDeviceRpcRequest(org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest) Device(org.thingsboard.server.common.data.Device) JacksonUtil(org.thingsboard.common.util.JacksonUtil) HashMap(java.util.HashMap) DeviceEdgeUpdateMsg(org.thingsboard.rule.engine.api.msg.DeviceEdgeUpdateMsg) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SessionSubscriptionInfoProto(org.thingsboard.server.gen.transport.TransportProtos.SessionSubscriptionInfoProto) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) LinkedHashMapRemoveEldest(org.thingsboard.common.util.LinkedHashMapRemoveEldest) CollectionUtils(org.apache.commons.collections.CollectionUtils) SessionCloseNotificationProto(org.thingsboard.server.gen.transport.TransportProtos.SessionCloseNotificationProto) KeyValueProto(org.thingsboard.server.gen.transport.TransportProtos.KeyValueProto) SessionEvent(org.thingsboard.server.gen.transport.TransportProtos.SessionEvent) DeviceSessionsCacheEntry(org.thingsboard.server.gen.transport.TransportProtos.DeviceSessionsCacheEntry) TbCallback(org.thingsboard.server.common.msg.queue.TbCallback) Nullable(javax.annotation.Nullable) AttributeKey(org.thingsboard.server.common.data.kv.AttributeKey) DataConstants(org.thingsboard.server.common.data.DataConstants) RpcId(org.thingsboard.server.common.data.id.RpcId) FromDeviceRpcResponse(org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse) DeviceCredentialsType(org.thingsboard.server.common.data.security.DeviceCredentialsType) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials) SessionEventMsg(org.thingsboard.server.gen.transport.TransportProtos.SessionEventMsg) SessionInfoProto(org.thingsboard.server.gen.transport.TransportProtos.SessionInfoProto) RpcError(org.thingsboard.server.common.data.rpc.RpcError) FutureCallback(com.google.common.util.concurrent.FutureCallback) TsKvProto(org.thingsboard.server.gen.transport.TransportProtos.TsKvProto) Consumer(java.util.function.Consumer) SubscriptionInfoProto(org.thingsboard.server.gen.transport.TransportProtos.SubscriptionInfoProto) ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg) Futures(com.google.common.util.concurrent.Futures) PageData(org.thingsboard.server.common.data.page.PageData) EdgeEvent(org.thingsboard.server.common.data.edge.EdgeEvent) EdgeEventType(org.thingsboard.server.common.data.edge.EdgeEventType) RelationTypeGroup(org.thingsboard.server.common.data.relation.RelationTypeGroup) ToDeviceRpcResponseStatusMsg(org.thingsboard.server.gen.transport.TransportProtos.ToDeviceRpcResponseStatusMsg) Collections(java.util.Collections) ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)

Example 7 with ToTransportMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.

the class DeviceActorMessageProcessor method notifyTransportAboutDeviceCredentialsUpdate.

void notifyTransportAboutDeviceCredentialsUpdate(UUID sessionId, SessionInfoMetaData sessionMd, DeviceCredentials deviceCredentials) {
    ToTransportUpdateCredentialsProto.Builder notification = ToTransportUpdateCredentialsProto.newBuilder();
    notification.addCredentialsId(deviceCredentials.getCredentialsId());
    notification.addCredentialsValue(deviceCredentials.getCredentialsValue());
    ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setToTransportUpdateCredentialsNotification(notification).build();
    systemContext.getTbCoreToTransportService().process(sessionMd.getSessionInfo().getNodeId(), msg);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg) ToTransportUpdateCredentialsProto(org.thingsboard.server.gen.transport.TransportProtos.ToTransportUpdateCredentialsProto)

Example 8 with ToTransportMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.

the class DeviceActorMessageProcessor method sendToTransport.

private void sendToTransport(GetAttributeResponseMsg responseMsg, SessionInfoProto sessionInfo) {
    ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionInfo.getSessionIdMSB()).setSessionIdLSB(sessionInfo.getSessionIdLSB()).setGetAttributesResponse(responseMsg).build();
    systemContext.getTbCoreToTransportService().process(sessionInfo.getNodeId(), msg);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)

Example 9 with ToTransportMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.

the class DeviceActorMessageProcessor method notifyTransportAboutClosedSession.

private void notifyTransportAboutClosedSession(UUID sessionId, SessionInfoMetaData sessionMd, String message) {
    SessionCloseNotificationProto sessionCloseNotificationProto = SessionCloseNotificationProto.newBuilder().setMessage(message).build();
    ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setSessionCloseNotification(sessionCloseNotificationProto).build();
    systemContext.getTbCoreToTransportService().process(sessionMd.getSessionInfo().getNodeId(), msg);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg) SessionCloseNotificationProto(org.thingsboard.server.gen.transport.TransportProtos.SessionCloseNotificationProto)

Example 10 with ToTransportMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg in project thingsboard by thingsboard.

the class DefaultTbClusterService method broadcastEntityChangeToTransport.

public <T> void broadcastEntityChangeToTransport(TenantId tenantId, EntityId entityid, T entity, TbQueueCallback callback) {
    String entityName = (entity instanceof HasName) ? ((HasName) entity).getName() : entity.getClass().getName();
    log.trace("[{}][{}][{}] Processing [{}] change event", tenantId, entityid.getEntityType(), entityid.getId(), entityName);
    TransportProtos.EntityUpdateMsg entityUpdateMsg = TransportProtos.EntityUpdateMsg.newBuilder().setEntityType(entityid.getEntityType().name()).setData(ByteString.copyFrom(encodingService.encode(entity))).build();
    ToTransportMsg transportMsg = ToTransportMsg.newBuilder().setEntityUpdateMsg(entityUpdateMsg).build();
    broadcast(transportMsg, callback);
}
Also used : HasName(org.thingsboard.server.common.data.HasName) ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg) TransportProtos(org.thingsboard.server.gen.transport.TransportProtos) ByteString(com.google.protobuf.ByteString)

Aggregations

ToTransportMsg (org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)12 TransportProtos (org.thingsboard.server.gen.transport.TransportProtos)5 UUID (java.util.UUID)2 TenantId (org.thingsboard.server.common.data.id.TenantId)2 SessionCloseNotificationProto (org.thingsboard.server.gen.transport.TransportProtos.SessionCloseNotificationProto)2 ToTransportUpdateCredentialsProto (org.thingsboard.server.gen.transport.TransportProtos.ToTransportUpdateCredentialsProto)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1