Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reconnection capabilities for the test client. #216

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

belagertem
Copy link
Collaborator

@belagertem belagertem commented Nov 5, 2024

Reconnection attempts on connection loss can be enabled in the test client.

Checklist

The following aspects have been respected by the author of this pull request, confirmed by both pull request assignee and reviewer:

  • Adherence to coding conventions
    • Pull Request Assignee
    • Reviewer
  • Adherence to javadoc conventions
    • Pull Request Assignee
    • Reviewer
  • Changelog update (necessity checked and entry added or not added respectively)
    • Pull Request Assignee
    • Reviewer
  • README update (necessity checked and entry added or not added respectively)
    • Pull Request Assignee
    • Reviewer
  • config update (necessity checked and entry added or not added respectively)
    • Pull Request Assignee
    • Reviewer
  • SDCcc executable ran against a test device (if necessary)
    • Pull Request Assignee
    • Reviewer

@belagertem belagertem requested a review from ldeichmann November 5, 2024 14:34
@belagertem belagertem self-assigned this Nov 5, 2024
LOG.debug("Attempted to access a connection-dependent object while the connection is interrupted, "
+ "wait for connection to be re-established.");
try {
lock.wait();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calling thread does not always get awakened, especially when this wait is called after the notifyAll, but before inReconnectProcess gets set back to false, which is possible, because inReconnectProcess gets set outside of the respective synchronized block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inReconnectProcess is set in the synchronized block now

@@ -384,12 +435,12 @@ public SdcRemoteDevicesConnector getConnector() {

@Override
public SdcRemoteDevice getSdcRemoteDevice() {
return sdcRemoteDevice;
return restrictedGetter(sdcRemoteDevice);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return the old object after a wait and not the new one, which matters alot because the reconnect potentially replaces its value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the restrictedGetter implementation, the new object should be returned now

this.roomSearchLogString,
this.bedSearchLogString,
e);
if (inReconnectProcess.get()) {
Copy link
Collaborator

@maximilianpilz maximilianpilz Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the concept work, inReconnectProcess would probably have to be used in many more cases and functions similiarly to how it is used here and also it would have to be thread id aware.

For example I got a TimeoutException in https://github.com/Draegerwerk/SDCcc/pull/216/files#diff-955d82d123e93ce4675e6524a4b941f007756b1589cfb87114b82fffa9e2d181R380 during a reconnect and although the reconnect was successful on the second attempt, the test run still got invalidated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a whitelist to the log appender to not invalid the test run during reconnect.

}

@Override
public void shouldReconnect(final Boolean shouldReconnect) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this with false as a parameter may lead to log messages from before to not be affected by the respective whitelist as they should, because of them potentially being processed in the appender, which is using the whitelist being set, too late e.g. after this returns.

}

@Override
public void shouldReconnect(final Boolean shouldReconnect) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear when to call this with false as its parameter value, I think it should be restricted to when all of the following are true:

  1. all log messages of whitelisted threads have been fully processed
  2. the maximum amount of retries occurred without a successful one, or, there was a successful try and no further ones will occur
  3. the expected behaviour e.g. a disconnect was observed at least once

Perhaps this should be checked here or else some convenience function provided to wait for these events before calling this function.

} else {
LOG.info("Watchdog detected expected disconnect from provider.");
LOG.info("The disconnect from provider was expected.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG.info("The disconnect from provider was expected.");
LOG.info("The disconnect from the provider was expected.");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants