Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer log messages when Ice connects #14

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions src/main/java/qupath/ext/omero/core/pixelapis/ice/IceAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import qupath.lib.images.servers.PixelType;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -131,30 +132,14 @@ public PixelAPIReader createReader(long id, ImageServerMetadata metadata) throws
throw new IllegalArgumentException("The provided image cannot be read by this API");
}

return new IceReader(
List.of(
new LoginCredentials(
sessionUuid,
sessionUuid,
apisHandler.getWebServerURI().getHost(),
apisHandler.getServerPort()
),
new LoginCredentials(
sessionUuid,
sessionUuid,
apisHandler.getServerURI(),
apisHandler.getServerPort()
),
new LoginCredentials(
sessionUuid,
sessionUuid,
serverAddress.get(),
serverPort.get()
)
),
id,
metadata.getChannels()
);
List<LoginCredentials> credentials = new ArrayList<>();
credentials.add(new LoginCredentials(sessionUuid, sessionUuid, apisHandler.getWebServerURI().getHost(), apisHandler.getServerPort()));
credentials.add(new LoginCredentials(sessionUuid, sessionUuid, apisHandler.getServerURI(), apisHandler.getServerPort()));
if (serverAddress.get() != null) {
credentials.add(new LoginCredentials(sessionUuid, sessionUuid, serverAddress.get(), serverPort.get()));
}

return new IceReader(credentials, id, metadata.getChannels());
}

@Override
Expand Down
24 changes: 17 additions & 7 deletions src/main/java/qupath/ext/omero/core/pixelapis/ice/IceReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,25 @@ public String toString() {
}

private Optional<ExperimenterData> connect(List<LoginCredentials> loginCredentials) {
for (LoginCredentials loginCredential: loginCredentials) {
for (int i=0; i<loginCredentials.size(); i++) {
try {
return Optional.ofNullable(gateway.connect(loginCredential));
return Optional.ofNullable(gateway.connect(loginCredentials.get(i)));
} catch (Exception e) {
logger.info(String.format(
"Can't connect to %s:%d",
loginCredential.getServer().getHost(),
loginCredential.getServer().getPort()
), e);
if (i < loginCredentials.size()-1) {
logger.warn(String.format(
"Ice can't connect to %s:%d. Trying %s:%d...",
loginCredentials.get(i).getServer().getHost(),
loginCredentials.get(i).getServer().getPort(),
loginCredentials.get(i+1).getServer().getHost(),
loginCredentials.get(i+1).getServer().getPort()
), e);
} else {
logger.warn(String.format(
"Ice can't connect to %s:%d. No more credentials available",
loginCredentials.get(i).getServer().getHost(),
loginCredentials.get(i).getServer().getPort()
), e);
}
}
}
return Optional.empty();
Expand Down
Loading