-
Couldn't load subscription status.
- Fork 36
Fix/36265 pa fsm #1229
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
base: master
Are you sure you want to change the base?
Fix/36265 pa fsm #1229
Conversation
cf61378 to
5c1bd96
Compare
…esources after unit test completes
4ff7b05 to
d3ba8de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. I hold a few concerns.
| } | ||
| return errorResponse(new AdapterFailedSchemaValidationError(errorMessages.toErrorList())); | ||
| } | ||
| }).orElseGet(adapterNotFoundError(adapterId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adapterNotFoundError(adapterId) to be in a function.
| log.error("Failed to restart adapter '{}'.", adapterId, throwable); | ||
| } else { | ||
| log.trace("Adapter '{}' was restarted successfully.", adapterId); | ||
| log.info("Adapter '{}' was restarted successfully.", adapterId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be trace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually has an information character.
I would suggest keeping it at info.
These operations are very low frequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I asked this question is the other similar logging statements are all trace ones, but this one is info.
hivemq-edge/src/main/java/com/hivemq/fsm/ProtocolAdapterFSM.java
Outdated
Show resolved
Hide resolved
hivemq-edge/src/main/java/com/hivemq/fsm/ProtocolAdapterFSM.java
Outdated
Show resolved
Hide resolved
hivemq-edge/src/main/java/com/hivemq/fsm/ProtocolAdapterFSM.java
Outdated
Show resolved
Hide resolved
| try { | ||
| subscription.delete(); | ||
| } catch (final Exception e) { | ||
| log.warn("Failed to delete subscription {}: {}", subscription, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better log the error stack.
| try { | ||
| client.removeSubscription(subscription); | ||
| } catch (final Exception e) { | ||
| log.warn("Failed to remove subscription {}: {}", subscription, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better log the error stack.
| try { | ||
| client.removeFaultListener(faultListener); | ||
| } catch (final Throwable e) { | ||
| log.error("Failed to remove fault listener {}: {}", faultListener, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better log the error stack.
| try { | ||
| client.removeSessionActivityListener(activityListener); | ||
| } catch (final Throwable e) { | ||
| log.error("Failed to remove session activity listener {}: {}", activityListener, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better log the error stack.
| client.disconnect(); | ||
| log.info("Successfully disconnected OPC UA client"); | ||
| } catch (final UaException e) { | ||
| log.error("Failed to disconnect: {}", e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better log the error stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion.
| } catch (final Exception e) { | ||
| log.error("Error closing HikariCP datasource", e); | ||
| } finally { | ||
| ds = null; // Clear reference to allow GC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion. ds = null; should be executed among all branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion.
… hot reload for mappings and tags (cheaper). will see how this improves stability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hold some concerns.
| StateEnum.ERROR_CLOSING, Set.of(StateEnum.ERROR), | ||
| StateEnum.ERROR, Set.of(StateEnum.CONNECTING, StateEnum.DISCONNECTED), // can recover from error | ||
| StateEnum.CLOSED, Set.of(StateEnum.DISCONNECTED, StateEnum.CLOSING) // can restart from closed or go to closing | ||
| public static final @NotNull Map<StateEnum, Set<StateEnum>> possibleTransitions = Map.of(StateEnum.DISCONNECTED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose java.util.function.Function<StateEnum, StateEnum> with switch-case inside can outperform this Map.
| * @param tags the new tags | ||
| */ | ||
| public void setTags(final @NotNull List<? extends Tag> tags) { | ||
| this.tags = tags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there locking mechanism for protecting these lists? Is it possible the multiple adapters are accessing these lists in parallel?
| .whenComplete((result, throwable) -> { | ||
| if (throwable != null) { | ||
| log.error("Error starting adapter", throwable); | ||
| stopProtocolAdapterOnFailedStart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During this call stopProtocolAdapterOnFailedStart(), currentStartFuture is not null. Is that the expected behavior?
Also if the exception is from the previous throw new RuntimeException("Failed to start consumers", startException);, stopProtocolAdapterOnFailedStart() will be called twice. Is that the expected behavior?
| // Transition southbound state to indicate shutdown in progress | ||
| final StateEnum currentSouthboundState = currentState().southbound(); | ||
| if (currentSouthboundState == StateEnum.CONNECTED) { | ||
| transitionSouthboundState(StateEnum.DISCONNECTING); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these transitions atomic?
card: https://hivemq.kanbanize.com/ctrl_board/57/cards/37501/details/