Search in sources :

Example 1 with ToTransportMsg

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

the class DefaultTbCoreToTransportService method process.

@Override
public void process(String nodeId, ToTransportMsg msg, Runnable onSuccess, Consumer<Throwable> onFailure) {
    if (nodeId == null || nodeId.isEmpty()) {
        log.trace("process: skipping message without nodeId [{}], (ToTransportMsg) msg [{}]", nodeId, msg);
        if (onSuccess != null) {
            onSuccess.run();
        }
        return;
    }
    TopicPartitionInfo tpi = partitionService.getNotificationsTopic(ServiceType.TB_TRANSPORT, nodeId);
    UUID sessionId = new UUID(msg.getSessionIdMSB(), msg.getSessionIdLSB());
    log.trace("[{}][{}] Pushing session data to topic: {}", tpi.getFullTopicName(), sessionId, msg);
    TbProtoQueueMsg<ToTransportMsg> queueMsg = new TbProtoQueueMsg<>(NULL_UUID, msg);
    tbTransportProducer.send(tpi, queueMsg, new QueueCallbackAdaptor(onSuccess, onFailure));
}
Also used : TopicPartitionInfo(org.thingsboard.server.common.msg.queue.TopicPartitionInfo) TbProtoQueueMsg(org.thingsboard.server.queue.common.TbProtoQueueMsg) ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg) NULL_UUID(org.thingsboard.server.dao.model.ModelConstants.NULL_UUID) UUID(java.util.UUID)

Example 2 with ToTransportMsg

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

the class DeviceActorMessageProcessor method sendToTransport.

private void sendToTransport(ToDeviceRpcRequestMsg rpcMsg, UUID sessionId, String nodeId) {
    ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setToDeviceRequest(rpcMsg).build();
    systemContext.getTbCoreToTransportService().process(nodeId, msg);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)

Example 3 with ToTransportMsg

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

the class DeviceActorMessageProcessor method sendToTransport.

private void sendToTransport(ToServerRpcResponseMsg rpcMsg, UUID sessionId, String nodeId) {
    ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setToServerResponse(rpcMsg).build();
    systemContext.getTbCoreToTransportService().process(nodeId, msg);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)

Example 4 with ToTransportMsg

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

the class DeviceActorMessageProcessor method sendToTransport.

private void sendToTransport(AttributeUpdateNotificationMsg notificationMsg, UUID sessionId, String nodeId) {
    ToTransportMsg msg = ToTransportMsg.newBuilder().setSessionIdMSB(sessionId.getMostSignificantBits()).setSessionIdLSB(sessionId.getLeastSignificantBits()).setAttributeUpdateNotification(notificationMsg).build();
    systemContext.getTbCoreToTransportService().process(nodeId, msg);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)

Example 5 with ToTransportMsg

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

the class DefaultTbClusterService method onResourceDeleted.

@Override
public void onResourceDeleted(TbResource resource, TbQueueCallback callback) {
    log.trace("[{}] Processing delete resource", resource);
    TransportProtos.ResourceDeleteMsg resourceUpdateMsg = TransportProtos.ResourceDeleteMsg.newBuilder().setTenantIdMSB(resource.getTenantId().getId().getMostSignificantBits()).setTenantIdLSB(resource.getTenantId().getId().getLeastSignificantBits()).setResourceType(resource.getResourceType().name()).setResourceKey(resource.getResourceKey()).build();
    ToTransportMsg transportMsg = ToTransportMsg.newBuilder().setResourceDeleteMsg(resourceUpdateMsg).build();
    broadcast(transportMsg, callback);
}
Also used : ToTransportMsg(org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg) TransportProtos(org.thingsboard.server.gen.transport.TransportProtos)

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