Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Azores <aazores@redhat.com>
  • Loading branch information
andrewazores committed Mar 16, 2023
1 parent 3a9f077 commit 0b772b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/main/java/io/cryostat/net/AgentConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,7 @@ public Optional<Document> getXml(String name, TemplateType type)

@Override
public boolean isConnected() {
try {
return client.ping().toCompletionStage().toCompletableFuture().get();
} catch (ExecutionException | InterruptedException e) {
logger.warn(e);
return false;
}
return true;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/cryostat/net/TargetConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ private JFRConnection connect(ConnectionDescriptor connectionDescriptor) throws
URI uri = URI.create(connectionDescriptor.getTargetId());
String scheme = uri.getScheme();
if (Set.of("http", "https", "cryostat-agent").contains(scheme)) {
return agentConnectionFactory.get().createConnection(uri);
AgentConnection agent = agentConnectionFactory.get().createConnection(uri);
// agent connections don't need to be opened and closed as each method call just maps to
// an HTTP request. This performs a basic HTTP GET to ensure the agent is reachable
agent.connect();
return agent;
} else {
try {
return attemptConnectAsJMXServiceURL(connectionDescriptor);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/cryostat/net/web/WebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ public String getAssetDownloadURL(ApiVersion apiVersion, String... pathSegments)
}

private String getTargetId(JFRConnection conn) throws IOException {
// TODO this is a hack
// TODO this is a hack, the JFRConnection interface should be refactored to expose a more
// general connection URL / targetId method since the JMX implementation is now only one
// possible implementation
if (conn instanceof AgentConnection) {
return ((AgentConnection) conn).getUri().toString();
}
Expand Down

0 comments on commit 0b772b3

Please sign in to comment.