]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
kcc_utils: Create the new classes for the intersite algorithm
authorGarming Sam <garming@catalyst.net.nz>
Wed, 18 Feb 2015 05:21:19 +0000 (18:21 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 28 May 2015 05:25:07 +0000 (07:25 +0200)
Also sorts vertex color by preference in sorting algorithms.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/kcc_utils.py

index 8da457018de4a2a583b05599bb7f1517d6ddec38..23eb505b1c0d7d796a1a98160b0dbdfa8ad9e836 100644 (file)
@@ -2161,7 +2161,7 @@ class SiteLink(object):
 
 
 class VertexColor(object):
-    (unknown, white, black, red) = range(0, 4)
+    (red, black, white, unknown) = range(0, 4)
 
 
 class Vertex(object):
@@ -2172,6 +2172,13 @@ class Vertex(object):
         self.site = site
         self.part = part
         self.color = VertexColor.unknown
+        self.edges = []
+        self.accept_red_red = []
+        self.accept_black = []
+        self.repl_info = None
+        self.root = None
+        self.guid = None
+        self.component_id = None
 
     def color_vertex(self):
         """Color each vertex to indicate which kind of NC
@@ -2213,6 +2220,81 @@ class Vertex(object):
         assert(self.color != VertexColor.unknown)
         return (self.color == VertexColor.white)
 
+
+class IntersiteGraph(object):
+    """Graph for representing the intersite"""
+    def __init__(self):
+        self.vertices = []
+        self.edges = []
+        self.edge_set = []
+
+
+class MultiEdgeSet(object):
+    """Defines a multi edge set"""
+    def __init__(self):
+        self.guid = 0 # objectGuid siteLinkBridge
+        self.edges = []
+
+
+class MultiEdge(object):
+    def __init__(self):
+        self.guid = 0 # objectGuid siteLink
+        self.vertices = []
+        self.con_type = None # interSiteTransport GUID
+        self.repl_info = None
+        self.directed = False
+
+class ReplInfo(object):
+    def __init__(self):
+        self.cost = 0
+        self.interval = 0
+        self.options = 0
+        self.schedule = 0
+
+class InternalEdge(object):
+    def __init__(self, v1, v2, redred, repl, eType):
+        self.v1 = v1
+        self.v2 = v2
+        self.red_red = redred
+        self.repl_info = repl
+        self.e_type = eType
+
+    def __eq__(self, other):
+        return not self < other and not other < self
+
+    def __ne__(self, other):
+        return self < other or other < self
+
+    def __gt__(self, other):
+        return other < self
+
+    def __ge__(self, other):
+        return not self < other
+
+    def __le__(self, other):
+        return not other < self
+
+    def __lt__(self, other):
+        if self.red_red != other.red_red:
+            return self.red_red
+
+        if self.repl_info.cost != other.repl_info.cost:
+            return self.repl_info.cost < other.repl_info.cost
+
+        self_time = total_schedule(self.repl_info.schedule)
+        other_time = total_schedule(other.repl_info.schedule)
+        if self_time != other_time:
+            return self_time > other_time
+
+        if self.v1.guid != other.v1.guid:
+            return self.v1.guid < other.v1.guid #TODO string?
+
+        if self.v2.guid != other.v2.guid:
+            return self.v2.guid < other.v2.guid #TODO string?
+
+        return self.con_type < other.con_type # TODO string?
+
+
 ##################################################
 # Global Functions
 ##################################################