예제 #1
0
        private ReplicationTopologyDestinationNode HandleDestination(ReplicationDestination replicationDestination)
        {
            var destination = ReplicationTask.GetConnectionOptions(replicationDestination, database);

            if (replicationDestination.Disabled)
            {
                return(ReplicationTopologyDestinationNode.Disabled(destination.ConnectionStringOptions.Url, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior));
            }

            if (from.Contains(destination.ConnectionStringOptions.Url))
            {
                var state = CheckDestinationConnectionState(destination);
                switch (state)
                {
                case ReplicatonNodeState.Online:
                    return(ReplicationTopologyDestinationNode.Online(destination.ConnectionStringOptions.Url, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior));

                case ReplicatonNodeState.Offline:
                    return(ReplicationTopologyDestinationNode.Offline(destination.ConnectionStringOptions.Url, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior));

                default:
                    throw new NotSupportedException(state.ToString());
                }
            }

            string error;
            ReplicationTopologyRootNode rootNode;

            if (TryGetSchema(destination.ConnectionStringOptions.Url, destination.ConnectionStringOptions, out rootNode, out error))
            {
                var node = ReplicationTopologyDestinationNode.Online(destination.ConnectionStringOptions.Url, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior);
                node.Destinations = rootNode.Destinations;
                node.Sources      = rootNode.Sources;
                node.Errors       = rootNode.Errors;

                return(node);
            }

            var offline = ReplicationTopologyDestinationNode.Offline(destination.ConnectionStringOptions.Url, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior);

            if (string.IsNullOrEmpty(error) == false)
            {
                offline.Errors.Add(error);
            }

            return(offline);
        }
예제 #2
0
        private ReplicationTopologyDestinationNode HandleDestination(ReplicationDestination replicationDestination)
        {
            var destination = ReplicationTask.GetConnectionOptions(replicationDestination, database);

            string error;
            string targetServerUrl;

            // since each server can be addresses using both dns and ips we normalize connection string url by fetching target server url
            // it should give us consistent urls
            if (FetchTargetServerUrl(destination.ConnectionStringOptions.Url, destination.ConnectionStringOptions, out targetServerUrl, out error) == false)
            {
                var offlineNode = ReplicationTopologyDestinationNode.Offline(destination.ConnectionStringOptions.Url, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior);

                if (string.IsNullOrEmpty(error) == false)
                {
                    offlineNode.Errors.Add(error);
                }

                return(offlineNode);
            }

            if (replicationDestination.Disabled)
            {
                return(ReplicationTopologyDestinationNode.Disabled(targetServerUrl, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior));
            }

            if (from.Contains(targetServerUrl))
            {
                var state = CheckDestinationConnectionState(destination);
                switch (state)
                {
                case ReplicatonNodeState.Online:
                    return(ReplicationTopologyDestinationNode.Online(targetServerUrl, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior));

                case ReplicatonNodeState.Offline:
                    return(ReplicationTopologyDestinationNode.Offline(targetServerUrl, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior));

                default:
                    throw new NotSupportedException(state.ToString());
                }
            }


            ReplicationTopologyRootNode rootNode;

            if (TryGetSchema(destination.ConnectionStringOptions.Url, destination.ConnectionStringOptions, out rootNode, out error))
            {
                var node = ReplicationTopologyDestinationNode.Online(targetServerUrl, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior);
                node.Destinations = rootNode.Destinations;
                node.Sources      = rootNode.Sources;
                node.Errors       = rootNode.Errors;

                return(node);
            }

            var offline = ReplicationTopologyDestinationNode.Offline(targetServerUrl, database.TransactionalStorage.Id, destination.ReplicationOptionsBehavior);

            if (string.IsNullOrEmpty(error) == false)
            {
                offline.Errors.Add(error);
            }

            return(offline);
        }