Пример #1
0
 /// <summary>
 /// 创建一个双机热备的 malock 服务器
 /// </summary>
 public MalockServer(MalockConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration it cannot be considered a null");
     }
     this.configuration  = configuration;
     this.malockEngine   = new MalockEngine(configuration);
     this.malockListener = new MalockSocketListener(configuration.Port);
     do
     {
         this.onAboredHandler        = this.ProcessAborted;
         this.onReceivedHandler      = this.ProcessReceived;
         this.malockListener.Accept += (sender, e) =>
         {
             MalockSocket socket = (MalockSocket)e;
             lock (socket)
             {
                 socket.Received  += this.onReceivedHandler;
                 socket.Aborted   += this.onAboredHandler;
                 socket.Connected += this.onConnectedHandler;
                 socket.Run();
             }
         };
     } while (false);
     this.onConnectedHandler = (sender, e) => this.ProcessAccept(sender, (MalockSocket)sender);
 }
Пример #2
0
 protected virtual string GetAddress(MalockConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     return(configuration.StandbyNode);
 }
Пример #3
0
 public MalockEngine(MalockConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     this.configuration       = configuration;
     this.malockTable         = new MalockTable();
     this.malockTaskPoll      = new MalockTaskPoll(this);
     this.malockNnsClient     = new MalockNnsClient(configuration);
     this.malockStandbyClient = new MalockStandbyClient(this, configuration);
 }
Пример #4
0
 public MalockStandbyClient(MalockEngine engine, MalockConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     this.configuration = configuration;
     this.engine        = engine;
     do
     {
         this.Identity   = configuration.Identity;
         this.Address    = this.GetAddress(configuration);
         this.listenport = configuration.Port;
     } while (false);
     this.socket            = new MalockInnetSocket(this.Identity, this.Address, this.GetListenPort(), MalockMessage.LINK_MODE_SERVER);
     this.socket.Received  += this.OnReceived;
     this.socket.Connected += this.OnConnected;
     this.socket.Aborted   += this.OnAborted;
     this.socket.Run();
 }
Пример #5
0
        protected override int GetListenPort()
        {
            MalockConfiguration configuration = (MalockConfiguration)this.GetStateObject();

            return(configuration.Port);
        }
Пример #6
0
 internal MalockNnsClient(MalockConfiguration configuration) :
     base(configuration.NnsId, configuration.NnsNode, configuration.NnsStandbyNode, configuration)
 {
     this.configuration = configuration;
     base.Run();
 }