Beispiel #1
0
        /// <summary>
        /// Returns a list of nodes that can be used to easily point to the current server node
        /// </summary>
        /// <returns></returns>
        public List <serverNode> getDbNodes()
        {
            var ns = namespaces.FindAll();
            Dictionary <int, int> namespace_index_relation = new Dictionary <int, int> {
            };

            foreach (var name in ns)
            {
                namespace_index_relation.Add(name.internalIndex, name.currentServerIndex);
            }

            List <serverNode> Out = new List <serverNode> {
            };
            var nodes_list        = nodes.FindAll();

            logger.Debug("Number of selected nodes: " + nodes_list.Count());

            foreach (var node in nodes_list)
            {
                serverNode s    = new serverNode(node);
                int        temp = 0;
                namespace_index_relation.TryGetValue(node.internalIndex, out temp);
                s.currentServerIndex = temp;
                s.serverIdentifier   = "ns=" + s.currentServerIndex.ToString();
                s.serverIdentifier  += ";" + node.identifier;

                Out.Add(s);
            }

            return(Out);
        }
Beispiel #2
0
        /// <summary>
        /// Return a ServerNode, the current representation in the server for that node
        /// </summary>
        /// <param name="name">Name of the variable</param>
        /// <returns></returns>
        public serverNode getServerNode(string name)
        {
            var node = nodes.FindOne(Query.EQ("name", name));

            if (node == null)
            {
                throw new Exception("Node does not exist");
            }
            serverNode s  = new serverNode(node);
            var        ns = namespaces.FindOne(Query.EQ("internalIndex", node.internalIndex));

            if (ns == null)
            {
                throw new Exception("Node exist but has not related namespace");
            }
            s.currentServerIndex = ns.currentServerIndex;
            s.serverIdentifier   = "ns=" + s.currentServerIndex.ToString();
            s.serverIdentifier  += ";" + node.identifier;

            return(s);
        }