|
@@ -116,6 +116,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
|
@@ -116,6 +116,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
116
|
|
116
|
|
117
|
@Override
|
117
|
@Override
|
118
|
public void saveAndNotify(TenantId tenantId, EntityId entityId, List<TsKvEntry> ts, long ttl, FutureCallback<Void> callback) {
|
118
|
public void saveAndNotify(TenantId tenantId, EntityId entityId, List<TsKvEntry> ts, long ttl, FutureCallback<Void> callback) {
|
|
|
119
|
+ checkInternalEntity(entityId);
|
|
|
120
|
+ saveAndNotifyInternal(tenantId, entityId, ts, ttl, callback);
|
|
|
121
|
+ }
|
|
|
122
|
+
|
|
|
123
|
+ @Override
|
|
|
124
|
+ public void saveAndNotifyInternal(TenantId tenantId, EntityId entityId, List<TsKvEntry> ts, long ttl, FutureCallback<Void> callback) {
|
119
|
ListenableFuture<List<Void>> saveFuture = tsService.save(tenantId, entityId, ts, ttl);
|
125
|
ListenableFuture<List<Void>> saveFuture = tsService.save(tenantId, entityId, ts, ttl);
|
120
|
addMainCallback(saveFuture, callback);
|
126
|
addMainCallback(saveFuture, callback);
|
121
|
addWsCallback(saveFuture, success -> onTimeSeriesUpdate(tenantId, entityId, ts));
|
127
|
addWsCallback(saveFuture, success -> onTimeSeriesUpdate(tenantId, entityId, ts));
|
|
@@ -176,6 +182,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
|
@@ -176,6 +182,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
176
|
|
182
|
|
177
|
@Override
|
183
|
@Override
|
178
|
public void saveAndNotify(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes, boolean notifyDevice, FutureCallback<Void> callback) {
|
184
|
public void saveAndNotify(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes, boolean notifyDevice, FutureCallback<Void> callback) {
|
|
|
185
|
+ checkInternalEntity(entityId);
|
|
|
186
|
+ saveAndNotifyInternal(tenantId, entityId, scope, attributes, notifyDevice, callback);
|
|
|
187
|
+ }
|
|
|
188
|
+
|
|
|
189
|
+ @Override
|
|
|
190
|
+ public void saveAndNotifyInternal(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes, boolean notifyDevice, FutureCallback<Void> callback) {
|
179
|
ListenableFuture<List<Void>> saveFuture = attrService.save(tenantId, entityId, scope, attributes);
|
191
|
ListenableFuture<List<Void>> saveFuture = attrService.save(tenantId, entityId, scope, attributes);
|
180
|
addMainCallback(saveFuture, callback);
|
192
|
addMainCallback(saveFuture, callback);
|
181
|
addWsCallback(saveFuture, success -> onAttributesUpdate(tenantId, entityId, scope, attributes, notifyDevice));
|
193
|
addWsCallback(saveFuture, success -> onAttributesUpdate(tenantId, entityId, scope, attributes, notifyDevice));
|
|
@@ -183,6 +195,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
|
@@ -183,6 +195,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
183
|
|
195
|
|
184
|
@Override
|
196
|
@Override
|
185
|
public void saveLatestAndNotify(TenantId tenantId, EntityId entityId, List<TsKvEntry> ts, FutureCallback<Void> callback) {
|
197
|
public void saveLatestAndNotify(TenantId tenantId, EntityId entityId, List<TsKvEntry> ts, FutureCallback<Void> callback) {
|
|
|
198
|
+ checkInternalEntity(entityId);
|
|
|
199
|
+ saveLatestAndNotifyInternal(tenantId, entityId, ts, callback);
|
|
|
200
|
+ }
|
|
|
201
|
+
|
|
|
202
|
+ @Override
|
|
|
203
|
+ public void saveLatestAndNotifyInternal(TenantId tenantId, EntityId entityId, List<TsKvEntry> ts, FutureCallback<Void> callback) {
|
186
|
ListenableFuture<List<Void>> saveFuture = tsService.saveLatest(tenantId, entityId, ts);
|
204
|
ListenableFuture<List<Void>> saveFuture = tsService.saveLatest(tenantId, entityId, ts);
|
187
|
addMainCallback(saveFuture, callback);
|
205
|
addMainCallback(saveFuture, callback);
|
188
|
addWsCallback(saveFuture, success -> onTimeSeriesUpdate(tenantId, entityId, ts));
|
206
|
addWsCallback(saveFuture, success -> onTimeSeriesUpdate(tenantId, entityId, ts));
|
|
@@ -190,6 +208,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
|
@@ -190,6 +208,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
190
|
|
208
|
|
191
|
@Override
|
209
|
@Override
|
192
|
public void deleteAndNotify(TenantId tenantId, EntityId entityId, String scope, List<String> keys, FutureCallback<Void> callback) {
|
210
|
public void deleteAndNotify(TenantId tenantId, EntityId entityId, String scope, List<String> keys, FutureCallback<Void> callback) {
|
|
|
211
|
+ checkInternalEntity(entityId);
|
|
|
212
|
+ deleteAndNotifyInternal(tenantId, entityId, scope, keys, callback);
|
|
|
213
|
+ }
|
|
|
214
|
+
|
|
|
215
|
+ @Override
|
|
|
216
|
+ public void deleteAndNotifyInternal(TenantId tenantId, EntityId entityId, String scope, List<String> keys, FutureCallback<Void> callback) {
|
193
|
ListenableFuture<List<Void>> deleteFuture = attrService.removeAll(tenantId, entityId, scope, keys);
|
217
|
ListenableFuture<List<Void>> deleteFuture = attrService.removeAll(tenantId, entityId, scope, keys);
|
194
|
addMainCallback(deleteFuture, callback);
|
218
|
addMainCallback(deleteFuture, callback);
|
195
|
addWsCallback(deleteFuture, success -> onAttributesDelete(tenantId, entityId, scope, keys));
|
219
|
addWsCallback(deleteFuture, success -> onAttributesDelete(tenantId, entityId, scope, keys));
|
|
@@ -197,6 +221,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
|
@@ -197,6 +221,12 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
197
|
|
221
|
|
198
|
@Override
|
222
|
@Override
|
199
|
public void deleteLatest(TenantId tenantId, EntityId entityId, List<String> keys, FutureCallback<Void> callback) {
|
223
|
public void deleteLatest(TenantId tenantId, EntityId entityId, List<String> keys, FutureCallback<Void> callback) {
|
|
|
224
|
+ checkInternalEntity(entityId);
|
|
|
225
|
+ deleteLatestInternal(tenantId, entityId, keys, callback);
|
|
|
226
|
+ }
|
|
|
227
|
+
|
|
|
228
|
+ @Override
|
|
|
229
|
+ public void deleteLatestInternal(TenantId tenantId, EntityId entityId, List<String> keys, FutureCallback<Void> callback) {
|
200
|
ListenableFuture<List<Void>> deleteFuture = tsService.removeLatest(tenantId, entityId, keys);
|
230
|
ListenableFuture<List<Void>> deleteFuture = tsService.removeLatest(tenantId, entityId, keys);
|
201
|
addMainCallback(deleteFuture, callback);
|
231
|
addMainCallback(deleteFuture, callback);
|
202
|
}
|
232
|
}
|
|
@@ -296,4 +326,11 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
|
@@ -296,4 +326,11 @@ public class DefaultTelemetrySubscriptionService extends AbstractSubscriptionSer |
296
|
}
|
326
|
}
|
297
|
}, tsCallBackExecutor);
|
327
|
}, tsCallBackExecutor);
|
298
|
}
|
328
|
}
|
|
|
329
|
+
|
|
|
330
|
+ private void checkInternalEntity(EntityId entityId) {
|
|
|
331
|
+ if (EntityType.API_USAGE_STATE.equals(entityId.getEntityType())) {
|
|
|
332
|
+ throw new RuntimeException("Can't update API Usage State!");
|
|
|
333
|
+ }
|
|
|
334
|
+ }
|
|
|
335
|
+
|
299
|
} |
336
|
} |