Skip to content

Commit 079eac4

Browse files
updated variable names
1 parent 9b6ad96 commit 079eac4

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/main/java/com/uid2/admin/salt/SaltRotation.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,22 @@ private void logSaltAges(String saltCountType, TargetDate targetDate, Collection
247247
}
248248
}
249249

250-
private void logBucketFormatCount(TargetDate targetDate, SaltEntry[] preRotationSalts, SaltEntry[] postRotationSalts) {
251-
int newKeyBucketCounter = 0, totalKeyBucketCounter = 0, totalSaltBucketCounter = 0;
252250

253-
for (int i = 0; i < preRotationSalts.length && i < postRotationSalts.length; i++) {
254-
var oldSalt = preRotationSalts[i];
255-
var updatedSalt = postRotationSalts[i];
251+
/** Logging to monitor migration of buckets from salts to keys **/
252+
private void logBucketFormatCount(TargetDate targetDate, SaltEntry[] preRotationBuckets, SaltEntry[] postRotationBuckets) {
253+
int migratedKeyBucketCounter = 0, totalKeyBucketCounter = 0, totalSaltBucketCounter = 0;
256254

257-
if (updatedSalt.currentKey() != null) totalKeyBucketCounter++;
258-
if (updatedSalt.currentSalt() != null) totalSaltBucketCounter++;
259-
if (updatedSalt.currentKey() != null && oldSalt.currentSalt() != null) newKeyBucketCounter++;
255+
for (int i = 0; i < preRotationBuckets.length && i < postRotationBuckets.length; i++) {
256+
var oldBucket = preRotationBuckets[i];
257+
var updatedBucket = postRotationBuckets[i];
258+
259+
if (updatedBucket.currentKey() != null) totalKeyBucketCounter++;
260+
if (updatedBucket.currentSalt() != null) totalSaltBucketCounter++;
261+
if (updatedBucket.currentKey() != null && oldBucket.currentSalt() != null) migratedKeyBucketCounter++;
260262
}
261263

262-
LOGGER.info("Salt rotation bucket format: target_date={} new_key_bucket_count={} total_key_bucket_count={} total_salt_bucket_count={}",
263-
targetDate, newKeyBucketCounter, totalKeyBucketCounter, totalSaltBucketCounter);
264+
LOGGER.info("Rotation bucket format: target_date={} migrated_key_bucket_count={} total_key_bucket_count={} total_salt_bucket_count={}",
265+
targetDate, migratedKeyBucketCounter, totalKeyBucketCounter, totalSaltBucketCounter);
264266
}
265267

266268
@Getter

src/test/java/com/uid2/admin/salt/SaltRotationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void testKeyRotationSaltToKeyRotation() throws Exception {
732732
"true, 1, 3, 1",
733733
"false, 0, 1, 3"
734734
})
735-
void testKeyRotationLogKeyBuckets(boolean v4Enabled, int expectedNewKeyBuckets, int expectedTotalKeyBuckets, int expectedTotalSaltBuckets) throws Exception {
735+
void testKeyRotationLogBucketFormat(boolean v4Enabled, int expectedNewKeyBuckets, int expectedTotalKeyBuckets, int expectedTotalSaltBuckets) throws Exception {
736736
saltRotation = new SaltRotation(keyGenerator, JsonObject.of(AdminConst.ENABLE_V4_RAW_UID, v4Enabled));
737737
when(keyGenerator.generateRandomKeyString(anyInt())).thenReturn("random-key-string");
738738

@@ -752,10 +752,10 @@ void testKeyRotationLogKeyBuckets(boolean v4Enabled, int expectedNewKeyBuckets,
752752
saltRotation.rotateSalts(lastSnapshot, minAges, 1, targetDate());
753753

754754
var expected = Set.of(
755-
String.format("[INFO] Salt rotation bucket format: target_date=2025-01-01 new_key_bucket_count=%d total_key_bucket_count=%d total_salt_bucket_count=%d",
755+
String.format("[INFO] Rotation bucket format: target_date=2025-01-01 migrated_key_bucket_count=%d total_key_bucket_count=%d total_salt_bucket_count=%d",
756756
expectedNewKeyBuckets, expectedTotalKeyBuckets, expectedTotalSaltBuckets)
757757
);
758-
var actual = appender.list.stream().map(Object::toString).filter(s -> s.contains("Salt rotation bucket format")).collect(Collectors.toSet());
758+
var actual = appender.list.stream().map(Object::toString).filter(s -> s.contains("Rotation bucket format")).collect(Collectors.toSet());
759759
assertThat(actual).isEqualTo(expected);
760760
}
761761
}

0 commit comments

Comments
 (0)