예제 #1
0
		public ReplicationTopology Flatten()
		{
		    var topology = new ReplicationTopology();
		    topology.Servers.Add(ServerUrl);

            var queue = new Queue<ReplicationTopologyNodeBase>();
            queue.Enqueue(this);

            while (queue.Count > 0)
            {
                var node = queue.Dequeue();

                foreach (var dst in node.Destinations)
                {
                    HandleLink(topology, node, dst);
                    queue.Enqueue(dst);
                }

                foreach (var source in node.Sources)
                {
                    HandleLink(topology, node, source);
                    queue.Enqueue(source);
                }
            }

		    return topology;
		}
예제 #2
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;
                connection.LastAttachmentEtag = sourceNode.LastAttachmentEtag;
            }

            topology.Connections.Add(connection);
        }
예제 #3
0
        public ReplicationTopology Flatten()
        {
            var topology = new ReplicationTopology();

            topology.Servers.Add(ServerUrl);

            var queue = new Queue <ReplicationTopologyNodeBase>();

            queue.Enqueue(this);

            while (queue.Count > 0)
            {
                var node = queue.Dequeue();

                foreach (var dst in node.Destinations)
                {
                    HandleLink(topology, node, dst);
                    queue.Enqueue(dst);
                }

                foreach (var source in node.Sources)
                {
                    HandleLink(topology, node, source);
                    queue.Enqueue(source);
                }
            }

            return(topology);
        }
예제 #4
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);
        }
예제 #5
0
        public ReplicationTopology Flatten()
        {
            var topology = new ReplicationTopology();

            topology.Servers.Add(ServerUrl);

            var queue = new Queue <ReplicationTopologyNodeBase>();

            queue.Enqueue(this);

            while (queue.Count > 0)
            {
                var node = queue.Dequeue();

                foreach (var dst in node.Destinations)
                {
                    HandleLink(topology, node, dst);
                    queue.Enqueue(dst);
                }

                foreach (var source in node.Sources)
                {
                    HandleLink(topology, node, source);
                    queue.Enqueue(source);
                }
            }

            foreach (var connection in topology.Connections)
            {
                connection.Source      = GetUrlByDatabaseId(connection.SourceServerId, connection.Source);
                connection.Destination = GetUrlByDatabaseId(connection.DestinationServerId, connection.Destination);

                Guid resourceId;
                if (connection.DestinationServerId.HasValue == false &&
                    urlToResourceId.TryGetValue(connection.Destination, out resourceId))
                {
                    connection.DestinationServerId = resourceId;
                }

                topology.Servers.Add(connection.Source);
                topology.Servers.Add(connection.Destination);
            }

            return(topology);
        }
예제 #6
0
        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;
            }
        }