mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 22:30:56 +00:00
Made sure that event is correctly replicated upon initial load, also
stopping trackers upon initial load on replica
This commit is contained in:
1 parent
4241965881
commit
792dfd7de2
7 files changed
+21
-19
No files matched your search
@@ -13,19 +13,6 @@ import com.sap.sailing.domain.common.WithID;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface Event extends Named, Renamable, WithID, EventData {
|
public interface Event extends Named, Renamable, WithID, EventData {
|
||||||
/**
|
|
||||||
* @return a non-<code>null</code> venue for this event
|
|
||||||
*/
|
|
||||||
Venue getVenue();
|
|
||||||
|
|
||||||
String getPublicationUrl();
|
|
||||||
|
|
||||||
void setPublicationUrl(String publicationUrl);
|
|
||||||
|
|
||||||
boolean isPublic();
|
|
||||||
|
|
||||||
void setPublic(boolean isPublic);
|
|
||||||
|
|
||||||
Iterable<Regatta> getRegattas();
|
Iterable<Regatta> getRegattas();
|
||||||
|
|
||||||
void addRegatta(Regatta regatta);
|
void addRegatta(Regatta regatta);
|
||||||
|
|||||||
+1
-1
@@ -2877,7 +2877,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startReplicatingFromMaster(String masterName, String exchangeName, int servletPort, int messagingPort) throws IOException, ClassNotFoundException {
|
public void startReplicatingFromMaster(String masterName, String exchangeName, int servletPort, int messagingPort) throws IOException, ClassNotFoundException, InterruptedException {
|
||||||
getReplicationService().startToReplicateFrom(
|
getReplicationService().startToReplicateFrom(
|
||||||
ReplicationFactory.INSTANCE.createReplicationMasterDescriptor(masterName, exchangeName, servletPort, messagingPort));
|
ReplicationFactory.INSTANCE.createReplicationMasterDescriptor(masterName, exchangeName, servletPort, messagingPort));
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -194,8 +194,9 @@ public abstract class AbstractServerReplicationTest {
|
|||||||
* Clones the {@link #master}'s state to the {@link #replica} using
|
* Clones the {@link #master}'s state to the {@link #replica} using
|
||||||
* {@link RacingEventServiceImpl#serializeForInitialReplication(ObjectOutputStream)} and
|
* {@link RacingEventServiceImpl#serializeForInitialReplication(ObjectOutputStream)} and
|
||||||
* {@link RacingEventServiceImpl#initiallyFillFrom(ObjectInputStream)} through a piped input/output stream.
|
* {@link RacingEventServiceImpl#initiallyFillFrom(ObjectInputStream)} through a piped input/output stream.
|
||||||
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
protected void initialLoad() throws IOException, ClassNotFoundException {
|
protected void initialLoad() throws IOException, ClassNotFoundException, InterruptedException {
|
||||||
PipedOutputStream pos = new PipedOutputStream();
|
PipedOutputStream pos = new PipedOutputStream();
|
||||||
PipedInputStream pis = new PipedInputStream(pos);
|
PipedInputStream pis = new PipedInputStream(pos);
|
||||||
final ObjectOutputStream oos = new ObjectOutputStream(pos);
|
final ObjectOutputStream oos = new ObjectOutputStream(pos);
|
||||||
|
|||||||
+2
-1
@@ -24,8 +24,9 @@ public interface ReplicationService {
|
|||||||
* Performs a servlet request to the server's {@link ReplicationServlet}, first registering this replica, ensuring
|
* Performs a servlet request to the server's {@link ReplicationServlet}, first registering this replica, ensuring
|
||||||
* the JMS replication topic is created, then subscribing for the master's JMS replication topic and asking the servlet
|
* the JMS replication topic is created, then subscribing for the master's JMS replication topic and asking the servlet
|
||||||
* for the stream containing the initial load.
|
* for the stream containing the initial load.
|
||||||
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
void startToReplicateFrom(ReplicationMasterDescriptor master) throws IOException, ClassNotFoundException;
|
void startToReplicateFrom(ReplicationMasterDescriptor master) throws IOException, ClassNotFoundException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a replica with this master instance. The <code>replica</code> will be considered in the result of
|
* Registers a replica with this master instance. The <code>replica</code> will be considered in the result of
|
||||||
|
|||||||
+1
-1
@@ -167,7 +167,7 @@ public class ReplicationServiceImpl implements ReplicationService, OperationExec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startToReplicateFrom(ReplicationMasterDescriptor master) throws IOException, ClassNotFoundException {
|
public void startToReplicateFrom(ReplicationMasterDescriptor master) throws IOException, ClassNotFoundException, InterruptedException {
|
||||||
logger.info("Starting to replicate from "+master);
|
logger.info("Starting to replicate from "+master);
|
||||||
replicatingFromMaster = master;
|
replicatingFromMaster = master;
|
||||||
registerReplicaWithMaster(master);
|
registerReplicaWithMaster(master);
|
||||||
|
|||||||
@@ -420,8 +420,9 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
|||||||
* replication of these operations will happen based on the changes performed on the replication master.<p>
|
* replication of these operations will happen based on the changes performed on the replication master.<p>
|
||||||
*
|
*
|
||||||
* <b>Caution:</b> All relevant contents of this service instance will be replaced by the stream contents.
|
* <b>Caution:</b> All relevant contents of this service instance will be replaced by the stream contents.
|
||||||
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
void initiallyFillFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException;
|
void initiallyFillFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a thread-safe copy of the events currently known by the service; it's safe for callers to iterate over
|
* @return a thread-safe copy of the events currently known by the service; it's safe for callers to iterate over
|
||||||
|
|||||||
+13
-1
@@ -1570,6 +1570,8 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serializeForInitialReplication(ObjectOutputStream oos) throws IOException {
|
public void serializeForInitialReplication(ObjectOutputStream oos) throws IOException {
|
||||||
|
logger.info("serializing eventsById");
|
||||||
|
oos.writeObject(eventsById);
|
||||||
logger.info("serializing regattasByName");
|
logger.info("serializing regattasByName");
|
||||||
oos.writeObject(regattasByName);
|
oos.writeObject(regattasByName);
|
||||||
logger.info("serializing regattasObservedForDefaultLeaderboard");
|
logger.info("serializing regattasObservedForDefaultLeaderboard");
|
||||||
@@ -1584,7 +1586,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked") // the type-parameters in the casts of the de-serialized collection objects can't be checked
|
@SuppressWarnings("unchecked") // the type-parameters in the casts of the de-serialized collection objects can't be checked
|
||||||
@Override
|
@Override
|
||||||
public void initiallyFillFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException {
|
public void initiallyFillFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException, InterruptedException {
|
||||||
logger.info("Performing initial replication load on "+this);
|
logger.info("Performing initial replication load on "+this);
|
||||||
ClassLoader oldContextClassloader = Thread.currentThread().getContextClassLoader();
|
ClassLoader oldContextClassloader = Thread.currentThread().getContextClassLoader();
|
||||||
try {
|
try {
|
||||||
@@ -1594,9 +1596,19 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
|||||||
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
|
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
|
||||||
regattasByName.clear();
|
regattasByName.clear();
|
||||||
regattasObservedForDefaultLeaderboard.clear();
|
regattasObservedForDefaultLeaderboard.clear();
|
||||||
|
|
||||||
|
for (DynamicTrackedRegatta regatta: regattaTrackingCache.values()) {
|
||||||
|
for (RaceTracker tracker : raceTrackersByRegatta.get(regatta)) {
|
||||||
|
tracker.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
regattaTrackingCache.clear();
|
regattaTrackingCache.clear();
|
||||||
leaderboardGroupsByName.clear();
|
leaderboardGroupsByName.clear();
|
||||||
leaderboardsByName.clear();
|
leaderboardsByName.clear();
|
||||||
|
eventsById.clear();
|
||||||
|
logger.info("receiving eventsById");
|
||||||
|
eventsById.putAll((Map<Serializable, Event>) ois.readObject());
|
||||||
logger.info("receiving regattasByName");
|
logger.info("receiving regattasByName");
|
||||||
regattasByName.putAll((Map<String, Regatta>) ois.readObject());
|
regattasByName.putAll((Map<String, Regatta>) ois.readObject());
|
||||||
// it is important that the leaderboards and tracked regattas are cleared before auto-linking to
|
// it is important that the leaderboards and tracked regattas are cleared before auto-linking to
|
||||||
|
|||||||
Reference in new issue
Block a user