itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
}
} else {
- LOG.error("flow add failed for id={}, errors={}", flowId.getValue(), errorsToString(rpcResult.getErrors()));
- }
+ deviceContext.getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
+ LOG.error("flow add failed for id={}, errors={}", flowId.getValue(),
+ errorsToString(rpcResult.getErrors()));
+ }
}
@Override
@Override
public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
- addGroup.getDeviceRegistry().getDeviceGroupRegistry().store(input.getGroupId());
+ deviceContext.getDeviceGroupRegistry().store(input.getGroupId());
final ListenableFuture<RpcResult<AddGroupOutput>> resultFuture = addGroup.handleServiceCall(input);
Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddGroupOutput>>() {
@Override
}
addIfNecessaryToDS(input.getGroupId(), input);
} else {
- LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
- errorsToString(result.getErrors()));
- }
+ deviceContext.getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+ LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
+ errorsToString(result.getErrors()));
+ }
}
@Override
public void onFailure(Throwable t) {
- LOG.error("Service call for group add failed for id={}. Exception: {}",
- input.getGroupId().getValue(), t);
+ deviceContext.getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+ LOG.error("Service call for group add failed for id={}. Exception: {}", input.getGroupId().getValue(), t);
}
});
@Override
public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
- addMeter.getDeviceRegistry().getDeviceMeterRegistry().store(input.getMeterId());
-
+ deviceContext.getDeviceMeterRegistry().store(input.getMeterId());
final ListenableFuture<RpcResult<AddMeterOutput>> resultFuture = addMeter.handleServiceCall(input);
Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddMeterOutput>>() {
-
@Override
public void onSuccess(@Nullable RpcResult<AddMeterOutput> result) {
if (result.isSuccessful()) {
LOG.debug("Meter add finished without error, id={}", input.getMeterId());
}
addIfNecessaryToDS(input.getMeterId(),input);
- }else{
+ } else {
+ deviceContext.getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
LOG.error("Meter add with id {} failed with error {}", input.getMeterId(),
errorsToString(result.getErrors()));
}
@Override
public void onFailure(Throwable t) {
+ deviceContext.getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
}
});