|
|
|
@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.google.common.util.concurrent.FutureCallback; |
|
|
|
import com.google.common.util.concurrent.Futures; |
|
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
|
import com.google.common.util.concurrent.MoreExecutors; |
|
|
|
import com.google.common.util.concurrent.SettableFuture; |
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
@ -127,11 +126,12 @@ public abstract class BaseTelemetryProcessor extends BaseEdgeProcessor { |
|
|
|
CustomerId customerId = pair.getValue(); |
|
|
|
metaData.putValue(DataConstants.MSG_SOURCE_KEY, getMsgSourceKey()); |
|
|
|
if (entityData.hasPostAttributesMsg()) { |
|
|
|
metaData.putValue(DataConstants.SCOPE, entityData.getPostAttributeScope()); |
|
|
|
long ts = entityData.hasAttributeTs() ? entityData.getAttributeTs() : System.currentTimeMillis(); |
|
|
|
result.add(processPostAttributes(tenantId, customerId, entityId, entityData.getPostAttributesMsg(), metaData, ts)); |
|
|
|
} |
|
|
|
if (entityData.hasAttributesUpdatedMsg()) { |
|
|
|
metaData.putValue("scope", entityData.getPostAttributeScope()); |
|
|
|
metaData.putValue(DataConstants.SCOPE, entityData.getPostAttributeScope()); |
|
|
|
long ts = entityData.hasAttributeTs() ? entityData.getAttributeTs() : System.currentTimeMillis(); |
|
|
|
result.add(processAttributesUpdate(tenantId, customerId, entityId, entityData.getAttributesUpdatedMsg(), metaData, ts)); |
|
|
|
} |
|
|
|
@ -265,8 +265,9 @@ public abstract class BaseTelemetryProcessor extends BaseEdgeProcessor { |
|
|
|
TransportProtos.PostAttributeMsg msg, TbMsgMetaData metaData, long ts) throws Exception { |
|
|
|
SettableFuture<Void> futureToSet = SettableFuture.create(); |
|
|
|
JsonObject json = JsonUtils.getJsonObject(msg.getKvList()); |
|
|
|
AttributeScope scope = AttributeScope.valueOf(metaData.getValue(DataConstants.SCOPE)); |
|
|
|
List<AttributeKvEntry> attributes = new ArrayList<>(JsonConverter.convertToAttributes(json, ts)); |
|
|
|
ListenableFuture<List<AttributeKvEntry>> future = filterAttributesByTs(tenantId, entityId, AttributeScope.CLIENT_SCOPE, attributes); |
|
|
|
ListenableFuture<List<AttributeKvEntry>> future = filterAttributesByTs(tenantId, entityId, scope, attributes); |
|
|
|
Futures.addCallback(future, new FutureCallback<>() { |
|
|
|
@Override |
|
|
|
public void onSuccess(List<AttributeKvEntry> attributesToSave) { |
|
|
|
@ -312,7 +313,7 @@ public abstract class BaseTelemetryProcessor extends BaseEdgeProcessor { |
|
|
|
long ts) { |
|
|
|
SettableFuture<Void> futureToSet = SettableFuture.create(); |
|
|
|
JsonObject json = JsonUtils.getJsonObject(msg.getKvList()); |
|
|
|
AttributeScope scope = AttributeScope.valueOf(metaData.getValue("scope")); |
|
|
|
AttributeScope scope = AttributeScope.valueOf(metaData.getValue(DataConstants.SCOPE)); |
|
|
|
List<AttributeKvEntry> attributes = new ArrayList<>(JsonConverter.convertToAttributes(json, ts)); |
|
|
|
ListenableFuture<List<AttributeKvEntry>> future = filterAttributesByTs(tenantId, entityId, scope, attributes); |
|
|
|
Futures.addCallback(future, new FutureCallback<>() { |
|
|
|
|