Example #1
0
        private void es_NodeCreated(Simias.Client.Event.NodeEventArgs args)
        {
            Member member = domain.GetNodeByID(args.Node) as Member;

            if (member.IsType(HostNode.HostNodeType))
            {
                HostNode  hostnode  = new HostNode(member);
                HostEntry hostentry = new HostEntry(hostnode);
                hosts.Add(hostentry);
            }
        }
Example #2
0
        /// <summary>
        /// Constructor for the load balance provider.
        ///
        /// Read all the hosts that are members of the domain and
        /// keep in a sorted list.  Register for member node changes
        /// so we know when new hosts come and go in the system.
        /// </summary>
        public LoadBalanceProvisionUserProvider()
        {
            Store store = Store.GetStore();

            domain = store.GetDomain(store.DefaultDomain);
            HostNode[] hArray = HostNode.GetHosts(domain.ID);
            foreach (HostNode host in hArray)
            {
                HostEntry hostentry = new HostEntry(host);
                hosts.Add(hostentry);
            }

            hosts.Sort();
            nodeEvents = new EventSubscriber(domain.ID);
            nodeEvents.NodeTypeFilter = Simias.Client.NodeTypes.MemberType;
            nodeEvents.NodeCreated   += new NodeEventHandler(es_NodeCreated);
        }
Example #3
0
        /// <summary>
        /// Provision the user
        /// </summary>
        /// <returns>new Hostnode if successful, otherwise null</returns>
        public string ProvisionUser(string Username)
        {
            HostNode hostnode = null;
            Member   member   = domain.GetMemberByName(Username);

            if (member != null)
            {
                hostnode = member.HomeServer;
                if (hostnode == null)
                {
                    HostEntry hostentry = hosts[0] as HostEntry;
                    hostnode = hostentry.Host;
                    hostentry.AddMember(domain, member);
                    lock ( hosts )
                    {
                        hosts.Sort();
                    }
                }
            }

            return(hostnode == null ? null : hostnode.UserID);
        }
Example #4
0
        /// <summary>
        /// Provision the user based on userID and HostName
        /// </summary>
        /// <returns>New hostInfo if successful otherwise null</returns>
        public static Simias.Host.HostInfo ProvisionUser(string userID, string hostName)
        {
            log.Debug("ProvisionUser: Request for  {0} to {1}", userID, hostName);
            HostNode hostnode = null;
            Store    store    = Store.GetStore();
            Domain   domain   = store.GetDomain(store.DefaultDomain);
            Member   member   = domain.GetMemberByID(userID);

            log.Debug(String.Format("ProvisionUser {0}", userID));
            hostnode = checkUserProvisionedByID(userID);
            if (hostnode == null)
            {
                hostnode = HostNode.GetHostByName(domain.ID, hostName);
                if (hostnode == null)
                {
                    return(null);
                }
                log.Debug(String.Format("Setting the home server for {0} to {1}", userID, hostName));
                HostEntry hentry = new HostEntry(hostnode);
                hostnode = hentry.Host;
                hentry.AddMember(domain, member);
            }
            else
            {
                if (Simias.Service.Manager.UserMoveServiceEnabled == false)
                {
                    log.Debug(String.Format("User move service is not configured, User movement skipped for  {0} to {1}", userID, hostName));
                    throw new Exception(String.Format("User move service is not configured, User movement skipped for  {0} to {1}", userID, hostName));
                }
                hostnode = HostNode.GetHostByName(domain.ID, hostName);
                if (hostnode == null)
                {
                    return(null);
                }
                return(Simias.Server.UserMove.Reprovision(userID, HostNode.GetMaster(domain.ID), member.HomeServer, hostnode));
            }
            return(new Simias.Host.HostInfo(hostnode));
        }
Example #5
0
        /// <summary>
        /// Icomparable object to compare 2 objects
        /// </summary>
        /// <param name="obj">obj to compare</param>
        /// <returns>matching result</returns>
        public int CompareTo(object obj)
        {
            HostEntry he = obj as HostEntry;

            return(userCount.CompareTo(he.userCount));
        }