Skip to content

Instantly share code, notes, and snippets.

@tbarbugli
Created December 23, 2015 20:41
Show Gist options
  • Save tbarbugli/a02a78ff7aa2886a7c13 to your computer and use it in GitHub Desktop.
Save tbarbugli/a02a78ff7aa2886a7c13 to your computer and use it in GitHub Desktop.

Revisions

  1. tbarbugli created this gist Dec 23, 2015.
    12 changes: 12 additions & 0 deletions LocalNetworkDCAwareRoundRobinPolicy.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    from cassandra.policies import DCAwareRoundRobinPolicy
    from cassandra.policies import HostDistance
    from IPy import IP


    class LocalNetworkDCAwareRoundRobinPolicy(DCAwareRoundRobinPolicy):

    def distance(self, host):
    host_distance = super(LocalNetworkDCAwareRoundRobinPolicy, self).distance(host)
    if IP(host.address).iptype() == 'PUBLIC':
    return HostDistance.IGNORED
    return host_distance