예제 #1
0
 /// <summary>
 /// When object servers ping periodically, this method is called
 /// </summary>
 /// <param name="serverName"></param>
 public void HeartBeatReceiver(string serverName)
 {
     lock (this)
     {
         ObjectServer server = Common.GetObjectServerByName(serverName, workerServerList);
         if (server != null)
         {
             if (objectServerHeartBeatTimeStamp.ContainsKey(serverName))
             {
                 objectServerHeartBeatTimeStamp[serverName] = DateTime.Now;
             }
             else
             {
                 objectServerHeartBeatTimeStamp.Add(serverName, DateTime.Now);
             }
             Console.WriteLine("Heartbeat Received, Server :" + server.ServerName + " Ip :" + server.ServerIp + " Port :" + server.ServerPort);
             Common.Logger().LogInfo("Heartbeat Received, Server :" + server.ServerName + " Ip :" + server.ServerIp + " Port :" + server.ServerPort, string.Empty, string.Empty);
         }
         else
         {
             Console.WriteLine("No server available with name " + serverName + " in master node");
             Common.Logger().LogError("No server available with name " + serverName + " in master node", string.Empty, string.Empty);
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Get the object server reference by the unique name provide
        /// </summary>
        /// <param name="serverName"></param>
        /// <param name="objectServerList"></param>
        /// <returns></returns>
        public static ObjectServer GetObjectServerByName(string serverName, List <ObjectServer> objectServerList)
        {
            ObjectServer server = null;

            if (objectServerList.Count > 0)
            {
                server = objectServerList.Single(s => s.ServerName == serverName);
            }
            return(server);
        }
예제 #3
0
 /// <summary>
 /// Receive the new object server map from server when object server join or left
 /// </summary>
 /// <param name="objectServerList"></param>
 public void UpdateServerList(ObjectServer[] objectServerList)
 {
     this.objectServerList = objectServerList;
     if (objectServerList != null)
     {
         thisServer    = Common.GetObjectServerByName(thisServer.ServerName, objectServerList.ToList());
         replicaServer = Common.GetObjectServerByName(thisServer.ReplicaServerName, objectServerList.ToList());
     }
     Console.WriteLine("New Object Server List received");
     Console.WriteLine("This server = " + thisServer.ServerName + " and replica = " + replicaServer.ServerName);
     Common.Logger().LogInfo("New Object Server List received", string.Empty, string.Empty);
 }
예제 #4
0
 /// <summary>
 /// Create a WorkerServer and update details.
 /// </summary>
 /// <param name="ip"></param>
 /// <param name="port"></param>
 /// <returns>unique server name</returns>
 public ObjectServer Bootstrap(string ip, string port)
 {
     lock (this)
     {
         ObjectServer wserver = new ObjectServer();
         wserver.ServerName  = PREFIX_WORKER_SERVER + (++serverIndex);
         wserver.ServerIp    = ip;
         wserver.ServerPort  = port;
         wserver.TcpUrl      = Common.GenerateTcpUrl(ip, port, Constants.OBJECT_TYPE_PADI_WORKER);
         wserver.ServerIndex = serverIndex;
         workerServerList.Add(wserver);
         Stabilizer();
         return(wserver);
     }
 }
예제 #5
0
        /// <summary>
        /// Bootstarp object servers with the master
        /// </summary>
        /// <param name="workerPort"></param>
        /// <returns></returns>
        public bool BootstrapMaster(string workerPort)
        {
            bool   isBootstraped = false;
            String masterUrl     = Common.GetMasterTcpUrl();
            //String workerIp = Common.GetLocalIPAddress();
            String      workerIp  = ConfigurationManager.AppSettings[Constants.APPSET_WORKER_IP];
            PADI_Master masterObj = (PADI_Master)Activator.GetObject(typeof(PADI_Master), masterUrl);

            thisServer = masterObj.Bootstrap(workerIp, workerPort);
            if (thisServer != null)
            {
                isBootstraped = true;
            }
            Console.WriteLine("Worker server :" + thisServer.ServerName + "started. Bootstrap status:" + isBootstraped);
            Common.Logger().LogInfo("Worker server :" + thisServer.ServerName + " started", "Port : " + workerPort, "Bootstrap status:" + isBootstraped);
            return(isBootstraped);
        }