@@ -9,7 +9,7 @@ type ReplicationStrategy interface {
99	// Filter out unhealthy instances and checks if there're enough instances 
1010	// for an operation to succeed. Returns an error if there are not enough 
1111	// instances. 
12- 	Filter (instances  []IngesterDesc , op  Operation , replicationFactor  int , heartbeatTimeout  time.Duration ) (healthy  []IngesterDesc , maxFailures  int , err  error )
12+ 	Filter (instances  []IngesterDesc , op  Operation , replicationFactor  int , heartbeatTimeout  time.Duration ,  zoneAwarenessEnabled   bool ) (healthy  []IngesterDesc , maxFailures  int , err  error )
1313
1414	// ShouldExtendReplicaSet returns true if given an instance that's going to be 
1515	// added to the replica set, the replica set size should be extended by 1 
@@ -25,7 +25,7 @@ type DefaultReplicationStrategy struct{}
2525// - Filters out dead ingesters so the one doesn't even try to write to them. 
2626// - Checks there is enough ingesters for an operation to succeed. 
2727// The ingesters argument may be overwritten. 
28- func  (s  * DefaultReplicationStrategy ) Filter (ingesters  []IngesterDesc , op  Operation , replicationFactor  int , heartbeatTimeout  time.Duration ) ([]IngesterDesc , int , error ) {
28+ func  (s  * DefaultReplicationStrategy ) Filter (ingesters  []IngesterDesc , op  Operation , replicationFactor  int , heartbeatTimeout  time.Duration ,  zoneAwarenessEnabled   bool ) ([]IngesterDesc , int , error ) {
2929	// We need a response from a quorum of ingesters, which is n/2 + 1.  In the 
3030	// case of a node joining/leaving, the actual replica set might be bigger 
3131	// than the replication factor, so use the bigger or the two. 
@@ -49,8 +49,14 @@ func (s *DefaultReplicationStrategy) Filter(ingesters []IngesterDesc, op Operati
4949	// This is just a shortcut - if there are not minSuccess available ingesters, 
5050	// after filtering out dead ones, don't even bother trying. 
5151	if  len (ingesters ) <  minSuccess  {
52- 		err  :=  fmt .Errorf ("at least %d live replicas required, could only find %d" ,
53- 			minSuccess , len (ingesters ))
52+ 		var  err  error 
53+ 
54+ 		if  zoneAwarenessEnabled  {
55+ 			err  =  fmt .Errorf ("at least %d live replicas required across different availability zones, could only find %d" , minSuccess , len (ingesters ))
56+ 		} else  {
57+ 			err  =  fmt .Errorf ("at least %d live replicas required, could only find %d" , minSuccess , len (ingesters ))
58+ 		}
59+ 
5460		return  nil , 0 , err 
5561	}
5662
0 commit comments