@@ -739,10 +739,6 @@ func (r *Ring) ShuffleShard(identifier string, size int) ReadRing {
739
739
return r .shuffleShardWithCache (identifier , size , false )
740
740
}
741
741
742
- func (r * Ring ) ShuffleShardWithOperation (identifier string , size int ) ReadRing {
743
- return r .shuffleShardWithCache (identifier , size , false )
744
- }
745
-
746
742
func (r * Ring ) ShuffleShardWithZoneStability (identifier string , size int ) ReadRing {
747
743
return r .shuffleShardWithCache (identifier , size , true )
748
744
}
@@ -879,7 +875,27 @@ func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Dur
879
875
}
880
876
}
881
877
882
- return r .copyWithNewDesc (shard )
878
+ // Build a read-only ring for the shard.
879
+ shardDesc := & Desc {Ingesters : shard }
880
+ shardTokensByZone := shardDesc .getTokensByZone ()
881
+
882
+ return & Ring {
883
+ cfg : r .cfg ,
884
+ strategy : r .strategy ,
885
+ ringDesc : shardDesc ,
886
+ ringTokens : shardDesc .GetTokens (),
887
+ ringTokensByZone : shardTokensByZone ,
888
+ ringZones : getZones (shardTokensByZone ),
889
+ KVClient : r .KVClient ,
890
+
891
+ // We reference the original map as is in order to avoid copying. It's safe to do
892
+ // because this map is immutable by design and it's a superset of the actual instances
893
+ // with the subring.
894
+ ringInstanceByToken : r .ringInstanceByToken ,
895
+
896
+ // For caching to work, remember these values.
897
+ lastTopologyChange : r .lastTopologyChange ,
898
+ }
883
899
}
884
900
885
901
// GetInstanceState returns the current state of an instance or an error if the
@@ -960,48 +976,6 @@ func (r *Ring) setCachedShuffledSubring(identifier string, size int, zoneStableS
960
976
}
961
977
}
962
978
963
- // getRingForOperation Returns a new ring filtered for operation.
964
- // The ring read lock must be already taken when calling this function.
965
- func (r * Ring ) getRingForOperation (op Operation ) * Ring {
966
- //Avoid filtering if we are receiving default operation or empty ring
967
- if r .ringDesc == nil || len (r .ringDesc .Ingesters ) == 0 || op == Reporting {
968
- return r
969
- }
970
-
971
- instanceDescs := make (map [string ]InstanceDesc )
972
- for id , instance := range r .ringDesc .Ingesters {
973
- if op .IsInstanceInStateHealthy (instance .State ) {
974
- instanceDescs [id ] = instance
975
- }
976
- }
977
-
978
- return r .copyWithNewDesc (instanceDescs )
979
- }
980
-
981
- // copyWithNewDesc Return a new ring with updated data for different InstanceDesc
982
- func (r * Ring ) copyWithNewDesc (desc map [string ]InstanceDesc ) * Ring {
983
- shardDesc := & Desc {Ingesters : desc }
984
- shardTokensByZone := shardDesc .getTokensByZone ()
985
-
986
- return & Ring {
987
- cfg : r .cfg ,
988
- strategy : r .strategy ,
989
- ringDesc : shardDesc ,
990
- ringTokens : shardDesc .GetTokens (),
991
- ringTokensByZone : shardTokensByZone ,
992
- ringZones : getZones (shardTokensByZone ),
993
- KVClient : r .KVClient ,
994
-
995
- // We reference the original map as is in order to avoid copying. It's safe to do
996
- // because this map is immutable by design and it's a superset of the actual instances
997
- // with the subring.
998
- ringInstanceByToken : r .ringInstanceByToken ,
999
-
1000
- // For caching to work, remember these values.
1001
- lastTopologyChange : r .lastTopologyChange ,
1002
- }
1003
- }
1004
-
1005
979
func (r * Ring ) CleanupShuffleShardCache (identifier string ) {
1006
980
if r .cfg .SubringCacheDisabled {
1007
981
return
0 commit comments