improved replication test logging; improved Javadoc for RaceTracker.stop(...)

This commit is contained in:
Axel Uhl committed 2015-03-30 10:44:08 +02:00
1 parent 4f18c1c366
commit b8ef26800f
3 files changed
+30 -13

No files matched your search

@@ -42,7 +42,11 @@ public interface RaceTracker {
/**
* Stops tracking the races.
* @param preemptive TODO
*
* @param preemptive
* if <code>false</code>, the tracker will continue to process data already received but will stop
* receiving new data. If <code>true</code>, the tracker will stop processing data immediately, ignoring
* (dropping) all data already received but not yet processed.
*/
void stop(boolean preemptive) throws MalformedURLException, IOException, InterruptedException;
@@ -129,6 +129,7 @@ public class TrackRaceReplicationTest extends AbstractServerReplicationTest {
@Test
public void testReassignmentToLeaderboardReplication() throws Exception {
logger.info("Running testReassignmentToLeaderboardReplication()");
final String leaderboardName = "Test Leaderboard";
Leaderboard masterLeaderboard = master.apply(new CreateFlexibleLeaderboard(leaderboardName, null, new int[0], new LowPoint(), null));
final String columnName = "R1";
@@ -153,10 +154,12 @@ public class TrackRaceReplicationTest extends AbstractServerReplicationTest {
RaceColumn column = replicaLeaderboard.getRaceColumnByName(columnName);
assertNotNull(column);
assertSame(replicaTrackedRace, column.getTrackedRace(defaultFleet));
logger.info("Done running testReassignmentToLeaderboardReplication()");
}
@Test
public void testRaceTimeReplication() throws InterruptedException, Exception {
logger.info("Running testRaceTimeReplication()");
startTracking();
// now wait at least until the start of tracking time has been received on the master copy
boolean receivedStartAndEndOfTracking = master.getTrackedRace(raceIdentifier).getStartOfTracking() != null &&
@@ -176,21 +179,27 @@ public class TrackRaceReplicationTest extends AbstractServerReplicationTest {
((DynamicTrackedRace) masterTrackedRace).setStartTimeReceived(now);
Thread.sleep(1000);
assertEquals(now, replicaTrackedRace.getStartOfRace());
logger.info("Done running testRaceTimeReplication()");
}
@Test
public void testWindSourcesToExcludeReplication() throws InterruptedException, Exception {
startTracking();
Thread.sleep(1000);
TrackedRace replicaTrackedRace = replica.getTrackedRace(raceIdentifier);
assertTrue(Util.isEmpty(masterTrackedRace.getWindSourcesToExclude()));
assertTrue(Util.isEmpty(replicaTrackedRace.getWindSourcesToExclude()));
masterTrackedRace.setWindSourcesToExclude(Collections.singleton(new WindSourceImpl(WindSourceType.WEB)));
assertEquals(1, Util.size(masterTrackedRace.getWindSourcesToExclude()));
assertEquals(WindSourceType.WEB, masterTrackedRace.getWindSourcesToExclude().iterator().next().getType());
Thread.sleep(1000);
assertEquals(1, Util.size(replicaTrackedRace.getWindSourcesToExclude()));
assertEquals(WindSourceType.WEB, replicaTrackedRace.getWindSourcesToExclude().iterator().next().getType());
try {
logger.info("Running testWindSourcesToExcludeReplication()");
startTracking();
Thread.sleep(1000);
TrackedRace replicaTrackedRace = replica.getTrackedRace(raceIdentifier);
assertTrue(Util.isEmpty(masterTrackedRace.getWindSourcesToExclude()));
assertTrue(Util.isEmpty(replicaTrackedRace.getWindSourcesToExclude()));
masterTrackedRace.setWindSourcesToExclude(Collections.singleton(new WindSourceImpl(WindSourceType.WEB)));
assertEquals(1, Util.size(masterTrackedRace.getWindSourcesToExclude()));
assertEquals(WindSourceType.WEB, masterTrackedRace.getWindSourcesToExclude().iterator().next().getType());
Thread.sleep(1000);
assertEquals(1, Util.size(replicaTrackedRace.getWindSourcesToExclude()));
assertEquals(WindSourceType.WEB, replicaTrackedRace.getWindSourcesToExclude().iterator().next().getType());
} finally {
logger.info("Done running testWindSourcesToExcludeReplication()");
}
}
@After
@@ -7,6 +7,8 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -19,6 +21,8 @@ import com.sap.sse.replication.Replicable;
import com.sap.sse.replication.ReplicationMasterDescriptor;
public class ReplicationMasterDescriptorImpl implements ReplicationMasterDescriptor {
private static final Logger logger = Logger.getLogger(ReplicationMasterDescriptorImpl.class.getName());
private static final String REPLICATION_SERVLET = "/replication/replication";
private final String masterServletHostname;
private final String exchangeName;
@@ -161,7 +165,7 @@ public class ReplicationMasterDescriptorImpl implements ReplicationMasterDescrip
} catch (Exception ex) {
// ignore any exception during abort. close can yield a broad
// number of exceptions that we don't want to know or to log.
ex.printStackTrace();
logger.log(Level.SEVERE, "Exception while closing replication channel consumer", ex);
}
}