Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 1380471 - Check for timeouts when getting live availability
Browse files Browse the repository at this point in the history
 - Set availability to unknown on timeout
  • Loading branch information
josejulio committed Aug 30, 2017
1 parent ae8a967 commit 803dbc9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Expand Up @@ -18,6 +18,7 @@
*/
package org.rhq.coregui.client.inventory.resource.detail;

import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -221,7 +222,19 @@ public void onFailure(Throwable caught) {
availabilityImage.setSrc(ImageManager.getAvailabilityLargeIconFromAvailType(currentAvail));
badge.setStyleName("resource-detail-" + currentAvail.getName());
if (!UserSessionManager.isLoggedOut()) {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resource_loadFailed(String.valueOf(resource.getId())), caught);
if (caught instanceof com.google.gwt.http.client.RequestTimeoutException) {
// platforms are never unknown, just up or down, so we need to default the availability to a different value
// depending on the resource's category
ResourceAvailability result = new ResourceAvailability(resource,
resource.getResourceType().getCategory() == ResourceCategory.PLATFORM ? AvailabilityType.DOWN
: AvailabilityType.UNKNOWN);
handleResourceAvailability(result);
Message message = new Message(MSG.view_inventory_resource_liveAvailabilityTimeout(),
EnumSet.of(Message.Option.Transient));
CoreGUI.getMessageCenter().notify(message);
} else {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resource_loadFailed(String.valueOf(resource.getId())), caught);
}
}

if (latch != null) {
Expand All @@ -233,17 +246,20 @@ public void onFailure(Throwable caught) {

@Override
public void onSuccess(ResourceAvailability result) {
availabilityImage.setSrc(ImageManager.getAvailabilityLargeIconFromAvailType(currentAvail));
resource.setCurrentAvailability(result);
badge.setStyleName("resource-detail-" + currentAvail.getName());

availabilityImage.markForRedraw();
handleResourceAvailability(result);
if (latch != null) {
latch.countDown();
} else {
markForRedraw();
}

}

private void handleResourceAvailability(ResourceAvailability result) {
availabilityImage.setSrc(ImageManager.getAvailabilityLargeIconFromAvailType(result.getAvailabilityType()));
resource.setCurrentAvailability(result);
badge.setStyleName("resource-detail-" + result.getAvailabilityType().getName());
availabilityImage.markForRedraw();
if (currentAvail != result.getAvailabilityType()) {
platformTree.refreshResource(resource);
}
Expand Down
Expand Up @@ -2011,6 +2011,7 @@ view_inventory_mixed = mixed
view_inventory_platforms = Platforms
view_inventory_problemGroups = Problem Groups
view_inventory_resource_loadFailed = Resource with id [{0}] does not exist or is not accessible
view_inventory_resource_liveAvailabilityTimeout = Unable to obtain resource''s availability.
view_inventory_resources_deleteConfirm = Are you sure you want to delete the selected resources?
view_inventory_resources_deleteFailed = Failed to delete the selected resources.
view_inventory_resources_deleteFailed2 = Failed to delete the selected resources. Cannot connect to the agent. This may indicate that the agent is down.
Expand Down

0 comments on commit 803dbc9

Please sign in to comment.