From cbdec0cb228b1fc669130b7542ac9b66adab75f1 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Wed, 10 Nov 2021 10:33:29 -0500 Subject: [PATCH] Remove legacy push latency measurement pathways --- .../metrics/PushLatencyManager.java | 24 +++-------------- .../metrics/PushLatencyManagerTest.java | 27 ------------------- 2 files changed, 3 insertions(+), 48 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManager.java index 29a01a35e..e0d741e5e 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManager.java @@ -152,7 +152,6 @@ public class PushLatencyManager { @VisibleForTesting CompletableFuture 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 getFuture = connection.async().get(key).toCompletableFuture() @@ -168,34 +167,17 @@ public class PushLatencyManager { } }); - final CompletableFuture 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 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; - } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManagerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManagerTest.java index 5be6ea879..900d4cc65 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManagerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/metrics/PushLatencyManagerTest.java @@ -18,7 +18,6 @@ import java.util.Collections; import java.util.UUID; import java.util.concurrent.ExecutionException; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -71,30 +70,4 @@ class PushLatencyManagerTest { assertNull(pushLatencyManager.takePushRecord(accountUuid, deviceId).get()); } - - @Test - void testTakeLegacyRecord() throws ExecutionException, InterruptedException { - final UUID accountUuid = UUID.randomUUID(); - final long deviceId = 1; - - final Instant pushTimestamp = Instant.ofEpochMilli(123456789); - - final PushLatencyManager pushLatencyManager = new PushLatencyManager(REDIS_CLUSTER_EXTENSION.getRedisCluster(), - dynamicConfigurationManager, Clock.fixed(pushTimestamp, ZoneId.systemDefault())); - - assertNull(pushLatencyManager.takePushRecord(accountUuid, deviceId).get()); - - // Inject a legacy record - REDIS_CLUSTER_EXTENSION.getRedisCluster().useCluster(connection -> - connection.sync().set(PushLatencyManager.getLegacyFirstUnacknowledgedPushKey(accountUuid, deviceId), - String.valueOf(pushTimestamp.toEpochMilli()))); - - final PushRecord pushRecord = pushLatencyManager.takePushRecord(accountUuid, deviceId).get(); - - assertNotNull(pushRecord); - assertEquals(pushTimestamp, pushRecord.getTimestamp()); - assertNull(pushRecord.getPushType()); - - assertNull(pushLatencyManager.takePushRecord(accountUuid, deviceId).get()); - } }