Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add to version tag to header on producer side #648

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ long runCycle(
} else {
writeEngine.getHeaderTags().remove(HollowStateEngine.HEADER_TAG_SCHEMA_CHANGE);
}
writeEngine.addHeaderTag(HollowStateEngine.HEADER_TAG_PRODUCER_TO_VERSION, String.valueOf(toVersion));
Copy link
Contributor

@Sunjeet Sunjeet Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reverse delta header is a special case. When running cycle v2 we want the reverse delta header to have
hollow.producer.to.version=v1
and I think that should be getting handled already here but its worth testing this out and if possible write a unit test, maybe here


// 3a. Publish, run checks & validation, then announce new state consumers
publish(listeners, toVersion, artifacts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public interface HollowStateEngine extends HollowDataset {
* */
String HEADER_TAG_METRIC_ANNOUNCEMENT = "hollow.metric.announcement";

/**
* A header tag indicating which version is this blob produce to.
*/
String HEADER_TAG_PRODUCER_TO_VERSION = "hollow.blob.to.version";

@Override
List<HollowSchema> getSchemas();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.netflix.hollow.core.util;

import static com.netflix.hollow.core.HollowStateEngine.HEADER_TAG_METRIC_CYCLE_START;
import static com.netflix.hollow.core.HollowStateEngine.HEADER_TAG_PRODUCER_TO_VERSION;
import static org.junit.Assert.assertEquals;

import com.netflix.hollow.api.objects.generic.GenericHollowObject;
Expand All @@ -42,11 +43,15 @@ public void recreatesUsingReadEngine() throws IOException {
mapper.add(new Integer(1));
writeEngine.addHeaderTag("CopyTag", "copied");
writeEngine.addHeaderTag(HEADER_TAG_METRIC_CYCLE_START, String.valueOf(System.currentTimeMillis()));
String toVersion = String.valueOf(System.currentTimeMillis());
writeEngine.addHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION, toVersion);

HollowReadStateEngine readEngine = StateEngineRoundTripper.roundTripSnapshot(writeEngine);
String cycleStartTime = readEngine.getHeaderTag(HEADER_TAG_METRIC_CYCLE_START);
String readEngineToVersion = readEngine.getHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION);
HollowWriteStateEngine recreatedWriteEngine = HollowWriteStateCreator.recreateAndPopulateUsingReadEngine(readEngine);
assertEquals(cycleStartTime, recreatedWriteEngine.getPreviousHeaderTags().get(HEADER_TAG_METRIC_CYCLE_START));
assertEquals(readEngineToVersion, recreatedWriteEngine.getPreviousHeaderTags().get(HEADER_TAG_PRODUCER_TO_VERSION));

HollowReadStateEngine recreatedReadEngine = StateEngineRoundTripper.roundTripSnapshot(recreatedWriteEngine);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.netflix.hollow.core.write;

import static com.netflix.hollow.core.HollowStateEngine.HEADER_TAG_PRODUCER_TO_VERSION;
import static org.junit.Assert.assertEquals;

import com.netflix.hollow.api.consumer.HollowConsumer;
Expand Down Expand Up @@ -57,8 +58,11 @@ public void testHeaderTagsOnDeltaAndReverseDelta() {

consumer.triggerRefreshTo(version3); // delta transition
assertEquals("3", consumer.getStateEngine().getHeaderTag(TEST_TAG));
assertEquals(String.valueOf(version3), consumer.getStateEngine().getHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION));

consumer.triggerRefreshTo(version2); // reverse delta transition
assertEquals("2", consumer.getStateEngine().getHeaderTag(TEST_TAG));
assertEquals(String.valueOf(version2), consumer.getStateEngine().getHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION));

}
}
Loading