Remove unused method from MessagesCache
This commit is contained in:
parent
3e01bc1174
commit
f58a320223
|
@ -87,8 +87,7 @@ public class MessagesCache extends RedisClusterPubSubAdapter<String, String> imp
|
||||||
private static final String REMOVE_TIMER_NAME = name(MessagesCache.class, "remove");
|
private static final String REMOVE_TIMER_NAME = name(MessagesCache.class, "remove");
|
||||||
|
|
||||||
private static final String REMOVE_METHOD_TAG = "method";
|
private static final String REMOVE_METHOD_TAG = "method";
|
||||||
private static final String REMOVE_METHOD_ID = "id";
|
private static final String REMOVE_METHOD_SENDER = "sender";
|
||||||
private static final String REMOVE_METHOD_SENDER = "sender";
|
|
||||||
private static final String REMOVE_METHOD_UUID = "uuid";
|
private static final String REMOVE_METHOD_UUID = "uuid";
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MessagesCache.class);
|
private static final Logger logger = LoggerFactory.getLogger(MessagesCache.class);
|
||||||
|
@ -164,25 +163,7 @@ public class MessagesCache extends RedisClusterPubSubAdapter<String, String> imp
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<OutgoingMessageEntity> remove(final UUID destinationUuid, final long destinationDevice, final long id) {
|
public Optional<OutgoingMessageEntity> remove(final UUID destinationUuid, final long destinationDevice, final String sender, final long timestamp) {
|
||||||
try {
|
|
||||||
final byte[] serialized = (byte[])Metrics.timer(REMOVE_TIMER_NAME, REMOVE_METHOD_TAG, REMOVE_METHOD_ID).record(() ->
|
|
||||||
removeByIdScript.executeBinary(List.of(getMessageQueueKey(destinationUuid, destinationDevice),
|
|
||||||
getMessageQueueMetadataKey(destinationUuid, destinationDevice),
|
|
||||||
getQueueIndexKey(destinationUuid, destinationDevice)),
|
|
||||||
List.of(String.valueOf(id).getBytes(StandardCharsets.UTF_8))));
|
|
||||||
|
|
||||||
if (serialized != null) {
|
|
||||||
return Optional.of(constructEntityFromEnvelope(id, MessageProtos.Envelope.parseFrom(serialized)));
|
|
||||||
}
|
|
||||||
} catch (final InvalidProtocolBufferException e) {
|
|
||||||
logger.warn("Failed to parse envelope", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<OutgoingMessageEntity> remove(final UUID destinationUuid, final long destinationDevice, final String sender, final long timestamp) {
|
|
||||||
try {
|
try {
|
||||||
final byte[] serialized = (byte[])Metrics.timer(REMOVE_TIMER_NAME, REMOVE_METHOD_TAG, REMOVE_METHOD_SENDER).record(() ->
|
final byte[] serialized = (byte[])Metrics.timer(REMOVE_TIMER_NAME, REMOVE_METHOD_TAG, REMOVE_METHOD_SENDER).record(() ->
|
||||||
removeBySenderScript.executeBinary(List.of(getMessageQueueKey(destinationUuid, destinationDevice),
|
removeBySenderScript.executeBinary(List.of(getMessageQueueKey(destinationUuid, destinationDevice),
|
||||||
|
|
|
@ -87,20 +87,6 @@ public class MessagesCacheTest extends AbstractRedisClusterTest {
|
||||||
assertEquals(firstId, secondId);
|
assertEquals(firstId, secondId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Parameters({"true", "false"})
|
|
||||||
public void testRemoveById(final boolean sealedSender) {
|
|
||||||
final UUID messageGuid = UUID.randomUUID();
|
|
||||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, sealedSender);
|
|
||||||
|
|
||||||
final long messageId = messagesCache.insert(messageGuid, DESTINATION_UUID, DESTINATION_DEVICE_ID, message);
|
|
||||||
final Optional<OutgoingMessageEntity> maybeRemovedMessage = messagesCache.remove(DESTINATION_UUID, DESTINATION_DEVICE_ID, messageId);
|
|
||||||
|
|
||||||
assertTrue(maybeRemovedMessage.isPresent());
|
|
||||||
assertEquals(MessagesCache.constructEntityFromEnvelope(messageId, message), maybeRemovedMessage.get());
|
|
||||||
assertEquals(Optional.empty(), messagesCache.remove(DESTINATION_UUID, DESTINATION_DEVICE_ID, messageId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveBySender() {
|
public void testRemoveBySender() {
|
||||||
final UUID messageGuid = UUID.randomUUID();
|
final UUID messageGuid = UUID.randomUUID();
|
||||||
|
|
Loading…
Reference in New Issue