Skip to content

Commit 91c52b1

Browse files
committed
Remove old code
Signed-off-by: Daniel Deluiggi <ddeluigg@amazon.com>
1 parent 7230e90 commit 91c52b1

File tree

2 files changed

+26
-52
lines changed

2 files changed

+26
-52
lines changed

pkg/compactor/shuffle_sharding_grouper_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,11 @@ func (r *RingMock) GetAllHealthy(op ring.Operation) (ring.ReplicationSet, error)
761761
return args.Get(0).(ring.ReplicationSet), args.Error(1)
762762
}
763763

764+
func (r *RingMock) GetInstanceDescsForOperation(op ring.Operation) (map[string]ring.InstanceDesc, error) {
765+
args := r.Called(op)
766+
return args.Get(0).(map[string]ring.InstanceDesc), args.Error(1)
767+
}
768+
764769
func (r *RingMock) GetAllInstanceDescs(op ring.Operation) ([]ring.InstanceDesc, []ring.InstanceDesc, error) {
765770
args := r.Called(op)
766771
return args.Get(0).([]ring.InstanceDesc), make([]ring.InstanceDesc, 0), args.Error(1)
@@ -789,11 +794,6 @@ func (r *RingMock) ShuffleShardWithZoneStability(identifier string, size int) ri
789794
return args.Get(0).(ring.ReadRing)
790795
}
791796

792-
func (r *RingMock) ShuffleShardWithOperation(identifier string, size int, op ring.Operation) ring.ReadRing {
793-
args := r.Called(identifier, size, op)
794-
return args.Get(0).(ring.ReadRing)
795-
}
796-
797797
func (r *RingMock) GetInstanceState(instanceID string) (ring.InstanceState, error) {
798798
args := r.Called(instanceID)
799799
return args.Get(0).(ring.InstanceState), args.Error(1)

pkg/ring/ring.go

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,6 @@ func (r *Ring) ShuffleShard(identifier string, size int) ReadRing {
739739
return r.shuffleShardWithCache(identifier, size, false)
740740
}
741741

742-
func (r *Ring) ShuffleShardWithOperation(identifier string, size int) ReadRing {
743-
return r.shuffleShardWithCache(identifier, size, false)
744-
}
745-
746742
func (r *Ring) ShuffleShardWithZoneStability(identifier string, size int) ReadRing {
747743
return r.shuffleShardWithCache(identifier, size, true)
748744
}
@@ -879,7 +875,27 @@ func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Dur
879875
}
880876
}
881877

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+
}
883899
}
884900

885901
// 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
960976
}
961977
}
962978

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-
1005979
func (r *Ring) CleanupShuffleShardCache(identifier string) {
1006980
if r.cfg.SubringCacheDisabled {
1007981
return

0 commit comments

Comments
 (0)