private void LoadAllInfo(Stream stream)
        {
            IList <HandleInfo> s = new List <HandleInfo>();

            if (!HandleInfo.Fill(s, stream))
            {
                this.socket.Abort();
                return;
            }
            MalockTable malock = this.engine.GetTable();

            lock (malock.GetSynchronizationObject())
            {
                foreach (HandleInfo i in s)
                {
                    if (i.Available)
                    {
                        malock.Exit(i.Key);
                    }
                    else
                    {
                        malock.Enter(i.Key, i.Identity);
                    }
                }
            }
        }
Exemple #2
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);
 }
Exemple #3
0
        private void ProcessAccept(object sender, MalockSocket e)
        {
            if (e.LinkMode == MalockMessage.LINK_MODE_CLIENT)
            {
                MalockTable malock = this.malockEngine.GetTable();
                malock.AllocKeyCollection(e.Identity);
            }

            /*
             * This creates a bug in a distributed atomic-state deadlock.
             *  else if (e.LinkMode == Message.LINK_MODE_SERVER)
             *  {
             *      this.malockEngine.GetAllInfo(new MalockTaskInfo()
             *      {
             *          Identity = e.Identity,
             *          Socket = e,
             *          Timeout = -1,
             *          Type = MalockTaskType.kGetAllInfo
             *      });
             *  }
             */
        }
Exemple #4
0
 private void ProcessServer(MalockSocket socket, MalockNodeMessage message)
 {
     if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_ENTER)
     {
         socket.UserToken = message;
         MalockTable malock = this.malockEngine.GetTable();
         malock.Enter(message.Key, message.Identity);
     }
     else if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_EXIT)
     {
         MalockTable malock = this.malockEngine.GetTable();
         malock.Exit(message.Key, message.Identity);
         do
         {
             this.malockEngine.AckPipelineExit(new MalockTaskInfo()
             {
                 Key      = message.Key,
                 Identity = message.Identity,
             });
         } while (false);
     }
     else if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_FREE)
     {
         string[]    keys;
         MalockTable malock = this.malockEngine.GetTable();
         malock.Exit(message.Identity, out keys);
         this.malockEngine.AckPipelineEnter(message.Identity, keys);
     }
     else if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_LOADALLINFO)
     {
         this.malockEngine.GetAllInfo(new MalockTaskInfo()
         {
             Identity = socket.Identity,
             Socket   = socket,
             Timeout  = -1,
             Type     = MalockTaskType.kGetAllInfo
         });
     }
 }
Exemple #5
0
        private void ProcessAborted(object sender, EventArgs e)
        {
            MalockSocket socket = (MalockSocket)sender;

            if (socket.LinkMode == MalockMessage.LINK_MODE_CLIENT)
            {
                if (!string.IsNullOrEmpty(socket.Identity))
                {
                    this.malockEngine.Abort(new MalockTaskInfo()
                    {
                        Type      = MalockTaskType.kAbort,
                        Key       = null,
                        Stopwatch = null,
                        Timeout   = -1,
                        Sequence  = MalockMessage.NewId(),
                        Socket    = socket,
                        Identity  = socket.Identity,
                    });
                }
            }
            else if (socket.LinkMode == MalockMessage.LINK_MODE_SERVER)
            {
                MalockNodeMessage message = (MalockNodeMessage)socket.UserToken;
                if (message != null)
                {
                    string[]    keys;
                    MalockTable malock = this.malockEngine.GetTable();
                    malock.Exit(message.Identity, out keys);
                    this.malockEngine.AckPipelineEnter(message.Identity, keys);
                }
            }
            lock (socket)
            {
                socket.Aborted   -= this.onAboredHandler;
                socket.Connected -= this.onConnectedHandler;
                socket.Received  -= this.onReceivedHandler;
            }
        }
        private void Enter(MalockNodeMessage message)
        {
            MalockTable malock = this.engine.GetTable();

            malock.Enter(message.Key, message.Identity);
        }