Skip to content

Commit b754c30

Browse files
authored
Merge pull request #3428 from ControlSystemStudio/pva_echo
PVA search monitor: List PV and client
2 parents 68c455d + 98f3e59 commit b754c30

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

core/pva/src/main/java/org/epics/pva/server/PVASearchMonitorMain.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,22 @@ private static class SearchInfo implements Comparable<SearchInfo>
4040
/** How often some client has searched for it */
4141
final AtomicLong count = new AtomicLong();
4242

43-
/** Client that searched most recently */
44-
volatile InetSocketAddress client;
43+
/** Client that searched for the PV */
44+
final InetSocketAddress client;
4545

4646
/** Time of last search */
4747
volatile Instant last = null;
4848

49-
SearchInfo(final String name)
49+
SearchInfo(final String name, final InetSocketAddress client)
5050
{
5151
this.name = name;
52+
this.client = client;
53+
}
54+
55+
/** @return Key of PV name and client address */
56+
public String getKey()
57+
{
58+
return name + client.toString();
5259
}
5360

5461
/** Sort by search count */
@@ -64,7 +71,7 @@ public int compareTo(final SearchInfo other)
6471
}
6572
}
6673

67-
/** Map of PV name to search info */
74+
/** Map of PV name and client address to search info */
6875
private static final ConcurrentHashMap<String, SearchInfo> searches = new ConcurrentHashMap<>();
6976

7077
private static void help()
@@ -147,10 +154,10 @@ else if (arg.startsWith("-v") && (i+1) < args.length)
147154
if (!once.get() && name.equals("QUIT"))
148155
done.countDown();
149156

150-
final SearchInfo search = searches.computeIfAbsent(name, n -> new SearchInfo(name));
157+
final SearchInfo candidate = new SearchInfo(name, addr);
158+
final SearchInfo search = searches.computeIfAbsent(candidate.getKey(), k -> candidate);
151159
search.count.incrementAndGet();
152160
search.last = Instant.now();
153-
search.client = addr;
154161

155162
// Done, don't proceed with default search handler
156163
return true;

0 commit comments

Comments
 (0)