fix HostFilterPolicy
The outer policy should filter on the way in or the way out, not both.
This commit is contained in:
		@@ -504,20 +504,16 @@ class HostFilterPolicy(LoadBalancingPolicy):
 | 
				
			|||||||
        self._predicate = predicate
 | 
					        self._predicate = predicate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_up(self, host, *args, **kwargs):
 | 
					    def on_up(self, host, *args, **kwargs):
 | 
				
			||||||
        if self.predicate(host):
 | 
					        return self._child_policy.on_up(host, *args, **kwargs)
 | 
				
			||||||
            return self._child_policy.on_up(host, *args, **kwargs)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_down(self, host, *args, **kwargs):
 | 
					    def on_down(self, host, *args, **kwargs):
 | 
				
			||||||
        if self.predicate(host):
 | 
					        return self._child_policy.on_down(host, *args, **kwargs)
 | 
				
			||||||
            return self._child_policy.on_down(host, *args, **kwargs)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_add(self, host, *args, **kwargs):
 | 
					    def on_add(self, host, *args, **kwargs):
 | 
				
			||||||
        if self.predicate(host):
 | 
					        return self._child_policy.on_add(host, *args, **kwargs)
 | 
				
			||||||
            return self._child_policy.on_add(host, *args, **kwargs)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_remove(self, host, *args, **kwargs):
 | 
					    def on_remove(self, host, *args, **kwargs):
 | 
				
			||||||
        if self.predicate(host):
 | 
					        return self._child_policy.on_remove(host, *args, **kwargs)
 | 
				
			||||||
            return self._child_policy.on_remove(host, *args, **kwargs)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def predicate(self):
 | 
					    def predicate(self):
 | 
				
			||||||
@@ -545,10 +541,7 @@ class HostFilterPolicy(LoadBalancingPolicy):
 | 
				
			|||||||
            return HostDistance.IGNORED
 | 
					            return HostDistance.IGNORED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def populate(self, cluster, hosts):
 | 
					    def populate(self, cluster, hosts):
 | 
				
			||||||
        self._child_policy.populate(
 | 
					        self._child_policy.populate(cluster=cluster, hosts=hosts)
 | 
				
			||||||
            cluster=cluster,
 | 
					 | 
				
			||||||
            hosts=[h for h in hosts if self.predicate(h)]
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def make_query_plan(self, working_keyspace=None, query=None):
 | 
					    def make_query_plan(self, working_keyspace=None, query=None):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user