Skip to content

Commit

Permalink
Patch: resuse history listener for concurrent fwd and rev consumer tr…
Browse files Browse the repository at this point in the history
…ansitions
  • Loading branch information
Sunjeet committed Apr 16, 2022
1 parent 0056c32 commit d4d3dbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ private static HollowHistory createHistory(HollowConsumer consumerFwd, HollowCon
try {
HollowHistory history = new HollowHistory(consumerFwd.getStateEngine(), consumerRev.getStateEngine(),
consumerFwd.getCurrentVersionId(), consumerRev.getCurrentVersionId(), numStatesToTrack);
consumerFwd.addRefreshListener(new HollowHistoryRefreshListener(history));
consumerRev.addRefreshListener(new HollowHistoryRefreshListener(history));
HollowHistoryRefreshListener listener = new HollowHistoryRefreshListener(history);
consumerFwd.addRefreshListener(listener);
consumerRev.addRefreshListener(listener);
return history;
} finally {
consumerFwd.getRefreshLock().unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ public HollowHistoryUIServer(HollowConsumer consumer, int port, TimeZone timeZon
* Serves HollowHistoryUI that supports building history in both directions simultaneously.
* Fwd and rev consumers should be initialized to the same version before calling this constructor.
* Attempting double snapshots or forward version transitions on consumerRev will have unintended consequences on history.
* This constructor defaults max states to 1024 and time zone to PST.
*
* @param consumerFwd HollowConsumer (already initialized with data) that will be traversing forward deltas
* @param consumerRev HollowConsumer (also initialized to the same version as consumerFwd) that will be traversing reverse deltas
* @param port server port
*/
public HollowHistoryUIServer(HollowConsumer consumerFwd, HollowConsumer consumerRev, int port) {
this(new HollowHistoryUI("", consumerFwd, consumerRev), port);
this(consumerFwd, consumerRev, 1024, port, VersionTimestampConverter.PACIFIC_TIMEZONE);
}

public HollowHistoryUIServer(HollowConsumer consumerFwd, HollowConsumer consumerRev, int numStatesToTrack, int port, TimeZone timeZone) {
this(new HollowHistoryUI("", consumerFwd, consumerRev, numStatesToTrack, timeZone), port);
}

public HollowHistoryUIServer(HollowConsumer consumer, int numStatesToTrack, int port, TimeZone timeZone) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static void createDeltaChain(TestBlobRetriever testBlobRetriever) throws
writer.writeDelta(baos_v2_to_v3);
writer.writeReverseDelta(baos_v3_to_v2);
testBlobRetriever.addSnapshot(3, new TestBlob(3,new ByteArrayInputStream(baos_v3.toByteArray())));
testBlobRetriever.addDelta(2, new TestBlob(2, 2, new ByteArrayInputStream(baos_v2_to_v3.toByteArray())));
testBlobRetriever.addDelta(2, new TestBlob(2, 3, new ByteArrayInputStream(baos_v2_to_v3.toByteArray())));
testBlobRetriever.addReverseDelta(3, new TestBlob(3, 2, new ByteArrayInputStream(baos_v3_to_v2.toByteArray())));

// v4
Expand Down

0 comments on commit d4d3dbe

Please sign in to comment.