Remove legacy push latency measurement pathways

This commit is contained in:
Jon Chambers
2021-11-10 10:33:29 -05:00
committed by Jon Chambers
parent de6e9d31c9
commit cbdec0cb22
2 changed files with 3 additions and 48 deletions

View File

@@ -152,7 +152,6 @@ public class PushLatencyManager {
@VisibleForTesting
CompletableFuture<PushRecord> takePushRecord(final UUID accountUuid, final long deviceId) {
final String key = getFirstUnacknowledgedPushKey(accountUuid, deviceId);
final String legacyKey = getLegacyFirstUnacknowledgedPushKey(accountUuid, deviceId);
return redisCluster.withCluster(connection -> {
final CompletableFuture<PushRecord> getFuture = connection.async().get(key).toCompletableFuture()
@@ -168,34 +167,17 @@ public class PushLatencyManager {
}
});
final CompletableFuture<PushRecord> legacyGetFuture = connection.async().get(legacyKey).toCompletableFuture()
.thenApply(timestampString -> {
if (StringUtils.isNotEmpty(timestampString)) {
return new PushRecord(Instant.ofEpochMilli(Long.parseLong(timestampString)), null);
} else {
return null;
}
});
final CompletableFuture<PushRecord> pushRecordFuture = getFuture.thenCombine(legacyGetFuture,
(a, b) -> a != null ? a : b);
pushRecordFuture.whenComplete((record, cause) -> {
getFuture.whenComplete((record, cause) -> {
if (cause == null) {
connection.async().del(key, legacyKey);
connection.async().del(key);
}
});
return pushRecordFuture;
return getFuture;
});
}
private static String getFirstUnacknowledgedPushKey(final UUID accountUuid, final long deviceId) {
return "push_latency::v2::" + accountUuid.toString() + "::" + deviceId;
}
@VisibleForTesting
static String getLegacyFirstUnacknowledgedPushKey(final UUID accountUuid, final long deviceId) {
return "push_latency::" + accountUuid.toString() + "::" + deviceId;
}
}