moved replication-related interface methods from SailingService to new RemoteReplicationService, matching RemoteReplicationServiceAsync;

based on this, implemented replication warning dependent on whether RacingEventService is replicated, giving no
warning in case, e.g., only the SecurityService is replicated

Change-Id: I84c8520a64d1f51ba00666b41e8eed4ec6c00f7f
This commit is contained in:
Axel Uhl committed 2016-12-27 14:23:16 +01:00
1 parent 1d4d322e37
commit a5ec8a8c51
8 files changed
+75 -20

No files matched your search

@@ -108,13 +108,13 @@ import com.sap.sse.gwt.client.ServerInfoDTO;
import com.sap.sse.gwt.client.filestorage.FileStorageManagementGwtService;
import com.sap.sse.gwt.client.media.ImageDTO;
import com.sap.sse.gwt.client.media.VideoDTO;
import com.sap.sse.gwt.shared.replication.ReplicationStateDTO;
import com.sap.sse.gwt.client.replication.RemoteReplicationService;
/**
* The client side stub for the RPC service. Usually, when a <code>null</code> date is passed to
* the time-dependent service methods, an empty (non-<code>null</code>) result is returned.
*/
public interface SailingService extends RemoteService, FileStorageManagementGwtService {
public interface SailingService extends RemoteService, FileStorageManagementGwtService, RemoteReplicationService {
List<TracTracConfigurationDTO> getPreviousTracTracConfigurations() throws Exception;
List<RegattaDTO> getRegattas();
@@ -310,10 +310,6 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
void setWindSourcesToExclude(RegattaAndRaceIdentifier raceIdentifier, Iterable<WindSource> windSourcesToExclude);
ReplicationStateDTO getReplicaInfo();
void startReplicatingFromMaster(String messagingHost, String masterHost, String exchangeName, int servletPort, int messagingPort) throws Exception;
void updateRaceDelayToLive(RegattaAndRaceIdentifier regattaAndRaceIdentifier, long delayToLiveInMs);
void updateRacesDelayToLive(List<RegattaAndRaceIdentifier> regattaAndRaceIdentifiers, long delayToLiveInMs);
@@ -423,12 +419,6 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
boolean showOnlyCurrentlyRunningRaces, boolean showOnlyRacesOfSameDay, Duration clientTimeZoneOffset,
List<String> visibleRegattas) throws Exception;
void stopReplicatingFromMaster();
void stopAllReplicas();
void stopSingleReplicaInstance(String identifier);
void reloadRaceLog(String leaderboardName, RaceColumnDTO raceColumnDTO, FleetDTO fleet);
RaceLogDTO getRaceLog(String leaderboardName, RaceColumnDTO raceColumnDTO, FleetDTO fleet);
@@ -96,12 +96,12 @@ import com.sap.sse.gwt.client.ServerInfoRetriever;
import com.sap.sse.gwt.client.filestorage.FileStorageManagementGwtServiceAsync;
import com.sap.sse.gwt.client.media.ImageDTO;
import com.sap.sse.gwt.client.media.VideoDTO;
import com.sap.sse.gwt.client.replication.ReplicationServiceAsync;
import com.sap.sse.gwt.client.replication.RemoteReplicationServiceAsync;
/**
* The async counterpart of {@link SailingService}
*/
public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageManagementGwtServiceAsync, ReplicationServiceAsync {
public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageManagementGwtServiceAsync, RemoteReplicationServiceAsync {
void getRegattas(AsyncCallback<List<RegattaDTO>> callback);
@@ -488,6 +488,7 @@ import com.sap.sse.replication.ReplicationFactory;
import com.sap.sse.replication.ReplicationMasterDescriptor;
import com.sap.sse.replication.ReplicationService;
import com.sap.sse.replication.impl.ReplicaDescriptor;
import com.sap.sse.security.SecurityService;
import com.sap.sse.security.SessionUtils;
import com.sap.sse.shared.media.ImageDescriptor;
import com.sap.sse.shared.media.MediaUtils;
@@ -3450,6 +3451,15 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
return new ReplicationStateDTO(master, replicaDTOs, service.getServerIdentifier().toString());
}
/**
* A warning shall be issued to the administration user if the {@link RacingEventService} is a replica. For all
* other {@link Replicable}s such as the {@link SecurityService} we don't care.
*/
@Override
public String[] getReplicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica() {
return new String[] { getService().getId().toString() };
}
@Override
public void startReplicatingFromMaster(String messagingHost, String masterHost, String exchangeName, int servletPort, int messagingPort) throws IOException, ClassNotFoundException, InterruptedException {
// The queue name must always be the same for this server. In order to achieve
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://gwtproject.org/doctype/2.7.0/gwt-module.dtd">
<module>
<inherits name="com.sap.sse.gwt.SSESharedGWT" />
<source path='adminconsole'/>
</module>
@@ -1,8 +1,11 @@
package com.sap.sse.gwt.adminconsole;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
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;
@@ -20,10 +23,11 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
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.controls.IntegerBox;
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
import com.sap.sse.gwt.client.replication.ReplicationServiceAsync;
import com.sap.sse.gwt.client.replication.RemoteReplicationServiceAsync;
import com.sap.sse.gwt.shared.replication.ReplicaDTO;
import com.sap.sse.gwt.shared.replication.ReplicationMasterDTO;
import com.sap.sse.gwt.shared.replication.ReplicationStateDTO;
@@ -39,7 +43,7 @@ public class ReplicationPanel extends FlowPanel {
private final Grid registeredReplicas;
private final Grid registeredMasters;
private final ReplicationServiceAsync replicationServiceAsync;
private final RemoteReplicationServiceAsync replicationServiceAsync;
private final ErrorReporter errorReporter;
private final StringMessages stringMessages;
@@ -47,10 +51,35 @@ public class ReplicationPanel extends FlowPanel {
private final Button stopReplicationButton;
private final Button removeAllReplicas;
public ReplicationPanel(ReplicationServiceAsync sailingService, ErrorReporter errorReporter, StringMessages stringMessages) {
this.replicationServiceAsync = sailingService;
/**
* For administrators it is important to understand whether an instance is a replica. A
* {@link ErrorReporter#reportPersistentInformation(String) persistent error message} shall be shown
* in this case; however, some replicables may not be considered part of the "domain-based" replication.
* For example, if only a security service for user management is replicated in order to implement
* central user and session management then this shall not lead to the warning being displayed.
* This set contains the stringified IDs of those replicables for which being a replica shall
* lead to a warnings.
*/
private final Set<String> replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica;
public ReplicationPanel(RemoteReplicationServiceAsync replicationService, ErrorReporter errorReporter, final StringMessages stringMessages) {
this.replicationServiceAsync = replicationService;
this.stringMessages = stringMessages;
this.errorReporter = errorReporter;
this.replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica = new HashSet<>();
replicationService.getReplicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica(new MarkedAsyncCallback<>(new AsyncCallback<String[]>() {
@Override
public void onFailure(Throwable caught) {
GWT.log(stringMessages.errorFetchingReplicaData(caught.getMessage()));
}
@Override
public void onSuccess(String[] result) {
for (final String replicableIdAsStringThatShallLeadToWarningAboutInstanceBeingReplica : result) {
replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica.add(replicableIdAsStringThatShallLeadToWarningAboutInstanceBeingReplica);
}
}
}));
Button refreshButton = new Button(stringMessages.refresh());
refreshButton.addClickHandler(new ClickHandler() {
@@ -277,7 +306,12 @@ public class ReplicationPanel extends FlowPanel {
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...
errorReporter.reportPersistentInformation(stringMessages.warningServerIsReplica());
for (final String replicableIdAsStringOfReplicableThatWeAreReplicatingCurrently : replicatingFromMaster.getReplicableIdsAsString()) {
if (Util.contains(replicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica, replicableIdAsStringOfReplicableThatWeAreReplicatingCurrently)) {
errorReporter.reportPersistentInformation(stringMessages.warningServerIsReplica());
break;
}
}
registeredMasters.insertRow(i);
registeredMasters.setWidget(i, 0, new Label(stringMessages.replicatingFromMaster(replicatingFromMaster.getHostname(),
replicatingFromMaster.getMessagingPort(), replicatingFromMaster.getServletPort(),
@@ -58,6 +58,7 @@ Export-Package: com.google.gwt.user.client.rpc.core.java.util,
com.sap.sse.gwt.resources,
com.sap.sse.gwt.server,
com.sap.sse.gwt.server.filestorage,
com.sap.sse.gwt.server.replication,
com.sap.sse.gwt.settings,
com.sap.sse.gwt.shared,
com.sap.sse.gwt.shared.filestorage,
@@ -0,0 +1,17 @@
package com.sap.sse.gwt.client.replication;
import com.sap.sse.gwt.shared.replication.ReplicationStateDTO;
public interface RemoteReplicationService {
ReplicationStateDTO getReplicaInfo();
void startReplicatingFromMaster(String messagingHost, String masterName, String exchangeName, int servletPort, int messagingPort) throws Exception;
void stopAllReplicas();
void stopReplicatingFromMaster();
void stopSingleReplicaInstance(String identifier);
String[] getReplicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica();
}
@@ -3,7 +3,7 @@ package com.sap.sse.gwt.client.replication;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sap.sse.gwt.shared.replication.ReplicationStateDTO;
public interface ReplicationServiceAsync {
public interface RemoteReplicationServiceAsync {
void getReplicaInfo(AsyncCallback<ReplicationStateDTO> callback);
void startReplicatingFromMaster(String messagingHost, String masterName, String exchangeName, int servletPort,
@@ -15,4 +15,6 @@ public interface ReplicationServiceAsync {
void stopSingleReplicaInstance(String identifier, AsyncCallback<Void> asyncCallback);
void getReplicableIdsAsStringThatShallLeadToWarningAboutInstanceBeingReplica(AsyncCallback<String[]> markedAsyncCallback);
}