Skip to content

update startup/shutdown cleanup - #7

Open
roycpro wants to merge 1 commit into
ChannelFinder:masterfrom
roycpro:master
Open

roycpro wants to merge 1 commit into
ChannelFinder:masterfrom
roycpro:master

Conversation

@roycpro

@roycpro roycpro commented Oct 23, 2026

Copy link
Copy Markdown

https://github.com/ControlSystemStudio/phoebus-codeathon/tree/master/projects#services-recsync-003-recceiver-lifecyclestate-cleanup

Should fix:

Reworks how recceiver cleans up its channels in ChannelFinder: delete-on-clean chooses how channels are cleaned, and clean-on-startup / clean-on-shutdown choose when startup and shutdown cleanup happens.

Settings

Setting Default Behaviour
recceiver.cf.delete-on-clean false true: delete channels. false: keep them and update pvStatus. Applies to every cleanup below.
recceiver.cf.clean-on-startup false On startup, clean all of this recceiver's channels: mark them Inactive, or delete them. false: startup doesn't touch ChannelFinder.
recceiver.cf.clean-on-shutdown (new) true On shutdown, clean all of this recceiver's channels: mark them Unknown, or delete them. false: shutdown doesn't touch ChannelFinder.
recceiver.cf.delete-on-shutdown — Removed. Use clean-on-shutdown together with delete-on-clean.

IOC disconnects are always cleaned, as before: their channels are marked Inactive, or deleted when delete-on-clean=true.

private String cfCleanOnStartup;

@Value("${recceiver.cf.delete-on-shutdown:true}")
private String cfDeleteOnShutdown;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are all these options mutually exclusive? Maybe it's better to have a config which is a list of enums.

@shroffk shroffk Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These are not mutually exclusive...kind off...
I think listing them might be too many states.... it might make it even more confusing than what it is
delete-on-startup
mark-inactive-on-startup
do-nothing-on-startup
delete-on-shutdown
mark-unknown-on-shutdown
do-nothing-on-shutdown

I think I like the current:
one flag for startup, one for shutdown, and one which describes if channels should be deleted

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Indeed, I would prefer to keep the 3 parameters.

return channels;
}
Map<String, ChannelFinderChannel> filtered = new LinkedHashMap<>();
for (Map.Entry<String, ChannelFinderChannel> channelEntry : channels.entrySet()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you can use a one liner with stream and filter map and then use parallelStream to improve performance

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok,
this makes sense @copilot

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good idea.
I have updated the code to use the parallelStream.

}
Map<String, ChannelFinderChannel> filtered = new LinkedHashMap<>();
for (Map.Entry<String, ChannelFinderChannel> channelEntry : channels.entrySet()) {
String status = channelEntry.getValue().property(PV_STATUS_PROPERTY);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't you want the filter for receiver id?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

either the startup or the destroy will do that search with the recciever id...line 203 or 619

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Indeed, as @shroffk mentioned, the search by recceiverId is already in place.

* @param channels channels to clean, keyed by name.
* @param statusIfKept pvStatus to write when channels are kept rather than deleted.
*/
private void cleanChannels(Map<String, ChannelFinderChannel> channels, String statusIfKept) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should statusIfKept be a set? Could also be an enum of statuses.

@shroffk shroffk Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmmm...
On one hand I like the idea of a set ("Active","InActive","Unknown")

To argue for the other side... CF property values are just Strings...so...

I am fine with this being a set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually,
I think an enum of statuses is a good idea

@roycpro roycpro Oct 30, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That is a great idea.
I have added a PvStatus enum.

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.

4 participants