示例#1
0
        /// <summary>
        /// Returns the information of the server where the PadInt is stored
        /// </summary>
        /// <param name="uid">PadInt identifier</param>
        /// <returns>Tuple containing (server identifier,server address)</returns>
        public Tuple <int, string> GetPadIntServer(int uid)
        {
            Logger.Log(new String[] { "Master", " getPadIntServer", "uid", uid.ToString() });

            ServerRegistry srvr = getServerRegistry(uid);

            if (srvr != null)
            {
                return(new Tuple <int, string>(srvr.ID, srvr.Address));
            }
            else
            {
                throw new PadIntNotFoundException(uid);
            }
        }
示例#2
0
        /// <summary>
        /// Returns the information of the server where the PadInt should be stored.
        /// </summary>
        /// <param name="uid">PadInt identifier</param>
        /// <returns>Tuple containing (server identifier,server address)</returns>
        public Tuple <int, string> RegisterPadInt(int uid)
        {
            Logger.Log(new String[] { "Master", " registerPadInt", "uid", uid.ToString() });
            int newServerID;

            try {
                newServerID = LoadBalancer.GetAvailableServer(registeredServers, serverIsPrimary);
            }
            catch (NoServersFoundException) {
                throw;
            }

            ServerRegistry oldServer = getServerRegistry(uid);

            if (oldServer == null)
            {
                registeredServers[newServerID].AddPadInt(uid);
                return(new Tuple <int, string>(newServerID, registeredServers[newServerID].Address));
            }
            else
            {
                throw new PadIntAlreadyExistsException(uid, oldServer.ID);
            }
        }