Пример #1
0
        /// <summary>
        /// Tries to get the first available entity ID.
        /// </summary>

        /// <returns>a non-zero ID if one was available; 0 otheriwse</returns>
        /// <remarks>If an available ID is found, it will be removed from the database.</remarks>
        public static uint GetLowEntityId(ObjectTypeId type)
        {
            // Lock so someone else doesn't grab the same row
            s_idLock.Enter();

            try
            {
                EntityIdStorage eid = GetFirstRecycledId(type);

                if (eid == null)
                {
                    return(0);
                }
                else
                {
                    RemoveRecycledId(eid);

                    return((uint)eid.EntityId);
                }
            }
            finally
            {
                s_idLock.Exit();
            }
        }
Пример #2
0
        private void QueryIndexingImpl(int docID, bool invokeProcessingPendingDocs)
        {
            //  Put new job only if the corresponding mode is appropriate:
            //  - either index in real time, or
            //  - index in idle mode and
            if (!IdleIndexingMode || Core.IsSystemIdle)
            {
                //  Do not act on a resource which was possibly deleted just
                //  before the indexing.
                if (docID >= 0)
                {
                    #region Pending Data Processing
                    _pendingDocsLock.Enter();
                    try
                    {
                        _pendingDocs.Add(docID);
                    }
                    finally
                    {
                        _pendingDocsLock.Exit();
                    }
                    #endregion Pending Data Processing

                    if (invokeProcessingPendingDocs)
                    {
                        QueueProcessingPendingDocs();
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Removes ArenaTeamMember from the arena team
        /// </summary>
        /// <param name="member">member to remove</param>
        /// <param name="update">if false, changes to the team will not be promoted anymore (used when the team is being disbanded)</param>
        public bool RemoveMember(ArenaTeamMember member, bool update)
        {
            OnRemoveMember(member);

            if (update && member == m_leader)
            {
                OnLeaderDeleted();
            }

            if (m_leader == null)
            {
                // Team has been disbanded
                return(true);
            }

            m_syncRoot.Enter();
            try
            {
                if (!Members.Remove(member.Id))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e, string.Format("Could not delete member {0} from arena team {1}", member.Name,
                                                        this));
                return(false);
            }
            finally
            {
                m_syncRoot.Exit();
            }

            if (update)
            {
                //ArenaTeamHandler.SendEventToTeam(this, ArenaTeamEvents.LEAVED_SS, member);
            }

            RealmServer.IOQueue.AddMessage(() =>
            {
                member.Delete();
                if (update)
                {
                    Update();
                }
            });
            return(true);
        }
Пример #4
0
        /// <summary>
        /// Tries to get the first available recycled ID.
        /// </summary>
        /// <param name="entityIdType">the type of the entity id</param>
        /// <returns>a non-zero ID if one was available; 0 otheriwse</returns>
        /// <remarks>If an available ID is found, it'll be removed from the database.</remarks>
        public static uint TryGetLowerEntityId(EntityIdType entityIdType)
        {
            // Lock so someone else doesn't grab the same row
            m_idLock.Enter();

            try
            {
                RecycledEntityId eid = GetFirstRecycledId(entityIdType);

                if (eid == null)
                {
                    return(0);
                }
                else
                {
                    RemoveRecycledId(eid);

                    return((uint)eid.EntityId);
                }
            }
            finally
            {
                m_idLock.Exit();
            }
        }
Пример #5
0
 protected override void Execute()
 {
     _lock.Enter();
     Thread.Sleep(0);
     _lock.Enter();
     Thread.Sleep(0);
     _lock.Enter();
     Thread.Sleep(0);
     _lock.Enter();
     Thread.Sleep(0);
     _lock.Exit();
     Thread.Sleep(0);
     _lock.Exit();
     Thread.Sleep(0);
     _lock.Exit();
     Thread.Sleep(0);
     _lock.Exit();
 }
Пример #6
0
        private static void OnPushTimerElapsed(object sender, ElapsedEventArgs e)
        {
            // push out the updates.
            // todo: do these as a batch operation to speed it up/make it more efficient

            List <AuditEntry> oldQueue;

            // swap out the queue
            _updateLock.Enter();

            try
            {
                // grab the old queue
                oldQueue = _queuedAuditEntries;

                // swap in a new queue
                _queuedAuditEntries = new List <AuditEntry>();
            }
            finally
            {
                _updateLock.Exit();
            }

            // here we're doing some custom query generation to batch insert all of these entries.
            // normally this would be something that goes in the DB layer, but since we don't want
            // to push hundreds of rows at a time, trying to do reflection on all of them before
            // insertion, we instead hard-code it here.  not the cleanest way but this will change
            // with a switch to a better DB layer.

            StringBuilder queryBuilder      = GetEntryQueryBuilder();
            int           currentQueryCount = 0;

            foreach (AuditEntry entry in oldQueue)
            {
                // we limit the number of items per insert query.
                if (currentQueryCount > EventsPerInsertLimit)
                {
                    // reset item count
                    currentQueryCount = 0;

                    // close query, remove previous `,` and add `;`
                    queryBuilder.Remove(queryBuilder.Length - 1, 1);
                    queryBuilder.Append(';');

                    // build query string and execute
                    string queryString = queryBuilder.ToString();

                    // Graveen: if AuditMgr is debuggued one day, this should be in ORM format: GS.Database.AddObject<AuditEntry> ...
                    //GameServer.Database.ExecuteNonQuery(queryString);

                    // get new query builder
                    queryBuilder = GetEntryQueryBuilder();
                }

                // add entry to the query
                queryBuilder.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7}),", entry.ObjectId, entry.AuditTime,
                                          entry.AccountID, entry.RemoteHost, entry.AuditType, entry.AuditSubtype,
                                          entry.OldValue, entry.NewValue);

                currentQueryCount++;
            }

            // close query, remove previous `,` and add `;`
            queryBuilder.Remove(queryBuilder.Length - 1, 1);
            queryBuilder.Append(';');

            /* Graveen: if AuditMgr is debuggued one day, this should be in ORM format: GS.Database.AddObject<AuditEntry> ...
             *
             * // build query string and execute
             * string entryQuery = queryBuilder.ToString();
             *
             * GameServer.Database.ExecuteNonQuery(entryQuery);
             */

            // restart timer
            PushTimer.Start();
        }