Skip to content

Commit

Permalink
Move the amazon credentials check at startup into an async thread (#1543
Browse files Browse the repository at this point in the history
)

* Move the amazon credentials check at startup into an async thread

* Profiling showed it was adding about half a second at startup
---------

Co-authored-by: jrobinso <[email protected]>
  • Loading branch information
lbergelson and jrobinso authored Aug 14, 2024
1 parent b730c8a commit d372765
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/broad/igv/ui/IGVMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ private List<AbstractButton> createMenus() {
log.error("Error creating google menu: " + e.getMessage());
}

try {
AWSMenu = createAWSMenu();
AWSMenu.setVisible(AmazonUtils.isAwsProviderPresent());
menus.add(AWSMenu);
} catch (IOException e) {
log.error("Error creating the Amazon AWS menu: " + e.getMessage());
AWSMenu.setVisible(false);
}

AWSMenu = createAWSMenu();
AWSMenu.setVisible(false);
menus.add(AWSMenu);
//detecting the provider is slow, do it in another thread
LongRunningTask.submit(this::updateAWSMenu);



menus.add(createHelpMenu());

Expand All @@ -211,7 +211,7 @@ private List<AbstractButton> createMenus() {
}

public void updateAWSMenu() {
AWSMenu.setVisible(AmazonUtils.isAwsProviderPresent());
SwingUtilities.invokeLater(() -> AWSMenu.setVisible(AmazonUtils.isAwsProviderPresent()));
}

/**
Expand Down Expand Up @@ -963,7 +963,7 @@ public void actionPerformed(ActionEvent actionEvent) {
return menu;
}

private JMenu createAWSMenu() throws IOException {
private JMenu createAWSMenu() {

boolean usingCognito = AmazonUtils.GetCognitoConfig() != null;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/broad/igv/util/AmazonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static JsonObject GetCognitoConfig() {


/**
* Test to see if aws credentials are avaialable, either through IGV configuration of Cognito, or from the
* Test to see if aws credentials are available, either through IGV configuration of Cognito, or from the
* default provider chain. See https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default
*
* @return
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/broad/igv/util/LongRunningTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
*
* @author jrobinso
*/
public class LongRunningTask implements Callable {
public class LongRunningTask implements Callable<Void> {

private static Logger log = LogManager.getLogger(LongRunningTask.class);
private static final Logger log = LogManager.getLogger(LongRunningTask.class);

private static final ExecutorService threadExecutor = Executors.newFixedThreadPool(5);

Expand All @@ -52,7 +52,7 @@ public static Executor getThreadExecutor() {
return threadExecutor;
}

public static Future submit(Runnable runnable) {
public static Future<Void> submit(Runnable runnable) {
if (Globals.isBatch()) {
runnable.run();
return null;
Expand All @@ -65,7 +65,8 @@ private LongRunningTask(Runnable runnable) {
this.runnable = runnable;
}

public Object call() {
@Override
public Void call() {

CursorToken token = WaitCursorManager.showWaitCursor();
try {
Expand Down

0 comments on commit d372765

Please sign in to comment.