mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-16 10:48:47 +00:00
bug6242: first demo of new replication panel table
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
package com.sap.sse.gwt.adminconsole;
|
||||
|
||||
import com.sap.sse.gwt.client.IconResources;
|
||||
import com.sap.sse.gwt.client.celltable.ImagesBarCell;
|
||||
|
||||
/**
|
||||
* Action cell for replica table rows with a "Details" and a "Drop connection" action.
|
||||
*/
|
||||
public class ReplicaImagesBarCell extends ImagesBarCell {
|
||||
|
||||
public static final String ACTION_DROP = "drop";
|
||||
|
||||
private final StringMessages stringMessages;
|
||||
|
||||
public ReplicaImagesBarCell(final StringMessages stringMessages) {
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<ImageSpec> getImageSpecs() {
|
||||
return java.util.Arrays.asList(
|
||||
new ImageSpec(ACTION_DROP, stringMessages.dropReplicaConnection(), IconResources.INSTANCE.removeIcon()));
|
||||
}
|
||||
}
|
||||
+175
-144
@@ -1,6 +1,7 @@
|
||||
package com.sap.sse.gwt.adminconsole;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -8,22 +9,29 @@ import java.util.Set;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CaptionPanel;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Focusable;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.PasswordTextBox;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.gwt.client.ErrorReporter;
|
||||
import com.sap.sse.gwt.client.async.MarkedAsyncCallback;
|
||||
import com.sap.sse.gwt.client.celltable.AbstractSortableTextColumn;
|
||||
import com.sap.sse.gwt.client.celltable.ActionsColumn;
|
||||
import com.sap.sse.gwt.client.celltable.EntityIdentityComparator;
|
||||
import com.sap.sse.gwt.client.celltable.FlushableCellTable;
|
||||
import com.sap.sse.gwt.client.celltable.RefreshableMultiSelectionModel;
|
||||
import com.sap.sse.gwt.client.celltable.SelectionCheckboxColumn;
|
||||
import com.sap.sse.gwt.client.controls.IntegerBox;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
@@ -45,16 +53,18 @@ import com.sap.sse.security.ui.client.component.AccessControlledButtonPanel;
|
||||
*
|
||||
*/
|
||||
public class ReplicationPanel extends FlowPanel {
|
||||
private final Grid registeredReplicas;
|
||||
private final FlushableCellTable<ReplicaDTO> replicasTable;
|
||||
private final ListDataProvider<ReplicaDTO> replicasDataProvider;
|
||||
private final RefreshableMultiSelectionModel<ReplicaDTO> replicaSelectionModel;
|
||||
private final Grid registeredMasters;
|
||||
|
||||
private final CaptionPanel replicaDetailPanel;
|
||||
private final Grid replicaDetailGrid;
|
||||
private final RemoteReplicationServiceAsync replicationServiceAsync;
|
||||
private final ErrorReporter errorReporter;
|
||||
private final StringMessages stringMessages;
|
||||
|
||||
private final Button addButton;
|
||||
private final Button stopReplicationButton;
|
||||
private final Button removeAllReplicas;
|
||||
private final Button dropReplicasButton;
|
||||
|
||||
private static class ReplicationData {
|
||||
private final String messagingHost;
|
||||
@@ -104,7 +114,6 @@ public class ReplicationPanel extends FlowPanel {
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,6 +127,7 @@ public class ReplicationPanel extends FlowPanel {
|
||||
*/
|
||||
private final Set<String> replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ReplicationPanel(RemoteReplicationServiceAsync replicationService, UserService userService, ErrorReporter errorReporter, final StringMessages stringMessages) {
|
||||
this.replicationServiceAsync = replicationService;
|
||||
this.stringMessages = stringMessages;
|
||||
@@ -131,12 +141,12 @@ public class ReplicationPanel extends FlowPanel {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String[] result) {
|
||||
for (final String replicableIdAsStringThatShallLeadToWarningAboutInstanceBeingReplica : result) {
|
||||
replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica.add(replicableIdAsStringThatShallLeadToWarningAboutInstanceBeingReplica);
|
||||
for (final String id : result) {
|
||||
replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica.add(id);
|
||||
}
|
||||
}
|
||||
}));
|
||||
Button refreshButton = new Button(stringMessages.refresh());
|
||||
final Button refreshButton = new Button(stringMessages.refresh());
|
||||
refreshButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -144,18 +154,27 @@ public class ReplicationPanel extends FlowPanel {
|
||||
}
|
||||
});
|
||||
add(refreshButton);
|
||||
// --- Replicas (master side) ---
|
||||
final CaptionPanel mastergroup = new CaptionPanel(stringMessages.explainReplicasRegistered());
|
||||
final VerticalPanel masterpanel = new VerticalPanel();
|
||||
final AdminConsoleTableResources tableResources = GWT.create(AdminConsoleTableResources.class);
|
||||
replicasDataProvider = new ListDataProvider<>();
|
||||
replicasTable = createReplicasTable(tableResources, userService);
|
||||
replicaSelectionModel = (RefreshableMultiSelectionModel<ReplicaDTO>) replicasTable.getSelectionModel();
|
||||
final AccessControlledButtonPanel masterPanelButtons = new AccessControlledButtonPanel(userService, SecuredSecurityTypes.SERVER);
|
||||
registeredReplicas = new Grid();
|
||||
registeredReplicas.resizeColumns(3);
|
||||
masterpanel.add(registeredReplicas);
|
||||
removeAllReplicas = masterPanelButtons.addAction(stringMessages.stopAllReplicas(),
|
||||
() -> userService.hasServerPermission(ServerActions.REPLICATE), this::stopAllReplicas);
|
||||
removeAllReplicas.setEnabled(false);
|
||||
dropReplicasButton = masterPanelButtons.addAction(stringMessages.dropReplicas(),
|
||||
() -> userService.hasServerPermission(ServerActions.REPLICATE), this::dropSelectedReplicas);
|
||||
dropReplicasButton.setEnabled(false);
|
||||
replicaSelectionModel.addSelectionChangeHandler(event -> {
|
||||
final int count = replicaSelectionModel.getSelectedSet().size();
|
||||
dropReplicasButton.setText(count > 0 ? stringMessages.dropReplicas() + " (" + count + ")" : stringMessages.dropReplicas());
|
||||
dropReplicasButton.setEnabled(count > 0 && userService.hasServerPermission(ServerActions.REPLICATE));
|
||||
});
|
||||
masterpanel.add(replicasTable);
|
||||
masterpanel.add(masterPanelButtons);
|
||||
mastergroup.add(masterpanel);
|
||||
add(mastergroup);
|
||||
// --- Masters (replica side) ---
|
||||
final CaptionPanel replicagroup = new CaptionPanel(stringMessages.explainConnectionsToMaster());
|
||||
final VerticalPanel replicapanel = new VerticalPanel();
|
||||
final AccessControlledButtonPanel replicapanelbuttons = new AccessControlledButtonPanel(userService, SecuredSecurityTypes.SERVER);
|
||||
@@ -170,11 +189,135 @@ public class ReplicationPanel extends FlowPanel {
|
||||
replicapanel.add(replicapanelbuttons);
|
||||
replicagroup.add(replicapanel);
|
||||
add(replicagroup);
|
||||
// --- Detail panel (below both tables, shown for single selection) ---
|
||||
replicaDetailPanel = new CaptionPanel();
|
||||
replicaDetailGrid = new Grid(10, 2);
|
||||
replicaDetailPanel.setContentWidget(replicaDetailGrid);
|
||||
replicaDetailPanel.setVisible(false);
|
||||
add(replicaDetailPanel);
|
||||
replicaSelectionModel.addSelectionChangeHandler(event -> {
|
||||
final Set<ReplicaDTO> selected = replicaSelectionModel.getSelectedSet();
|
||||
if (selected.size() == 1) {
|
||||
refreshReplicaDetail(selected.iterator().next());
|
||||
} else {
|
||||
replicaDetailPanel.setVisible(false);
|
||||
}
|
||||
});
|
||||
if (userService.hasServerPermission(ServerActions.READ_REPLICATOR)) {
|
||||
updateReplicaList();
|
||||
}
|
||||
}
|
||||
|
||||
private FlushableCellTable<ReplicaDTO> createReplicasTable(final AdminConsoleTableResources tableResources, final UserService userService) {
|
||||
final FlushableCellTable<ReplicaDTO> table = new FlushableCellTable<>(/* pageSize */ 50, tableResources);
|
||||
replicasDataProvider.addDataDisplay(table);
|
||||
final SelectionCheckboxColumn<ReplicaDTO> checkboxColumn = new SelectionCheckboxColumn<ReplicaDTO>(
|
||||
tableResources.cellTableStyle().cellTableCheckboxSelected(),
|
||||
tableResources.cellTableStyle().cellTableCheckboxDeselected(),
|
||||
tableResources.cellTableStyle().cellTableCheckboxColumnCell(),
|
||||
new EntityIdentityComparator<ReplicaDTO>() {
|
||||
@Override
|
||||
public boolean representSameEntity(final ReplicaDTO r1, final ReplicaDTO r2) {
|
||||
return r1.getIdentifier().equals(r2.getIdentifier());
|
||||
}
|
||||
@Override
|
||||
public int hashCode(final ReplicaDTO t) {
|
||||
return t.getIdentifier().hashCode();
|
||||
}
|
||||
}, replicasDataProvider);
|
||||
final ListHandler<ReplicaDTO> sortHandler = new ListHandler<>(replicasDataProvider.getList());
|
||||
table.addColumnSortHandler(sortHandler);
|
||||
final TextColumn<ReplicaDTO> hostnameColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
ReplicaDTO::getHostname, sortHandler);
|
||||
final TextColumn<ReplicaDTO> identifierColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
ReplicaDTO::getIdentifier, sortHandler);
|
||||
final TextColumn<ReplicaDTO> registeredAtColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
replica -> replica.getRegistrationTime().toString(), sortHandler);
|
||||
sortHandler.setComparator(registeredAtColumn, new Comparator<ReplicaDTO>() {
|
||||
@Override
|
||||
public int compare(final ReplicaDTO r1, final ReplicaDTO r2) {
|
||||
return r1.getRegistrationTime().compareTo(r2.getRegistrationTime());
|
||||
}
|
||||
});
|
||||
final ActionsColumn<ReplicaDTO, ReplicaImagesBarCell> actionsColumn = new ActionsColumn<>(
|
||||
new ReplicaImagesBarCell(stringMessages),
|
||||
(replica, action) -> userService.hasServerPermission(ServerActions.REPLICATE));
|
||||
actionsColumn.addAction(ReplicaImagesBarCell.ACTION_DROP, replica -> dropSingleReplica(replica));
|
||||
final TextColumn<ReplicaDTO> avgOpsPerMsgColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
replica -> String.valueOf(Math.round(replica.getAverageNumberOfOperationsPerMessage())), sortHandler);
|
||||
sortHandler.setComparator(avgOpsPerMsgColumn, Comparator.comparingDouble(ReplicaDTO::getAverageNumberOfOperationsPerMessage));
|
||||
final TextColumn<ReplicaDTO> numMessagesSentColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
replica -> String.valueOf(replica.getNumberOfMessagesSent()), sortHandler);
|
||||
sortHandler.setComparator(numMessagesSentColumn, Comparator.comparingLong(ReplicaDTO::getNumberOfMessagesSent));
|
||||
final TextColumn<ReplicaDTO> avgMsgSizeColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
replica -> String.valueOf(Math.round(replica.getAverageMessageSizeInBytes())), sortHandler);
|
||||
sortHandler.setComparator(avgMsgSizeColumn, Comparator.comparingDouble(ReplicaDTO::getAverageMessageSizeInBytes));
|
||||
final TextColumn<ReplicaDTO> totalSizeColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
replica -> replica.getNumberOfBytesSent() + "B (" + (replica.getNumberOfBytesSent() / 1024 / 1024) + "MB)", sortHandler);
|
||||
sortHandler.setComparator(totalSizeColumn, Comparator.comparingLong(ReplicaDTO::getNumberOfBytesSent));
|
||||
final TextColumn<ReplicaDTO> totalOpsColumn = new AbstractSortableTextColumn<ReplicaDTO>(
|
||||
replica -> String.valueOf(replica.getOperationCountByOperationClassName().values().stream().mapToLong(Integer::longValue).sum()), sortHandler);
|
||||
sortHandler.setComparator(totalOpsColumn, Comparator.comparingLong(
|
||||
replica -> replica.getOperationCountByOperationClassName().values().stream().mapToLong(Integer::longValue).sum()));
|
||||
table.addColumn(checkboxColumn, checkboxColumn.createHeader());
|
||||
table.addColumn(hostnameColumn, "IP");
|
||||
table.addColumn(identifierColumn, "ID");
|
||||
table.addColumn(registeredAtColumn, "Registered");
|
||||
table.addColumn(avgOpsPerMsgColumn, "Ops/msg");
|
||||
table.addColumn(numMessagesSentColumn, "Messages");
|
||||
table.addColumn(avgMsgSizeColumn, "Avg msg size");
|
||||
table.addColumn(totalSizeColumn, "Total size");
|
||||
table.addColumn(totalOpsColumn, "Total ops");
|
||||
table.addColumn(actionsColumn, stringMessages.additionalInformation());
|
||||
table.setSelectionModel(checkboxColumn.getSelectionModel(), checkboxColumn.getSelectionManager());
|
||||
return table;
|
||||
}
|
||||
private void refreshReplicaDetail(final ReplicaDTO replica) {
|
||||
replicaDetailPanel.setCaptionText(replica.getHostname() + " (" + replica.getIdentifier() + ")");
|
||||
int row = 0;
|
||||
replicaDetailGrid.resize(6 + replica.getOperationCountByOperationClassName().size(), 2);
|
||||
replicaDetailGrid.setWidget(row, 0, new Label(stringMessages.registrationTime()));
|
||||
replicaDetailGrid.setWidget(row, 1, new Label(replica.getRegistrationTime().toString()));
|
||||
row++;
|
||||
replicaDetailGrid.setWidget(row, 0, new Label(stringMessages.replicables()));
|
||||
replicaDetailGrid.setWidget(row, 1, new Label(Arrays.toString(replica.getReplicableIdsAsStrings()).replaceAll(",", "\n")));
|
||||
row++;
|
||||
replicaDetailGrid.setWidget(row, 0, new Label(stringMessages.additionalInformation()));
|
||||
replicaDetailGrid.setWidget(row, 1, new Label(replica.getAdditionalInformation()));
|
||||
row++;
|
||||
long totalNumberOfOperations = 0;
|
||||
for (final Map.Entry<String, Integer> e : replica.getOperationCountByOperationClassName().entrySet()) {
|
||||
replicaDetailGrid.setWidget(row, 0, new Label(e.getKey()));
|
||||
replicaDetailGrid.setWidget(row, 1, new Label(e.getValue().toString()));
|
||||
totalNumberOfOperations += e.getValue();
|
||||
row++;
|
||||
}
|
||||
replicaDetailGrid.setWidget(row, 0, new Label(stringMessages.totalNumberOfOperations()));
|
||||
replicaDetailGrid.setWidget(row, 1, new Label(String.valueOf(totalNumberOfOperations)));
|
||||
row++;
|
||||
replicaDetailGrid.setWidget(row, 0, new Label(stringMessages.totalSize()));
|
||||
replicaDetailGrid.setWidget(row, 1, new Label(replica.getNumberOfBytesSent() + "B (" + (replica.getNumberOfBytesSent() / 1024 / 1024) + "MB)"));
|
||||
replicaDetailPanel.setVisible(true);
|
||||
}
|
||||
private void dropSelectedReplicas() {
|
||||
final Set<ReplicaDTO> selected = new HashSet<>(replicaSelectionModel.getSelectedSet());
|
||||
for (final ReplicaDTO replica : selected) {
|
||||
dropSingleReplica(replica);
|
||||
}
|
||||
}
|
||||
private void dropSingleReplica(final ReplicaDTO replica) {
|
||||
replicationServiceAsync.stopSingleReplicaInstance(replica.getIdentifier(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
updateReplicaList();
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
updateReplicaList();
|
||||
}
|
||||
});
|
||||
}
|
||||
protected void stopAllReplicas() {
|
||||
replicationServiceAsync.stopAllReplicas(new AsyncCallback<Void>() {
|
||||
@Override
|
||||
@@ -184,7 +327,6 @@ public class ReplicationPanel extends FlowPanel {
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
removeAllReplicas.setEnabled(false);
|
||||
updateReplicaList();
|
||||
}
|
||||
});
|
||||
@@ -206,29 +348,17 @@ public class ReplicationPanel extends FlowPanel {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addReplication() {
|
||||
AddReplicationDialog dialog = new AddReplicationDialog(new Validator<ReplicationData>() {
|
||||
|
||||
new AddReplicationDialog(new Validator<ReplicationData>() {
|
||||
@Override
|
||||
public String getErrorMessage(ReplicationData valueToValidate) {
|
||||
boolean userNameUnset = valueToValidate.getUserName() == null
|
||||
|| valueToValidate.getUserName().isEmpty();
|
||||
boolean passWordUnset = valueToValidate.getPassword() == null
|
||||
|| valueToValidate.getPassword().isEmpty();
|
||||
final boolean userNameUnset = valueToValidate.getUserName() == null || valueToValidate.getUserName().isEmpty();
|
||||
final boolean passWordUnset = valueToValidate.getPassword() == null || valueToValidate.getPassword().isEmpty();
|
||||
return userNameUnset == passWordUnset ? null : stringMessages.usernameAndPasswordMustBothBeSet();
|
||||
}
|
||||
}, new DialogCallback<ReplicationData>() {
|
||||
@Override
|
||||
/**
|
||||
* @param masterNameAndExchangeNameAndMessagingPortNumberAndServletPortNumber
|
||||
* a triple containing the RabbitMQ exchange hostname, the servlet hostname and the RabbitMQ
|
||||
* exchange name, followed by the RabbitMQ messaging port and the servlet port
|
||||
*/
|
||||
public void ok(final ReplicationData state) {
|
||||
registeredMasters.removeRow(0);
|
||||
registeredMasters.insertRow(0);
|
||||
registeredMasters.setWidget(0, 0, new Label(stringMessages.loading()));
|
||||
addButton.setEnabled(false);
|
||||
stopReplicationButton.setEnabled(false);
|
||||
replicationServiceAsync.startReplicatingFromMaster(state.getMessagingHost(), state.getMasterHostName(),
|
||||
@@ -255,103 +385,31 @@ public class ReplicationPanel extends FlowPanel {
|
||||
public void cancel() {
|
||||
// simply don't add replication
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}).show();
|
||||
}
|
||||
|
||||
public void updateReplicaList() {
|
||||
replicationServiceAsync.getReplicaInfo(new AsyncCallback<ReplicationStateDTO>() {
|
||||
@Override
|
||||
public void onSuccess(ReplicationStateDTO replicas) {
|
||||
int i=0;
|
||||
int replicaCount = 0;
|
||||
registeredReplicas.clear();
|
||||
boolean replicaRegistered = false;
|
||||
replicaSelectionModel.clear();
|
||||
final java.util.List<ReplicaDTO> replicaList = replicasDataProvider.getList();
|
||||
replicaList.clear();
|
||||
for (final ReplicaDTO replica : replicas.getReplicas()) {
|
||||
replicaCount++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 0, new Label(replicaCount + ". " + replica.getHostname() + " (" + replica.getIdentifier() + ")"));
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.registeredAt(replica.getRegistrationTime().toString())));
|
||||
final Button removeReplicaButton = new Button(stringMessages.dropReplicaConnection());
|
||||
removeReplicaButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
replicationServiceAsync.stopSingleReplicaInstance(replica.getIdentifier(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
updateReplicaList();
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
updateReplicaList();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registeredReplicas.setWidget(i, 2, removeReplicaButton);
|
||||
i++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.replicables()));
|
||||
HTML replicablesLabel = new HTML(new SafeHtmlBuilder().appendEscapedLines(Arrays.toString(replica.getReplicableIdsAsStrings()).replaceAll(",", "\n")).toSafeHtml());
|
||||
registeredReplicas.setWidget(i, 2, replicablesLabel);
|
||||
i++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.averageNumberOfOperationsPerMessage()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getAverageNumberOfOperationsPerMessage()));
|
||||
i++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.additionalInformation()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getAdditionalInformation()));
|
||||
i++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.numberOfQueueMessagesSent()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getNumberOfMessagesSent()));
|
||||
i++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.averageMessageSize()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getAverageMessageSizeInBytes()));
|
||||
i++;
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.totalSize()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getNumberOfBytesSent()+"B ("+replica.getNumberOfBytesSent()/1024.0/1024.0+"MB)"));
|
||||
i++;
|
||||
long totalNumberOfOperations = 0;
|
||||
for (Map.Entry<String, Integer> e : replica.getOperationCountByOperationClassName().entrySet()) {
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(e.getKey()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(e.getValue().toString()));
|
||||
totalNumberOfOperations += e.getValue();
|
||||
i++;
|
||||
}
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.totalNumberOfOperations()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+totalNumberOfOperations));
|
||||
i++;
|
||||
replicaRegistered = true;
|
||||
}
|
||||
if (!replicaRegistered) {
|
||||
insertRowIfNeeded(registeredReplicas, i);
|
||||
registeredReplicas.setWidget(i, 0, new Label(stringMessages.explainNoConnectionsFromReplicas()));
|
||||
removeAllReplicas.setEnabled(false);
|
||||
i++;
|
||||
} else {
|
||||
removeAllReplicas.setEnabled(true);
|
||||
}
|
||||
while (registeredReplicas.getRowCount() > i) {
|
||||
registeredReplicas.removeRow(registeredReplicas.getRowCount()-1);
|
||||
replicaList.add(replica);
|
||||
}
|
||||
replicasDataProvider.refresh();
|
||||
while (registeredMasters.getRowCount() > 0) {
|
||||
registeredMasters.removeRow(0);
|
||||
}
|
||||
i = 0;
|
||||
int i = 0;
|
||||
registeredMasters.insertRow(i);
|
||||
registeredMasters.setWidget(i, 0, new Label("Client UUID: " + replicas.getServerIdentifier()));
|
||||
i++;
|
||||
final ReplicationMasterDTO replicatingFromMaster = replicas.getReplicatingFromMaster();
|
||||
if (replicatingFromMaster != null) { // TODO bug 2465: replicating only the user service from a "domain controller master" shouldn't lead to a warning here...
|
||||
for (final String replicableIdAsStringOfReplicableThatWeAreReplicatingCurrently : replicatingFromMaster.getReplicableIdsAsString()) {
|
||||
if (Util.contains(replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica, replicableIdAsStringOfReplicableThatWeAreReplicatingCurrently)) {
|
||||
if (replicatingFromMaster != null) {
|
||||
for (final String replicableId : replicatingFromMaster.getReplicableIdsAsString()) {
|
||||
if (Util.contains(replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica, replicableId)) {
|
||||
errorReporter.reportPersistentInformation(stringMessages.warningServerIsReplica());
|
||||
break;
|
||||
}
|
||||
@@ -372,28 +430,16 @@ public class ReplicationPanel extends FlowPanel {
|
||||
stopReplicationButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
errorReporter.reportError(stringMessages.errorFetchingReplicaData(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void insertRowIfNeeded(Grid grid, int zeroBasedRowNumber) {
|
||||
if (grid.getRowCount() <= zeroBasedRowNumber) {
|
||||
grid.insertRow(zeroBasedRowNumber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A text entry dialog with ok/cancel button and configurable validation rule. Subclasses may provide a redefinition for
|
||||
* {@link #getAdditionalWidget()} to add a widget below the text field, e.g., for capturing additional data. The result of
|
||||
* this dialog is a triple containing the RabbitMQ exchange hostname, the servlet hostname and the RabbitMQ exchange name,
|
||||
* followed by the RabbitMQ messaging port and the servlet port.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
* A text entry dialog for connecting to a replication master. The result contains the RabbitMQ exchange
|
||||
* hostname, the servlet hostname, the RabbitMQ exchange name, the messaging port and the servlet port.
|
||||
*/
|
||||
private class AddReplicationDialog extends DataEntryDialog<ReplicationData> {
|
||||
private final TextBox hostnameEntryField;
|
||||
@@ -403,7 +449,6 @@ public class ReplicationPanel extends FlowPanel {
|
||||
private final IntegerBox servletPortField;
|
||||
private final TextBox usernameEntryField;
|
||||
private final PasswordTextBox passwordEntryField;
|
||||
|
||||
public AddReplicationDialog(final Validator<ReplicationData> validator,
|
||||
final DialogCallback<ReplicationData> callback) {
|
||||
super(stringMessages.connect(), stringMessages.enterMaster(),
|
||||
@@ -416,49 +461,36 @@ public class ReplicationPanel extends FlowPanel {
|
||||
usernameEntryField = createTextBox("admin");
|
||||
passwordEntryField = createPasswordTextBox("admin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Can contribute an additional widget to be displayed underneath the text entry field. If <code>null</code> is
|
||||
* returned, no additional widget will be displayed. This is the default behavior of this default implementation.
|
||||
*/
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
Grid grid = new Grid(14, 2);
|
||||
final Grid grid = new Grid(14, 2);
|
||||
grid.setWidget(0, 0, new Label(stringMessages.hostname()));
|
||||
grid.setWidget(0, 1, hostnameEntryField);
|
||||
grid.setWidget(1, 0, new Label(stringMessages.explainReplicationHostname()));
|
||||
|
||||
grid.setWidget(2, 0, new Label(stringMessages.exchangeHost()));
|
||||
grid.setWidget(2, 1, exchangeHostnameEntryField);
|
||||
grid.setWidget(3, 0, new Label(stringMessages.explainExchangeHostName()));
|
||||
|
||||
grid.setWidget(4, 0, new Label(stringMessages.exchangeName()));
|
||||
grid.setWidget(4, 1, exchangenameEntryField);
|
||||
grid.setWidget(5, 0, new Label(stringMessages.explainReplicationExchangeName()));
|
||||
|
||||
grid.setWidget(6, 0, new Label(stringMessages.messagingPortNumber()));
|
||||
grid.setWidget(6, 1, messagingPortField);
|
||||
grid.setWidget(7, 0, new Label(stringMessages.explainReplicationExchangePort()));
|
||||
|
||||
grid.setWidget(8, 0, new Label(stringMessages.servletPortNumber()));
|
||||
grid.setWidget(8, 1, servletPortField);
|
||||
grid.setWidget(9, 0, new Label(stringMessages.explainReplicationServletPort()));
|
||||
|
||||
grid.setWidget(10, 0, new Label(stringMessages.username()));
|
||||
grid.setWidget(10, 1, usernameEntryField);
|
||||
grid.setWidget(11, 0, new Label(stringMessages.explainUserName()));
|
||||
|
||||
grid.setWidget(12, 0, new Label(stringMessages.password()));
|
||||
grid.setWidget(12, 1, passwordEntryField);
|
||||
grid.setWidget(13, 0, new Label(stringMessages.explainPassword()));
|
||||
return grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Focusable getInitialFocusWidget() {
|
||||
return hostnameEntryField;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReplicationData getResult() {
|
||||
return new ReplicationData(exchangeHostnameEntryField.getValue(), hostnameEntryField.getValue(),
|
||||
@@ -466,5 +498,4 @@ public class ReplicationPanel extends FlowPanel {
|
||||
usernameEntryField.getValue(), passwordEntryField.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,8 +43,16 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages {
|
||||
|
||||
String registeredAt(String string);
|
||||
|
||||
String registrationTime();
|
||||
|
||||
String dropReplicaConnection();
|
||||
|
||||
String dropReplicas();
|
||||
|
||||
String replicaIdentifier();
|
||||
|
||||
String numberOfOperations();
|
||||
|
||||
String replicables();
|
||||
|
||||
String averageNumberOfOperationsPerMessage();
|
||||
|
||||
+4
@@ -16,7 +16,11 @@ stopConnectionToMaster=Stop Replication
|
||||
errorStartingReplication=Error starting replication from host {0} / exchange {1}: {2}
|
||||
loading=Loading (on a slow internet connection this can take some minutes)...
|
||||
registeredAt=Registered at {0}
|
||||
registrationTime=Registration Time
|
||||
dropReplicaConnection=Drop connection
|
||||
dropReplicas=Drop connections
|
||||
replicaIdentifier=Identifier
|
||||
numberOfOperations=Operations
|
||||
replicables=Replicating objects
|
||||
averageNumberOfOperationsPerMessage=Average number of operations per message
|
||||
numberOfQueueMessagesSent=Number of queue messages sent
|
||||
|
||||
Reference in New Issue
Block a user