MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / ProfileManager

Class ProfileManager

cassandra/cluster.py:505–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503
504
505class ProfileManager(object):
506
507 def __init__(self):
508 self.profiles = dict()
509
510 def _profiles_without_explicit_lbps(self):
511 names = (profile_name for
512 profile_name, profile in self.profiles.items()
513 if not profile._load_balancing_policy_explicit)
514 return tuple(
515 'EXEC_PROFILE_DEFAULT' if n is EXEC_PROFILE_DEFAULT else n
516 for n in names
517 )
518
519 def distance(self, host):
520 distances = set(p.load_balancing_policy.distance(host) for p in self.profiles.values())
521 return HostDistance.LOCAL if HostDistance.LOCAL in distances else \
522 HostDistance.REMOTE if HostDistance.REMOTE in distances else \
523 HostDistance.IGNORED
524
525 def populate(self, cluster, hosts):
526 for p in self.profiles.values():
527 p.load_balancing_policy.populate(cluster, hosts)
528
529 def check_supported(self):
530 for p in self.profiles.values():
531 p.load_balancing_policy.check_supported()
532
533 def on_up(self, host):
534 for p in self.profiles.values():
535 p.load_balancing_policy.on_up(host)
536
537 def on_down(self, host):
538 for p in self.profiles.values():
539 p.load_balancing_policy.on_down(host)
540
541 def on_add(self, host):
542 for p in self.profiles.values():
543 p.load_balancing_policy.on_add(host)
544
545 def on_remove(self, host):
546 for p in self.profiles.values():
547 p.load_balancing_policy.on_remove(host)
548
549 @property
550 def default(self):
551 """
552 internal-only; no checks are done because this entry is populated on cluster init
553 """
554 return self.profiles[EXEC_PROFILE_DEFAULT]
555
556
557EXEC_PROFILE_DEFAULT = object()

Callers 2

MockClusterClass · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected