[shelly] Add additional syncing to Shelly2ApiRc#20386
[shelly] Add additional syncing to Shelly2ApiRc#20386markus7017 wants to merge 1 commit intoopenhab:mainfrom
Conversation
Signed-off-by: Markus Michels <markus7017@gmail.com>
|
@markus7017 It will take some time to analyze is properly, but after a quick glance, it doesn't look bad. The problem/challenge as I see it, is the inheritance of the classes. Remember that any instance is the result of the class and all superclasses combined, which means that to make one thread-safe, you must handle the superclasses too. We have: So, to make this thread-safe, you really have to deal with all of these classes. It might be slightly complicated. |
|
I suggest that we start with Looking at it, I see: protected int timeoutErrors = 0;
protected int timeoutsRecovered = 0;But, I can't see that the information gathered is used anywhere. It's a bit of a strange thing to keep track of, what can you possibly use that information for? I mean, these are sums of errors/recovery across all requests for a device. The number of requests isn't counted, nor is the time - so you have no context to decide if this is "little" or "much". What is the idea? Is it better to just remove them, than to try to make them thread-safe? |
I think this is a longer journey and splitter in multiple PRs. Do you see a risk to just merge this PR. It doesn't solve the issues completely, but would add some level of improvement. Then we could proceed module by module, which also creates a clerar scope for each PR |
It's hard to evaluate what the consequences of having some things thread-safe and some things not is. I can't really say, I never do it that way. I'm not sure that the "journey" is that long, but maybe, I can't really tell until I dive into the details. If you want to do it in multiple PRs, I would start with |
| String uid = thing.getUID().getAsString(); | ||
| thingTable.addThing(uid, handler); | ||
| logger.debug("Thing handler for uid {} added, total things = {}", uid, thingTable.size()); | ||
| return handler; |
There was a problem hiding this comment.
How did this happen? Was it a mistake in the previous PR? I can't work if it always returns null, so it can't have been like this.
There was a problem hiding this comment.
Other PR was merged. I would expect this to be remvoed from the PR or a conflict.
Those are just statistical values, updated in ShellyHttpClient.httpRequest(). They are displayed by ShellyManager in the WebView and are an indicator for an unstable WiFi connection or other issues when communicating with the device. |
O, then I would say we leave this one open and starte with |
Ping me from the new PR about this, the reason I asked is because syncing them will mean a lot of sync blocks. I can't see that they are read anywhere, so how does the WebView get them? I'm wondering if it would be best to use |
Some more improvements on thread-safety.
@Nadahar Could you check while I'm running longer tests. I'm not sure about synchronized on disconnect(), reconnect(), close() method level.