Ejemplo n.º 1
0
 public zoneServerCluster(string region, string zone, proxyNettyServer masterServer)
 {
     this.clusterId  = string.Format("{0}:{1}", region, zone).ToMD5();
     this.zoneName   = zone;
     this.master     = masterServer;
     this.regionName = region;
     repetionList    = new List <proxyNettyServer>();
 }
Ejemplo n.º 2
0
 public void removeRepetion(proxyNettyServer _server)
 {
     if (repetionList.Contains(_server))
     {
         this.repetionList.Remove(_server);
         if (_server == localRunServer.Instance.ownServer)
         {
             localRunServer.Instance.zoneRole = ServerRoleEnum.unkown;
         }
         this.OnChange(new serverChangeEventArgs(_server.id, serverChangeTypeEnum.zoneRepRemoved, "repetionList delete", "", this.clusterId));
     }
 }
Ejemplo n.º 3
0
        public void addRepetion(proxyNettyServer _server)
        {
            if (!repetionList.Contains(_server))
            {
                if (_server == localRunServer.Instance.ownServer)
                {
                    localRunServer.Instance.zoneRole = ServerRoleEnum.zoneRepetiton;
                }
                this.repetionList.Add(_server);

                this.OnChange(new serverChangeEventArgs(_server.id, serverChangeTypeEnum.zoneRepChanged, "repetionList add", "", this.clusterId));
            }
        }
Ejemplo n.º 4
0
        public zoneServerCluster getClusterByeServerId(string id)
        {
            proxyNettyServer result = null;

            foreach (var cluster in zoneServer_dic.Values)
            {
                result = cluster.getzoneServerById(id);
                if (result != null)
                {
                    return(cluster);
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        public void setSlave(proxyNettyServer _slave)
        {
            if (repetionList.Contains(_slave))
            {
                removeRepetion(_slave);
            }
            this.slave = _slave;
            if (_slave == localRunServer.Instance.ownServer)
            {
                localRunServer.Instance.zoneRole = ServerRoleEnum.zoneSlave;
            }

            this.OnChange(new serverChangeEventArgs(_slave.id, serverChangeTypeEnum.zoneSlaveChanged, "slave", "", this.clusterId));
        }
Ejemplo n.º 6
0
 public void setMaster(proxyNettyServer _master)
 {
     if (repetionList.Contains(_master))
     {
         removeRepetion(_master);
     }
     if (slave == _master)
     {
         this.slave = null;
     }
     this.master = _master;
     if (_master == localRunServer.Instance.ownServer)
     {
         localRunServer.Instance.zoneRole = ServerRoleEnum.zoneMaster;
     }
     this.OnChange(new serverChangeEventArgs(_master.id, serverChangeTypeEnum.zoneMasterChanged, "master set", "", this.clusterId));
 }
Ejemplo n.º 7
0
        public void setSlave(proxyNettyServer _slave)
        {
            if (_slave == null)
            {
                return;
            }
            if (!zoneServer_dic.ContainsKey(_slave.clusterID))
            {
                throw new Exception("region not contain this zoneCluster");
            }
            var existServer = zoneServer_dic[_slave.clusterID].getzoneServerById(_slave.id);

            if (existServer == null)
            {
                throw new Exception("cluster not contain this server");
            }
            this.slaveClusterId = _slave.clusterID;
            this.slaveId        = _slave.id;
        }
Ejemplo n.º 8
0
        public void setMaster(proxyNettyServer _master)
        {
            if (_master == null)
            {
                return;
            }
            if (!zoneServer_dic.ContainsKey(_master.clusterID))
            {
                throw new Exception("region not contain this zoneCluster");
            }
            var existServer = zoneServer_dic[_master.clusterID].getzoneServerById(_master.id);

            if (existServer == null)
            {
                throw new Exception("cluster not contain this server");
            }
            this.masterClusterId = _master.clusterID;
            this.masterId        = _master.id;
        }
Ejemplo n.º 9
0
        public mapPortGroup(string host, string port, string appkey, int _listenCount, outPortSelectPolicy grouppolicy, string httpsPort, proxyNettyServer oServer, listenHttpsEnum usehttps = listenHttpsEnum.onlyListenport, int _mapType = 0, bool fromEureka = false) : this()
        {
            this.ownServer = oServer;
            IPAddress ip = IPAddress.Any;

            if (!IPAddress.TryParse(host, out ip))
            {
            }
            ushort uport;

            if (ushort.TryParse(port, out uport))
            {
                _point_in = new IPEndPoint(ip, uport);
            }
            else
            {
                _point_in = null;
            }
            this.host         = host;
            this.port         = port;
            this.appkey       = appkey;
            this.mapType      = _mapType;
            this.groupPolicy  = grouppolicy;
            this._maxInCount  = _listenCount;
            this.httpsPort    = httpsPort;
            this.useHttps     = usehttps;
            this.isfromEureka = fromEureka;
        }
Ejemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="host"></param>
 /// <param name="port"></param>
 /// <param name="appkey"></param>
 /// <param name="_listenCount"></param>
 /// <param name="grouppolicy"></param>
 /// <param name="oServer"></param>
 /// <param name="_mapType">0:端口转发,1:http的appkey转发</param>
 /// <param name="fromEureka"></param>
 public mapPortGroup(string host, string port, string appkey, int _listenCount, outPortSelectPolicy grouppolicy, proxyNettyServer oServer, int _mapType, bool fromEureka = false) : this(host, port, appkey, _listenCount, grouppolicy, null, oServer, listenHttpsEnum.onlyHttpsPort, _mapType, fromEureka)
 {
 }