From 6cbc27f5023058744284bd0c0ca87e065cecc7ed Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Mon, 22 Jan 2024 09:05:03 -0800 Subject: [PATCH] Capitalize enum. Signed-off-by: Yury-Fridlyand --- .../glide/api/models/configuration/Route.java | 25 +++++++++-------- .../java/glide/managers/CommandManager.java | 28 +++++++++---------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/java/client/src/main/java/glide/api/models/configuration/Route.java b/java/client/src/main/java/glide/api/models/configuration/Route.java index fc25248a1e..c48ea58bd8 100644 --- a/java/client/src/main/java/glide/api/models/configuration/Route.java +++ b/java/client/src/main/java/glide/api/models/configuration/Route.java @@ -10,39 +10,40 @@ public class Route { public enum RouteType { /** Route request to all nodes. */ - AllNodes, + ALL_NODES, /** Route request to all primary nodes. */ - AllPrimaries, + ALL_PRIMARIES, /** Route request to a random node. */ - Random, + RANDOM, /** Route request to the primary node that contains the slot with the given id. */ - PrimarySlotId, + PRIMARY_SLOT_ID, /** Route request to the replica node that contains the slot with the given id. */ - ReplicaSlotId, + REPLICA_SLOT_ID, /** Route request to the primary node that contains the slot that the given key matches. */ - PrimarySlotKey, + PRIMARY_SLOT_KEY, /** Route request to the replica node that contains the slot that the given key matches. */ - ReplicaSlotKey, + REPLICA_SLOT_KEY, } /** * Request routing configuration overrides the {@link ReadFrom} connection configuration.
- * If {@link RouteType#ReplicaSlotId} or {@link RouteType#ReplicaSlotKey} is used, the request + * If {@link RouteType#REPLICA_SLOT_ID} or {@link RouteType#REPLICA_SLOT_KEY} is used, the request * will be routed to a replica, even if the strategy is {@link ReadFrom#PRIMARY}. */ private final RouteType routeType; /** * Slot number. There are 16384 slots in a redis cluster, and each shard manages a slot range. - * Unless the slot is known, it's better to route using {@link RouteType#PrimarySlotKey} or {@link - * RouteType#ReplicaSlotKey}.
- * Could be used with {@link RouteType#PrimarySlotId} or {@link RouteType#ReplicaSlotId} only. + * Unless the slot is known, it's better to route using {@link RouteType#PRIMARY_SLOT_KEY} or + * {@link RouteType#REPLICA_SLOT_KEY}.
+ * Could be used with {@link RouteType#PRIMARY_SLOT_ID} or {@link RouteType#REPLICA_SLOT_ID} only. */ private final int slotId; /** * The request will be sent to nodes managing this key.
- * Could be used with {@link RouteType#PrimarySlotKey} or {@link RouteType#ReplicaSlotKey} only. + * Could be used with {@link RouteType#PRIMARY_SLOT_KEY} or {@link RouteType#REPLICA_SLOT_KEY} + * only. */ private final String slotKey; } diff --git a/java/client/src/main/java/glide/managers/CommandManager.java b/java/client/src/main/java/glide/managers/CommandManager.java index 73f4535321..518e400345 100644 --- a/java/client/src/main/java/glide/managers/CommandManager.java +++ b/java/client/src/main/java/glide/managers/CommandManager.java @@ -88,16 +88,16 @@ private RedisRequest.Builder prepareRedisRequest( RedisRequest.Builder builder = prepareRedisRequest(command, args); switch (route.getRouteType()) { - case Random: - case AllNodes: - case AllPrimaries: + case RANDOM: + case ALL_NODES: + case ALL_PRIMARIES: builder.setRoute( RedisRequestOuterClass.Routes.newBuilder() .setSimpleRoutes(getSimpleRoutes(route.getRouteType())) .build()); break; - case PrimarySlotKey: - case ReplicaSlotKey: + case PRIMARY_SLOT_KEY: + case REPLICA_SLOT_KEY: builder.setRoute( RedisRequestOuterClass.Routes.newBuilder() .setSlotKeyRoute( @@ -105,8 +105,8 @@ private RedisRequest.Builder prepareRedisRequest( .setSlotKey(route.getSlotKey()) .setSlotType(getSlotTypes(route.getRouteType())))); break; - case PrimarySlotId: - case ReplicaSlotId: + case PRIMARY_SLOT_ID: + case REPLICA_SLOT_ID: builder.setRoute( RedisRequestOuterClass.Routes.newBuilder() .setSlotIdRoute( @@ -127,11 +127,11 @@ private RedisRequestOuterClass.RequestType mapRequestTypes(RequestType inType) { private RedisRequestOuterClass.SimpleRoutes getSimpleRoutes(Route.RouteType routeType) { switch (routeType) { - case Random: + case RANDOM: return RedisRequestOuterClass.SimpleRoutes.Random; - case AllNodes: + case ALL_NODES: return RedisRequestOuterClass.SimpleRoutes.AllNodes; - case AllPrimaries: + case ALL_PRIMARIES: return RedisRequestOuterClass.SimpleRoutes.AllPrimaries; } throw new IllegalStateException("Unreachable code"); @@ -139,11 +139,11 @@ private RedisRequestOuterClass.SimpleRoutes getSimpleRoutes(Route.RouteType rout private RedisRequestOuterClass.SlotTypes getSlotTypes(Route.RouteType routeType) { switch (routeType) { - case PrimarySlotId: - case PrimarySlotKey: + case PRIMARY_SLOT_ID: + case PRIMARY_SLOT_KEY: return RedisRequestOuterClass.SlotTypes.Primary; - case ReplicaSlotId: - case ReplicaSlotKey: + case REPLICA_SLOT_ID: + case REPLICA_SLOT_KEY: return RedisRequestOuterClass.SlotTypes.Replica; } throw new IllegalStateException("Unreachable code");