form.setMargin(10);
form.setWidth100();
form.setWrapItemTitles(false);
form.setNumCols(2);
final StaticTextItem nameItem = new StaticTextItem(FIELD_ADDRESS.propertyName(), FIELD_ADDRESS.title());
nameItem.setValue("<b>" + storageNode.getAddress() + "</b>");
final StaticTextItem cqlPortItem = new StaticTextItem(FIELD_CQL_PORT.propertyName(), FIELD_CQL_PORT.title());
cqlPortItem.setValue(storageNode.getCqlPort());
jmxPortItem = new StaticTextItem("jmxPort", MSG.view_adminTopology_storageNodes_settings_jmxPortName());
final StaticTextItem operationModeItem = new StaticTextItem(FIELD_OPERATION_MODE.propertyName(),
FIELD_OPERATION_MODE.title());
operationModeItem.setValue(storageNode.getOperationMode());
final StaticTextItem clusterStatusItem = new StaticTextItem(FIELD_STATUS.propertyName(), FIELD_STATUS.title());
clusterStatusItem.setValue(storageNode.getStatus().toString());
final StaticTextItem availabilityItem = new StaticTextItem(FIELD_AVAILABILITY.propertyName(),
FIELD_AVAILABILITY.title());
// make clickable link to associated resource
StaticTextItem resourceItem = new StaticTextItem("associatedResource",
MSG.view_adminTopology_storageNodes_detail_associatedResource());
String storageNodeItemText = "";
String availabilityItemText = imgHTML(ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.UNKNOWN));
Resource storageNodeResource = storageNode.getResource();
if (storageNodeResource != null && storageNodeResource.getName() != null) {
String detailsUrl = LinkManager.getResourceLink(storageNodeResource.getId());
String formattedValue = StringUtility.escapeHtml(storageNodeResource.getName());
storageNodeItemText = LinkManager.getHref(detailsUrl, formattedValue);
// set the availability
ResourceAvailability availability = storageNodeResource.getCurrentAvailability();
if (storageNodeResource.getCurrentAvailability() != null
&& storageNodeResource.getCurrentAvailability().getAvailabilityType() != null) {
availabilityItemText = imgHTML(ImageManager.getAvailabilityIconFromAvailType(availability
.getAvailabilityType()));
}
} else {
storageNodeItemText = MSG.common_label_none();
}
resourceItem.setValue(storageNodeItemText);
availabilityItem.setValue(availabilityItemText);
StaticTextItem installationDateItem = new StaticTextItem(FIELD_CTIME.propertyName(), FIELD_CTIME.title());
installationDateItem.setValue(TimestampCellFormatter.format(Long.valueOf(storageNode.getCtime()),
TimestampCellFormatter.DATE_TIME_FORMAT_LONG));
StaticTextItem lastUpdateItem = new StaticTextItem(FIELD_MTIME.propertyName(), FIELD_MTIME.title());
lastUpdateItem.setValue(TimestampCellFormatter.format(Long.valueOf(storageNode.getMtime()),
TimestampCellFormatter.DATE_TIME_FORMAT_LONG));
alertsItem = new StaticTextItem(FIELD_ALERTS.propertyName(), FIELD_ALERTS.title());
alertsItem.setPrompt(MSG.view_adminTopology_storageNodes_detail_unackAlertsHover());
if (unackAlerts != -1) {
alertsItem.setValue(StorageNodeAdminView.getAlertsString(MSG.view_adminTopology_storageNodes_unackAlerts(),
storageNodeId, unackAlerts));
}
StaticTextItem messageItem = new StaticTextItem("message", MSG.view_adminTopology_storageNodes_detail_note());
StringBuffer message = new StringBuffer();
boolean isOk = true;
OperationMode operationMode = storageNode.getOperationMode();
boolean joining = operationMode == OperationMode.ANNOUNCE || operationMode == OperationMode.BOOTSTRAP
|| operationMode == OperationMode.ADD_MAINTENANCE;
boolean leaving = operationMode == OperationMode.DECOMMISSION || operationMode == OperationMode.UNANNOUNCE
|| operationMode == OperationMode.REMOVE_MAINTENANCE || operationMode == OperationMode.UNINSTALL;
if (storageNode.getResource() == null) {
message.append(MSG.view_adminTopology_storageNodes_detail_noResource() + "<br />");
isOk = false;
}
if (storageNode.getErrorMessage() != null) {
String noteTextPrefix = (joining ? MSG.view_adminTopology_storageNodes_detail_errorDeployment() + ": "
: (leaving ? MSG.view_adminTopology_storageNodes_detail_errorUndeployment() + ": " : ""));
message.append(noteTextPrefix);
message.append(storageNode.getErrorMessage()).append("<br />");
isOk = false;
} else if (storageNode.getFailedOperation() != null) {
message.append(MSG.view_adminTopology_storageNodes_detail_errorLastOperationFailed());
isOk = false;
}
if (isOk) {
message.append(MSG.view_adminTopology_storageNodes_detail_ok());
}
messageItem.setValue(message.toString());
StaticTextItem lastOperation = null;
StaticTextItem lastOperationAck = null;
boolean isOperationFailed = storageNode.getFailedOperation() != null
&& storageNode.getFailedOperation().getResource() != null;
if (isOperationFailed) {
ResourceOperationHistory operationHistory = storageNode.getFailedOperation();
String value = LinkManager.getSubsystemResourceOperationHistoryLink(operationHistory.getResource().getId(),
operationHistory.getId());
lastOperation = new StaticTextItem("lastOp", MSG.view_operationHistoryDetails_operation());
String operationTextPrefix = (joining ? MSG.view_adminTopology_storageNodes_detail_errorFailedDeployOp()
+ ": " : (leaving ? MSG.view_adminTopology_storageNodes_detail_errorFailedUneployOp() + ": " : ""));
lastOperation.setValue(operationTextPrefix
+ LinkManager.getHref(value, operationHistory.getOperationDefinition().getDisplayName()));
}
List<FormItem> formItems = new ArrayList<FormItem>(6);
formItems.addAll(Arrays.asList(nameItem, resourceItem, availabilityItem, cqlPortItem, jmxPortItem));
if (!CoreGUI.isDebugMode()) {
formItems.add(operationModeItem); // debug mode fails if this item is added
}
formItems.addAll(Arrays
.asList(clusterStatusItem, installationDateItem, lastUpdateItem, alertsItem, messageItem));
if (isOperationFailed) {
formItems.add(lastOperation);
}
if (null != storageNode.getErrorMessage() || null != storageNode.getFailedOperation()) {
lastOperationAck = new StaticTextItem("lastOpAck", "");
lastOperationAck.setValue("<span style='color: #0099D3;'>" + MSG.common_button_ack() + "</span>");
lastOperationAck.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ackFailedOperation(storageNode);
}
});