6.2.2.3.4.3 Site Graph Construction
The following methods construct the initial site graph, comprising the vertices, multi-edges, and multi-edge sets corresponding to the site, siteLink, and siteLinkBridge objects (respectively) in the config NC.
-
/***** SetupGraph *****/ /* Set up a GRAPH, populated with a VERTEX for each site object, a * MULTIEDGE for each siteLink object, and a MUTLIEDGESET for each * siteLinkBridge object (or implied siteLinkBridge). * * RETURNS: A new graph. */ SetupGraph() : GRAPH { LET vertexIDs be the sequence containing the objectGUID of each site object child of the CN=Sites child of the config NC LET g be the GRAPH return of CreateGraph(vertexIDs) LET localSite be the site object for the site of the local DC FOR each interSiteTransport object t that is a child of the CN=Inter-Site Transports child of the CN=Sites child of the config NC LET L be the set containing each siteLink object that is a child of t FOR each l in L APPEND CreateEdge(t!objectGUID, l) to g.Edges ENDFOR IF NTDSTRANSPORT_OPT_BRIDGES_REQUIRED bit is clear in t!options and NTDSSETTINGS_OPT_W2K3_BRIDGES_REQUIRED bit is clear in localSite!options APPEND CreateAutoEdgeSet(g, t!objectGUID, L) to g.EdgeSets ELSE FOR each siteLinkBridge object b that is a child of t APPEND CreateEdgeSet(g, t!objectGUID, b) to g.EdgeSets ENDFOR ENDIF ENDFOR RETURN g } /***** CreateGraph *****/ /* Create a GRAPH instance. * IN: vertexIDs - Set containing the ID of each vertex to add to the * graph. * RETURNS: A new graph containing vertices with the specified IDs. */ CreateGraph(IN SEQUENCE<GUID> vertexIDs) : GRAPH { LET g be a new GRAPH SORT vertexIDs in ascending order of objectGUID FOR each id in vertexIDs LET v be a new VERTEX SET v.ID to id APPEND v to g.Vertices ENDFOR RETURN g } /***** CreateEdge *****/ /* Create a MULTIEDGE instance. * IN: type - Type of edge to add. * IN: link - Corresponding siteLink object. * RETURNS: A new MULTIEDGE instance. */ CreateEdge(IN GUID type, IN siteLink link) : MULTIEDGE { LET e be a new MULTIEDGE SET e.ID to link!objectGUID SET e.VertexIDs to be the set containing the objectGUID value of each site referenced by link!siteList SET e.ReplInfo.Cost to link!cost; SET e.ReplInfo.Options to link!options SET e.ReplInfo.Interval to link!replInterval IF link!schedule has a value SET e.ReplInfo.Schedule to link!schedule ELSE SET e.ReplInfo.Schedule to NULL EndIF SET e.Type to type SET e.Directed to FALSE RETURN e } /***** CreateAutoEdgeSet *****/ /* Create a MULTIEDGESET instance containing edges for all siteLink * objects. * INOUT: g - Site graph. * IN: type - Type of edges being connected. * IN: L - All siteLink objects. * RETURNS: A new MULTIEDGESET instance. */ CreateAutoEdgeSet(INOUT GRAPH g, IN GUID type, IN SET OF siteLink L) : MULTIEDGESET { LET s be a new MULTIEDGESET SET s.ID to NULL GUID FOR each l in L LET e be the edge in g.Edges such that e.ID = l!objectGUID IF e.Type = type APPEND l!objectGUID to s.EdgeIDs ENDIF ENDFOR RETURN s } /***** CreateEdgeSet *****/ /* Create a MULTIEDGESET instance. * INOUT: g - Site graph. * IN: type - Type of edges being connected. * IN: b - Corresponding siteLinkBridge object. * RETURNS: A new MULTIEDGESET instance. */ CreateEdgeSet(INOUT GRAPH g, IN GUID type, IN siteLinkBridge b) : MULTIEDGESET { LET s be a new MULTIEDGESET SET e.ID to b!objectGUID FOR each DSNAME l in b!siteLinkList LET e be the edge in g.Edges such that e.ID = l!objectGUID IF e.Type = type APPEND l!objectGUID to s.EdgeIDs ENDIF ENDFOR RETURN s } /***** ColorVertices *****/ /* Color each vertex to indicate which kinds of NC replicas it * contains. * INOUT: g - Site graph. * IN: cr - crossRef for NC. * IN: detectFailedDCs - TRUE to detect failed DCs and route * replication traffic around them, FALSE to assume no DC * has failed. * RETURNS: TRUE if one or more failed DCs were detected, * otherwise FALSE. */ ColorVertices(INOUT GRAPH g, IN crossRef cr, IN bool detectFailedDCs) : bool { LET foundFailedDCs be FALSE FOR each v in g.Vertices LET s be the site object with objectGUID v.ID IF s contains one or more DCs with full replicas of the NC cr!nCName SET v.Color to COLOR.RED ELSEIF s contains one or more partial replicas of the NC SET v.Color to COLOR.BLACK ELSE SET v.Color to COLOR.WHITE ENDIF ENDFOR LET localSiteVertex be the vertex in graph.Vertices such that localSiteVertex.ID = objectGUID of the local DC's site object FOR each v in g.Vertices FOR each interSiteTransport object t that is a child of the CN=Inter-Site Transports child of the CN=Sites child of the config NC IF localSiteVertex.Color = COLOR.RED and t!name ≠ "IP" and FLAG_CR_NTDS_DOMAIN bit is set in cr!systemFlags Skip t ENDIF IF no edge e exists in g.Edges such that e.VertexIDs contains v.ID Skip t ENDIF LET partialReplicaOkay be TRUE if and only if localSiteVertex.Color = COLOR.BLACK LET bh be the result of GetBridgeheadDC( localSiteVertex.ID, cr, t, partialReplicaOkay, detectFailedDCs) IF bh = null /* No bridgehead DC is currently available. */ SET foundFailedDCs to TRUE Skip t ENDIF APPEND t!objectGUID to v.AcceptRedRed APPEND t!objectGUID to v.AcceptBlack ENDFOR ENDFOR RETURN foundFailedDCs }