示例#1
0
        private static void HandleLink(ReplicationTopology topology, ReplicationTopologyNodeBase source, ReplicationTopologyNodeBase target)
        {
            topology.Servers.Add(source.ServerUrl);
            topology.Servers.Add(target.ServerUrl);

            ReplicationTopologyConnection connection = null;

            if (target is ReplicationTopologyDestinationNode)
            {
                var destinationNode = (ReplicationTopologyDestinationNode)target;
                // going to destination
                connection                          = topology.GetConnection(source.ServerUrl, target.ServerUrl) ?? new ReplicationTopologyConnection();
                connection.Source                   = source.ServerUrl;
                connection.Destination              = target.ServerUrl;
                connection.ReplicationBehavior      = destinationNode.ReplicationBehavior;
                connection.SourceToDestinationState = destinationNode.State;
                connection.SendServerId             = destinationNode.SendServerId;
                connection.Errors                   = destinationNode.Errors;
            }
            else if (target is ReplicationTopologySourceNode)
            {
                // going to source
                var sourceNode = (ReplicationTopologySourceNode)target;
                connection             = topology.GetConnection(target.ServerUrl, source.ServerUrl) ?? new ReplicationTopologyConnection();
                connection.Source      = target.ServerUrl;
                connection.Destination = source.ServerUrl;
                connection.DestinationToSourceState = sourceNode.State;
                connection.StoredServerId           = sourceNode.StoredServerId;
                connection.LastDocumentEtag         = sourceNode.LastDocumentEtag;
            }

            topology.Connections.Add(connection);
        }
        private static void HandleLink(ReplicationTopology topology, ReplicationTopologyNodeBase source, ReplicationTopologyNodeBase target)
        {
            topology.Servers.Add(source.ServerUrl);
            topology.Servers.Add(target.ServerUrl);

            ReplicationTopologyConnection connection = null;

            if (target is ReplicationTopologyDestinationNode)
            {
                var destinationNode = (ReplicationTopologyDestinationNode)target;
                // going to destination
                connection = topology.GetConnection(source.ServerUrl, target.ServerUrl) ?? new ReplicationTopologyConnection();
                connection.Source = source.ServerUrl;
                connection.Destination = target.ServerUrl;
                connection.ReplicationBehavior = destinationNode.ReplicationBehavior;
                connection.SourceToDestinationState = destinationNode.State;
                connection.SendServerId = destinationNode.SendServerId;
                connection.Errors = destinationNode.Errors;
            }
            else if (target is ReplicationTopologySourceNode)
            {
                // going to source
                var sourceNode = (ReplicationTopologySourceNode)target;
                connection = topology.GetConnection(target.ServerUrl, source.ServerUrl) ?? new ReplicationTopologyConnection();
                connection.Source = target.ServerUrl;
                connection.Destination = source.ServerUrl;
                connection.DestinationToSourceState = sourceNode.State;
                connection.StoredServerId = sourceNode.StoredServerId;
                connection.LastDocumentEtag = sourceNode.LastDocumentEtag;
                connection.LastAttachmentEtag = sourceNode.LastAttachmentEtag;
            }

            topology.Connections.Add(connection);
        }
        private void FindVisitedNodes(ReplicationTopologyNodeBase rootNode, HashSet<string> visitedNodes)
	    {
	        visitedNodes.Add(rootNode.ServerUrl);
	        foreach (var source in rootNode.Sources)
	        {
	            FindVisitedNodes(source, visitedNodes);
	        }
            foreach (var destinationNode in rootNode.Destinations)
            {
                FindVisitedNodes(destinationNode, visitedNodes);
            }
	    }
        private void HandleLink(ReplicationTopology topology, ReplicationTopologyNodeBase source, ReplicationTopologyNodeBase target)
        {
            ReplicationTopologyConnection connection = null;

            if (target is ReplicationTopologyDestinationNode)
            {
                var destinationNode = (ReplicationTopologyDestinationNode)target;
                // going to destination

                var sourceServerId = destinationNode.SendServerId;
                var sourceUrl      = AddToCache(sourceServerId, source.ServerUrl);

                var destinationId = GetResourceId(destinationNode.DestinationServerId, destinationNode.ServerUrl);
                var targetUrl     = AddToCache(destinationId, destinationNode.ServerUrl);

                connection = topology.GetConnection(sourceServerId, destinationId, sourceUrl, targetUrl);
                if (connection == null)
                {
                    connection = new ReplicationTopologyConnection();
                    topology.Connections.Add(connection);
                }

                connection.SendServerId        = sourceServerId;
                connection.DestinationServerId = destinationId;
                connection.SourceUrl.Add(source.ServerUrl);
                connection.DestinationUrl.Add(target.ServerUrl);
                connection.ReplicationBehavior      = destinationNode.ReplicationBehavior;
                connection.SourceToDestinationState = destinationNode.State;
                connection.Errors = destinationNode.Errors;

                //left for backward compatibility with v3.0
                connection.Source      = sourceUrl;
                connection.Destination = targetUrl;
            }
            else if (target is ReplicationTopologySourceNode)
            {
                // going to source
                var sourceNode     = (ReplicationTopologySourceNode)target;
                var sourceServerId = sourceNode.StoredServerId;
                var sourceUrl      = AddToCache(sourceServerId, target.ServerUrl);

                var destinationId = GetResourceId(sourceNode.DestinationServerId, source.ServerUrl);
                var targetUrl     = AddToCache(destinationId, source.ServerUrl);

                connection = topology.GetConnection(sourceServerId, destinationId, sourceUrl, targetUrl);
                if (connection == null)
                {
                    connection = new ReplicationTopologyConnection();
                    topology.Connections.Add(connection);
                }

                connection.StoredServerId      = sourceServerId;
                connection.DestinationServerId = destinationId;
                connection.SourceUrl.Add(target.ServerUrl);
                connection.DestinationUrl.Add(source.ServerUrl);
                connection.DestinationToSourceState = sourceNode.State;
                connection.LastDocumentEtag         = sourceNode.LastDocumentEtag;
                connection.LastAttachmentEtag       = sourceNode.LastAttachmentEtag;

                //left for backward compatibility with v3.0
                connection.Source      = sourceUrl;
                connection.Destination = targetUrl;
            }
        }