Beispiel #1
0
        public CountersReplicationTopologyRootNode Discover()
        {
            var root = new CountersReplicationTopologyRootNode(counterStorage.CounterStorageUrl, counterStorage.ServerId);

            if (ttl <= 0)
            {
                return(root);
            }

            CountersReplicationDocument replicationData;
            IEnumerable <CounterStorage.ReplicationSourceInfo> serverSources;

            using (var reader = counterStorage.CreateReader())
            {
                replicationData = reader.GetReplicationData();
                serverSources   = reader.GetReplicationSources().ToList();
            }

            if (@from.Contains(counterStorage.CounterStorageUrl) == false)
            {
                @from.Add(counterStorage.CounterStorageUrl);
            }

            if (replicationData != null)
            {
                root.Destinations = HandleDestinations(replicationData.Destinations);
            }

            root.Sources = HandleSources(serverSources, root);

            return(root);
        }
Beispiel #2
0
 private List <CountersReplicationTopologySourceNode> HandleSources(IEnumerable <CounterStorage.ReplicationSourceInfo> serverSources, CountersReplicationTopologyRootNode root)
 {
     return(serverSources
            .Select(HandleSource)
            .ToList());
 }
Beispiel #3
0
        private bool TryGetSchema(string serverUrl, RavenConnectionStringOptions connectionStringOptions, out CountersReplicationTopologyRootNode rootNode, out string error)
        {
            var url = string.Format("{0}/admin/replication/topology/discover?&ttl={1}", serverUrl, ttl - 1);

            try
            {
                var request = requestFactory.Create(url, HttpMethods.Post, connectionStringOptions);
                request.Write(from);

                error    = null;
                rootNode = request.ExecuteRequest <CountersReplicationTopologyRootNode>();

                var visitedNodes = new HashSet <string>();
                FindVisitedNodes(rootNode, visitedNodes);
                foreach (var visitedNode in visitedNodes)
                {
                    if (@from.Contains(visitedNode) == false)
                    {
                        @from.Add(visitedNode);
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                error    = e.Message;
                rootNode = null;
                return(false);
            }
        }