@@ -997,6 +997,108 @@ public Map<String, CommandInfo> build(Object data) {
997
997
}
998
998
};
999
999
1000
+ private static final Builder <List <List <Long >>> CLUSTER_SHARD_SLOTS_RANGES = new Builder <List <List <Long >>>() {
1001
+
1002
+ @ Override
1003
+ public List <List <Long >> build (Object data ) {
1004
+ if (null == data ) {
1005
+ return null ;
1006
+ }
1007
+
1008
+ List <Long > rawSlots = (List <Long >) data ;
1009
+ List <List <Long >> slotsRanges = new ArrayList <>();
1010
+ for (int i = 0 ; i < rawSlots .size (); i += 2 ) {
1011
+ slotsRanges .add (Arrays .asList (rawSlots .get (i ), rawSlots .get (i + 1 )));
1012
+ }
1013
+ return slotsRanges ;
1014
+ }
1015
+ };
1016
+
1017
+ private static final Builder <List <ClusterShardNodeInfo >> CLUSTER_SHARD_NODE_INFO_LIST
1018
+ = new Builder <List <ClusterShardNodeInfo >>() {
1019
+
1020
+ final Map <String , Builder > mappingFunctions = createDecoderMap ();
1021
+
1022
+ private Map <String , Builder > createDecoderMap () {
1023
+
1024
+ Map <String , Builder > tempMappingFunctions = new HashMap <>();
1025
+ tempMappingFunctions .put (ClusterShardNodeInfo .ID , STRING );
1026
+ tempMappingFunctions .put (ClusterShardNodeInfo .ENDPOINT , STRING );
1027
+ tempMappingFunctions .put (ClusterShardNodeInfo .IP , STRING );
1028
+ tempMappingFunctions .put (ClusterShardNodeInfo .HOSTNAME , STRING );
1029
+ tempMappingFunctions .put (ClusterShardNodeInfo .PORT , LONG );
1030
+ tempMappingFunctions .put (ClusterShardNodeInfo .TLS_PORT , LONG );
1031
+ tempMappingFunctions .put (ClusterShardNodeInfo .ROLE , STRING );
1032
+ tempMappingFunctions .put (ClusterShardNodeInfo .REPLICATION_OFFSET , LONG );
1033
+ tempMappingFunctions .put (ClusterShardNodeInfo .HEALTH , STRING );
1034
+
1035
+ return tempMappingFunctions ;
1036
+ }
1037
+
1038
+ @ Override
1039
+ @ SuppressWarnings ("unchecked" )
1040
+ public List <ClusterShardNodeInfo > build (Object data ) {
1041
+ if (null == data ) {
1042
+ return null ;
1043
+ }
1044
+
1045
+ List <ClusterShardNodeInfo > response = new ArrayList <>();
1046
+
1047
+ List <Object > clusterShardNodeInfos = (List <Object >) data ;
1048
+ for (Object clusterShardNodeInfoObject : clusterShardNodeInfos ) {
1049
+ List <Object > clusterShardNodeInfo = (List <Object >) clusterShardNodeInfoObject ;
1050
+ Iterator <Object > iterator = clusterShardNodeInfo .iterator ();
1051
+ response .add (new ClusterShardNodeInfo (createMapFromDecodingFunctions (iterator , mappingFunctions )));
1052
+ }
1053
+
1054
+ return response ;
1055
+ }
1056
+
1057
+ @ Override
1058
+ public String toString () {
1059
+ return "List<ClusterShardNodeInfo>" ;
1060
+ }
1061
+ };
1062
+
1063
+ public static final Builder <List <ClusterShardInfo >> CLUSTER_SHARD_INFO_LIST
1064
+ = new Builder <List <ClusterShardInfo >>() {
1065
+
1066
+ final Map <String , Builder > mappingFunctions = createDecoderMap ();
1067
+
1068
+ private Map <String , Builder > createDecoderMap () {
1069
+
1070
+ Map <String , Builder > tempMappingFunctions = new HashMap <>();
1071
+ tempMappingFunctions .put (ClusterShardInfo .SLOTS , CLUSTER_SHARD_SLOTS_RANGES );
1072
+ tempMappingFunctions .put (ClusterShardInfo .NODES , CLUSTER_SHARD_NODE_INFO_LIST );
1073
+
1074
+ return tempMappingFunctions ;
1075
+ }
1076
+
1077
+ @ Override
1078
+ @ SuppressWarnings ("unchecked" )
1079
+ public List <ClusterShardInfo > build (Object data ) {
1080
+ if (null == data ) {
1081
+ return null ;
1082
+ }
1083
+
1084
+ List <ClusterShardInfo > response = new ArrayList <>();
1085
+
1086
+ List <Object > clusterShardInfos = (List <Object >) data ;
1087
+ for (Object clusterShardInfoObject : clusterShardInfos ) {
1088
+ List <Object > clusterShardInfo = (List <Object >) clusterShardInfoObject ;
1089
+ Iterator <Object > iterator = clusterShardInfo .iterator ();
1090
+ response .add (new ClusterShardInfo (createMapFromDecodingFunctions (iterator , mappingFunctions )));
1091
+ }
1092
+
1093
+ return response ;
1094
+ }
1095
+
1096
+ @ Override
1097
+ public String toString () {
1098
+ return "List<ClusterShardInfo>" ;
1099
+ }
1100
+ };
1101
+
1000
1102
public static final Builder <List <Module >> MODULE_LIST = new Builder <List <Module >>() {
1001
1103
@ Override
1002
1104
public List <Module > build (Object data ) {
0 commit comments