Skip to content

Add pvget servlet#34

Closed
wanglin86769 wants to merge 4 commits intoornl-epics:mainfrom
wanglin86769:add-pvget-servlet
Closed

Add pvget servlet#34
wanglin86769 wants to merge 4 commits intoornl-epics:mainfrom
wanglin86769:add-pvget-servlet

Conversation

@wanglin86769
Copy link

At one workshop section hosted by @shroffk at the Spring 2025 EPICS Collaboration Meeting this month, it seemed that a few developers were interested in adding pvget REST API to pvws, and it is the reason why this PR is created.

The implementation of the servlet is as follows,

  1. It asynchronously reads a value from the given PV(s) with retry logic.
  2. Single PV value can be fetched via query parameter "?pv=pvname" and JSON object will be returned.
  3. Multiple PV values can be fetched together via query parameter "?pv=pvname1,pvname2,pvname3" and JSON array will be returned.
  4. For simplicity, raw data instead of base64 encoding are returned for array value.

@wanglin86769
Copy link
Author

Thanks for the comments, previously simulated PVs were not taken into account.

Now the following modifications have been made,

  1. Pass in a JSON array of PV names instead of splitting by commas
  2. Add a timeout for task execution
  3. Break the retrying loop only if asyncRead() returns non-null value, but the behavior of asyncRead() for simulated PVs looks weird to me and I have created an issue in the Phoebus repo
    org.phoebus.pv.PV.asyncRead() throws exception for real PVs but returns null for simulated PVs when connection not established ControlSystemStudio/phoebus#3385

@kasemir
Copy link
Collaborator

kasemir commented Apr 30, 2025

You should not look for a non-null value but use PV.isDisconnected to check the value.
See more elaborate comments in ControlSystemStudio/phoebus#3385

} else {
// Handle multiple PV requests using a thread pool for concurrent processing.
int numberOfThreads = 100; // Set a large number of threads for I/O-bound tasks.
ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you creating a new thread pool for 100 threads each time the servlet is called?!?

@kasemir
Copy link
Collaborator

kasemir commented Apr 30, 2025

See also https://github.com/ControlSystemStudio/phoebus/blob/20dd0cce58b3cd9e52dda92ec02affb80dba51b1/core/pv/src/test/java/org/phoebus/pv/ReactivePVTest.java#L57 for example that creates PV, gets single value, releases.

That will most efficiently get you the current value, using the value we received last for a known PV.

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