use of org.finos.symphony.toolkit.stream.Participant in project spring-bot by finos.
the class SymphonyLeaderEventFilterIT method testMultipleStreamingConsumers.
@Test
public void testMultipleStreamingConsumers() throws InterruptedException {
List<SimpleEventConsumer> consumers = IntStream.range(0, 4).mapToObj(i -> new Participant("p" + i)).map(p -> new SimpleEventConsumer(p)).collect(Collectors.toList());
List<SymphonyStreamHandler> wrapped = consumers.stream().map(c -> {
lmh = new SymphonyRoomSharedLog(clusterName, streamId, messagesApi, "UNIT", 6000);
SymphonyStreamHandler out = new SymphonyStreamHandler(singleApi, c, ec, false);
out.setFilter(new SymphonyLeaderEventFilter(c.p, lmh));
out.start();
return out;
}).collect(Collectors.toList());
// send some messsages through
for (int j = 0; j < 8; j++) {
createLeaderEvent(j % 4);
for (int k = 0; k < 3; k++) {
createMessageEvent(k);
}
}
boolean done = false;
while (!done) {
Thread.sleep(2000);
done = consumers.stream().map(c -> c.collection.size() == 6).reduce(true, (a, b) -> a && b);
}
wrapped.stream().forEach(c -> c.stop());
}
use of org.finos.symphony.toolkit.stream.Participant in project spring-bot by finos.
the class SymphonySharedLogIT method testParticipantWrite.
@Test
public void testParticipantWrite() {
SymphonyRoomSharedLog ssl = new SymphonyRoomSharedLog(clusterName, streamId, messagesApi, "test", SymphonyRoomSharedLog.ONE_HOUR);
Participant p1 = new Participant("testing-participant-" + new Random(122).nextLong());
Participant p2 = new Participant("testing-participant-" + new Random(122).nextLong());
ssl.writeParticipantMessage(p1);
ssl.writeParticipantMessage(p2);
List<Participant> returned = ssl.getRecentParticipants();
Assertions.assertTrue(returned.contains(p1));
Assertions.assertTrue(returned.contains(p2));
}
use of org.finos.symphony.toolkit.stream.Participant in project spring-bot by finos.
the class SymphonySharedLogIT method testLeaderWrite.
@Test
public void testLeaderWrite() {
SymphonyRoomSharedLog ssl = new SymphonyRoomSharedLog(clusterName, streamId, messagesApi, "test", SymphonyRoomSharedLog.ONE_HOUR);
Participant p1 = new Participant("testing-participant-" + new Random(122).nextLong());
Participant p2 = new Participant("testing-participant-" + new Random(122).nextLong());
ssl.writeLeaderMessage(p1);
ssl.writeLeaderMessage(p2);
for (int i = 0; i < 30; i++) {
// sometimes takes a few tries to get the thing back
Optional<Participant> returned = ssl.getLastRecordedLeader(p1);
if (returned.isPresent()) {
Assertions.assertEquals(p2, returned.get());
return;
}
}
Assertions.fail("Didn't find leader");
}
use of org.finos.symphony.toolkit.stream.Participant in project spring-bot by finos.
the class SymphonyLeaderEventFilterIT method createLeaderEvent.
private void createLeaderEvent(int i) {
LogMessage lm = new LogMessage("test", new Participant("p" + i), LogMessageType.LEADER);
String messageMl = lmh.createMessageML(lm);
String json = lmh.serializeJson(lm);
messagesApi.v4StreamSidMessageCreatePost(null, streamId, messageMl, json, null, null, null, null);
}
use of org.finos.symphony.toolkit.stream.Participant in project spring-bot by finos.
the class SymphonySharedLogIT method testLocalLog.
@Test
public void testLocalLog() {
LocalConsoleOnlyLog ssl = new LocalConsoleOnlyLog();
Participant p1 = new Participant("testing-participant-" + new Random(122).nextLong());
Participant p2 = new Participant("testing-participant-" + new Random(122).nextLong());
ssl.writeParticipantMessage(p1);
ssl.writeLeaderMessage(p2);
List<Participant> returned = ssl.getRecentParticipants();
Assertions.assertTrue(returned.isEmpty());
}
Aggregations