-
Notifications
You must be signed in to change notification settings - Fork 7
circuit breaker refactored #264
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
Closed
Closed
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
fa305b8
fix test
Ian-Nara 695f6b4
threshold in reading
Ian-Nara 9dab244
factgoring in the queue attributes adjustment
Ian-Nara 0fbbc6f
[CI Pipeline] Released Snapshot version: 4.5.1-alpha-114-SNAPSHOT
18262c3
Update .trivyignore
Ian-Nara f7cecde
[CI Pipeline] Released Snapshot version: 4.5.2-alpha-115-SNAPSHOT
104860f
Merge branch 'ian-UID2-6151-add-traffic-filter-class' into ian-UID2-6…
Ian-Nara 663abd3
Merge branch 'ian-UID2-6345-circuit-breaker' of github.com:IABTechLab…
Ian-Nara d23c792
update naming
Ian-Nara d03eb73
[CI Pipeline] Released Snapshot version: 4.5.3-alpha-117-SNAPSHOT
b09ac28
update logging
Ian-Nara 980c055
Merge branch 'ian-UID2-6345-circuit-breaker' of github.com:IABTechLab…
Ian-Nara de8ae4a
[CI Pipeline] Released Snapshot version: 4.5.4-alpha-118-SNAPSHOT
7603858
Update name
Ian-Nara c867bd5
Merge branch 'ian-UID2-6345-circuit-breaker' of github.com:IABTechLab…
Ian-Nara b4bd7c8
Merge branch 'ian-UID2-6151-add-traffic-filter-class' into ian-UID2-6…
Ian-Nara 29a16ac
remove if block for DEFAULT
Ian-Nara a200825
[CI Pipeline] Released Snapshot version: 4.5.5-alpha-119-SNAPSHOT
bcf1709
[CI Pipeline] Released Snapshot version: 4.5.6-alpha-120-SNAPSHOT
5b7124e
commons logging missing?
Ian-Nara b807339
Merge branch 'ian-UID2-6345-circuit-breaker' of github.com:IABTechLab…
Ian-Nara 1e63135
[CI Pipeline] Released Snapshot version: 4.5.7-alpha-121-SNAPSHOT
b22ea64
Merge branch 'main' into ian-UID2-6345-circuit-breaker
Ian-Nara 5442674
whitespace
Ian-Nara 1697197
Merge branch 'ian-UID2-6345-circuit-breaker' of github.com:IABTechLab…
Ian-Nara d2364e0
improve config error logging details
Ian-Nara 03fe8a9
[CI Pipeline] Released Snapshot version: 4.5.8-alpha-122-SNAPSHOT
1bc84d5
remove unneeded variable
Ian-Nara dd57abc
Merge branch 'ian-UID2-6345-circuit-breaker' of github.com:IABTechLab…
Ian-Nara b85a017
refactoring circuit breaker and delta producer
Ian-Nara a2b3439
update comments
Ian-Nara fa1bd62
more refactoring
Ian-Nara 6dbccec
update logging
Ian-Nara da7ac07
update logging and tests
Ian-Nara c6be5a1
update test
Ian-Nara 521118d
update logging
Ian-Nara 51b59a4
update traffic calculator
Ian-Nara daf4d84
update test
Ian-Nara a05eb90
logging in lowercase
Ian-Nara 0a0790a
test format
Ian-Nara 28d20d6
git diff detect file move
Ian-Nara b5793e0
git diff detect filel move
Ian-Nara 64c244c
update test
Ian-Nara 3a72d0f
update test
Ian-Nara 65d811b
file rename/relocate
Ian-Nara 04654af
move files
Ian-Nara aadf9c6
[CI Pipeline] Released Snapshot version: 4.5.9-alpha-123-SNAPSHOT
8aeb191
improve calculator visibility
Ian-Nara 24b0d69
Merge branch 'ian-UID2-6345-circuit-breaker-refactored' of github.com…
Ian-Nara f1f252f
[CI Pipeline] Released Snapshot version: 4.5.10-alpha-124-SNAPSHOT
d3a121b
update logging
Ian-Nara 9da20ee
Merge branch 'ian-UID2-6345-circuit-breaker-refactored' of github.com…
Ian-Nara 01474e4
[CI Pipeline] Released Snapshot version: 4.5.11-alpha-126-SNAPSHOT
e8a8f1a
fix traffic calulator processing too many files
Ian-Nara 5ea93f2
Merge branch 'ian-UID2-6345-circuit-breaker-refactored' of github.com…
Ian-Nara e3a8085
[CI Pipeline] Released Snapshot version: 4.5.12-alpha-127-SNAPSHOT
337ca99
use sliding window, not fixed boundaries
Ian-Nara d0511da
denylisted deduplication
Ian-Nara acf87c6
Merge branch 'ian-UID2-6345-circuit-breaker-refactored' of github.com…
Ian-Nara 9e8e6ab
increase calculator accuracy
Ian-Nara 5b99a60
[CI Pipeline] Released Snapshot version: 4.5.13-alpha-128-SNAPSHOT
df98d9d
improve calculator logs and visibility
Ian-Nara 7282a03
standardizing logs
Ian-Nara 98b386b
Merge branch 'ian-UID2-6345-circuit-breaker-refactored' of github.com…
Ian-Nara bf665a0
standardize error logging for alerts
Ian-Nara e31e2b3
add todos
Ian-Nara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/main/java/com/uid2/optout/delta/DeltaFileWriter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| package com.uid2.optout.delta; | ||
|
|
||
| import com.uid2.shared.optout.OptOutConst; | ||
| import com.uid2.shared.optout.OptOutEntry; | ||
| import com.uid2.shared.optout.OptOutUtils; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.IOException; | ||
| import java.nio.ByteBuffer; | ||
| import java.nio.ByteOrder; | ||
|
|
||
| /** | ||
| * Handles binary writing of delta file entries. | ||
| * | ||
| * Delta files have the following format: | ||
| * - Start entry: null hash (32 bytes) + null hash (32 bytes) + timestamp (8 bytes) | ||
| * - Opt-out entries: hash (32 bytes) + id (32 bytes) + timestamp (7 bytes) + metadata (1 byte) | ||
| * - End entry: ones hash (32 bytes) + ones hash (32 bytes) + timestamp (8 bytes) | ||
| * | ||
| * Each entry is 72 bytes (OptOutConst.EntrySize) | ||
| */ | ||
| public class DeltaFileWriter { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(DeltaFileWriter.class); | ||
|
|
||
| private ByteBuffer buffer; | ||
|
|
||
| /** | ||
| * Create a DeltaFileWriter with the specified initial buffer size. | ||
| * | ||
| * @param bufferSize Initial buffer size in bytes | ||
| */ | ||
| public DeltaFileWriter(int bufferSize) { | ||
| this.buffer = ByteBuffer.allocate(bufferSize).order(ByteOrder.LITTLE_ENDIAN); | ||
| } | ||
|
|
||
| /** | ||
| * Write the start-of-delta sentinel entry. | ||
| * Uses null hash bytes and the window start timestamp. | ||
| * | ||
| * @param stream Output stream to write to | ||
| * @param windowStart Window start timestamp (epoch seconds) | ||
| * @throws IOException if write fails | ||
| */ | ||
| public void writeStartOfDelta(ByteArrayOutputStream stream, long windowStart) throws IOException { | ||
| ensureCapacity(OptOutConst.EntrySize); | ||
|
|
||
| buffer.put(OptOutUtils.nullHashBytes); | ||
| buffer.put(OptOutUtils.nullHashBytes); | ||
| buffer.putLong(windowStart); | ||
|
|
||
| flushToStream(stream); | ||
| } | ||
|
|
||
| /** | ||
| * Write a single opt-out entry. | ||
| * | ||
| * @param stream Output stream to write to | ||
| * @param hashBytes Hash bytes (32 bytes) | ||
| * @param idBytes ID bytes (32 bytes) | ||
| * @param timestamp Entry timestamp (epoch seconds) | ||
| * @throws IOException if write fails | ||
| */ | ||
| public void writeOptOutEntry(ByteArrayOutputStream stream, byte[] hashBytes, byte[] idBytes, long timestamp) throws IOException { | ||
| ensureCapacity(OptOutConst.EntrySize); | ||
|
|
||
| OptOutEntry.writeTo(buffer, hashBytes, idBytes, timestamp); | ||
|
|
||
| flushToStream(stream); | ||
| } | ||
|
|
||
| /** | ||
| * Write the end-of-delta sentinel entry. | ||
| * Uses ones hash bytes and the window end timestamp. | ||
| * | ||
| * @param stream Output stream to write to | ||
| * @param windowEnd Window end timestamp (epoch seconds) | ||
| * @throws IOException if write fails | ||
| */ | ||
| public void writeEndOfDelta(ByteArrayOutputStream stream, long windowEnd) throws IOException { | ||
| ensureCapacity(OptOutConst.EntrySize); | ||
|
|
||
| buffer.put(OptOutUtils.onesHashBytes); | ||
| buffer.put(OptOutUtils.onesHashBytes); | ||
| buffer.putLong(windowEnd); | ||
|
|
||
| flushToStream(stream); | ||
| } | ||
|
|
||
| /** | ||
| * Flush the buffer contents to the output stream and clear the buffer. | ||
| */ | ||
| private void flushToStream(ByteArrayOutputStream stream) throws IOException { | ||
| buffer.flip(); | ||
| byte[] entry = new byte[buffer.remaining()]; | ||
| buffer.get(entry); | ||
| stream.write(entry); | ||
| buffer.clear(); | ||
| } | ||
|
|
||
| /** | ||
| * Ensure buffer has sufficient capacity, expanding if necessary. | ||
| */ | ||
| private void ensureCapacity(int dataSize) { | ||
| if (buffer.capacity() < dataSize) { | ||
| int newCapacity = Integer.highestOneBit(dataSize) << 1; | ||
| LOGGER.info("expanding buffer size: current {}, need {}, new {}", buffer.capacity(), dataSize, newCapacity); | ||
| this.buffer = ByteBuffer.allocate(newCapacity).order(ByteOrder.LITTLE_ENDIAN); | ||
| } | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/com/uid2/optout/delta/DeltaProductionMetrics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package com.uid2.optout.delta; | ||
|
|
||
| import io.micrometer.core.instrument.Counter; | ||
| import io.micrometer.core.instrument.Metrics; | ||
|
|
||
| /** | ||
| * Metrics counters for delta production operations. | ||
| * | ||
| * Tracks: | ||
| * - Number of delta files produced | ||
| * - Number of opt-out entries processed | ||
| * - Number of dropped request files produced | ||
| * - Number of dropped requests processed | ||
| */ | ||
| public class DeltaProductionMetrics { | ||
|
|
||
| private final Counter deltasProduced; | ||
| private final Counter entriesProcessed; | ||
| private final Counter droppedRequestFilesProduced; | ||
| private final Counter droppedRequestsProcessed; | ||
|
|
||
| public DeltaProductionMetrics() { | ||
| this.deltasProduced = Counter | ||
| .builder("uid2_optout_sqs_delta_produced_total") | ||
| .description("counter for how many optout delta files are produced from SQS") | ||
| .register(Metrics.globalRegistry); | ||
|
|
||
| this.entriesProcessed = Counter | ||
| .builder("uid2_optout_sqs_entries_processed_total") | ||
| .description("counter for how many optout entries are processed from SQS") | ||
| .register(Metrics.globalRegistry); | ||
|
|
||
| this.droppedRequestFilesProduced = Counter | ||
| .builder("uid2_optout_sqs_dropped_request_files_produced_total") | ||
| .description("counter for how many optout dropped request files are produced from SQS") | ||
| .register(Metrics.globalRegistry); | ||
|
|
||
| this.droppedRequestsProcessed = Counter | ||
| .builder("uid2_optout_sqs_dropped_requests_processed_total") | ||
| .description("counter for how many optout dropped requests are processed from SQS") | ||
| .register(Metrics.globalRegistry); | ||
| } | ||
|
|
||
| /** | ||
| * Record that a delta file was produced with the given number of entries. | ||
| */ | ||
| public void recordDeltaProduced(int entryCount) { | ||
| deltasProduced.increment(); | ||
| entriesProcessed.increment(entryCount); | ||
| } | ||
|
|
||
| /** | ||
| * Record that a dropped requests file was produced with the given number of entries. | ||
| */ | ||
| public void recordDroppedRequestsProduced(int requestCount) { | ||
| droppedRequestFilesProduced.increment(); | ||
| droppedRequestsProcessed.increment(requestCount); | ||
| } | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is due to uid2-shared version update:
cabdce5