Search in sources :

Example 1 with HasName

use of org.thingsboard.server.common.data.HasName 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

ByteString (com.google.protobuf.ByteString)1 HasName (org.thingsboard.server.common.data.HasName)1 TransportProtos (org.thingsboard.server.gen.transport.TransportProtos)1 ToTransportMsg (org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg)1