Skip to content

Commit 67eff8c

Browse files
committed
Updates based on peer feedback
1 parent 338d863 commit 67eff8c

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryCalenderViewController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public Void call(Appointment appointment) {
194194

195195
search.disableProperty().bind(searchInProgress);
196196

197-
determineConnectivity(() -> {
197+
determineConnectivity(connectivityMode -> {
198+
connectivityModeObjectProperty.set(connectivityMode);
198199
switch (connectivityModeObjectProperty.get()){
199200
case HTTP_ONLY -> search();
200201
case WEB_SOCKETS_SUPPORTED -> connectWebSocket();

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,9 @@ public void updateItem(TableViewListItem logEntry, boolean empty) {
332332
Messages.AdvancedSearchHide : Messages.AdvancedSearchOpen,
333333
advancedSearchVisible));
334334

335-
determineConnectivity(() -> {
336-
switch (connectivityModeObjectProperty.get()){
335+
determineConnectivity(connectivityMode -> {
336+
connectivityModeObjectProperty.set(connectivityMode);
337+
switch (connectivityMode){
337338
case HTTP_ONLY -> search();
338339
case WEB_SOCKETS_SUPPORTED -> connectWebSocket();
339340
}

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogbookSearchController.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,30 @@ public LogbookSearchController() {
8888
* Determines how the client may connect to the remote service. The service info endpoint is called to establish
8989
* availability of the service. If available, then a single web socket connection is attempted to determine
9090
* if the service supports web sockets.
91-
* @param completionHandler {@link Runnable} called when connection mode has been determined.
91+
* @param consumer {@link Consumer} called when the connectivity mode has been determined.
9292
*/
93-
protected void determineConnectivity(Runnable completionHandler){
93+
protected void determineConnectivity(Consumer<ConnectivityMode> consumer){
9494

9595
// Try to determine the connection mode: is the remote service available at all?
9696
// If so, does it accept web socket connections?
9797
JobManager.schedule("Connection mode probe", monitor -> {
98+
ConnectivityMode connectivityMode = ConnectivityMode.NOT_CONNECTED;
9899
String serviceInfo = client.serviceInfo();
99100
if (serviceInfo != null && !serviceInfo.isEmpty()) { // service online, check web socket availability
100101
if (WebSocketClientService.checkAvailability(this.webSocketConnectUrl)) {
101-
connectivityModeObjectProperty.set(ConnectivityMode.WEB_SOCKETS_SUPPORTED);
102+
connectivityMode = ConnectivityMode.WEB_SOCKETS_SUPPORTED;
102103
} else {
103-
connectivityModeObjectProperty.set(ConnectivityMode.HTTP_ONLY);
104+
connectivityMode = ConnectivityMode.HTTP_ONLY;
104105
}
105106
}
106107
connectivityCheckerCountDownLatch.countDown();
107-
if (connectivityModeObjectProperty.get().equals(ConnectivityMode.NOT_CONNECTED)) {
108+
consumer.accept(connectivityMode);
109+
if (connectivityMode.equals(ConnectivityMode.NOT_CONNECTED)) {
108110
Platform.runLater(() -> {
109111
errorPane.visibleProperty().set(true);
110112
viewSearchPane.visibleProperty().set(false);
111113
});
112114
}
113-
completionHandler.run();
114115
});
115116
}
116117

@@ -180,7 +181,7 @@ public void shutdown() {
180181
webSocketClientService.removeWebSocketMessageHandler(this);
181182
webSocketClientService.shutdown();
182183
}
183-
if(connectivityModeObjectProperty.get().equals(ConnectivityMode.HTTP_ONLY)){
184+
else if(connectivityModeObjectProperty.get().equals(ConnectivityMode.HTTP_ONLY)){
184185
cancelPeriodSearch();
185186
}
186187
}

core/websocket/src/main/java/org/phoebus/core/websocket/springframework/WebSocketClientService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public void disconnect() {
138138
* Disconnects the socket if connected and terminates connection thread.
139139
*/
140140
public void shutdown() {
141-
disconnect();
142141
attemptReconnect.set(false);
142+
disconnect();
143143
}
144144

145145
/**

0 commit comments

Comments
 (0)