Ejemplo n.º 1
0
        Task <bool> IMembershipTable.UpdateRow(MembershipEntry entry, string etag, TableVersion tableVersion)
        {
            if (logger.IsVerbose3)
            {
                logger.Verbose3(string.Format("IMembershipTable.UpdateRow called with entry {0}, etag {1} and tableVersion {2}.", entry, etag, tableVersion));
            }

            //The "tableVersion" parameter should always exist when updating a row as Init should
            //have been called and membership version created and read. This is an optimization to
            //not to go through all the way to database to fail a conditional check (which does
            //exist for the sake of robustness) as mandated by Orleans membership protocol.
            //Likewise, no update can be done without membership entry or an etag.
            if (entry == null)
            {
                if (logger.IsVerbose)
                {
                    logger.Verbose("SqlMembershipTable.UpdateRow aborted due to null check. MembershipEntry is null.");
                }
                throw new ArgumentNullException("entry");
            }
            if (etag == null)
            {
                if (logger.IsVerbose)
                {
                    logger.Verbose("SqlMembershipTable.UpdateRow aborted due to null check. etag is null.");
                }
                throw new ArgumentNullException("etag");
            }
            if (tableVersion == null)
            {
                if (logger.IsVerbose)
                {
                    logger.Verbose("SqlMembershipTable.UpdateRow aborted due to null check. TableVersion is null ");
                }
                throw new ArgumentNullException("tableVersion");
            }

            try
            {
                var query = queryConstants.GetConstant(database.InvariantName, QueryKeys.UpdateMembershipKey);
                return(database.UpdateMembershipRowAsync(query, deploymentId, etag, entry, tableVersion));
            }
            catch (Exception ex)
            {
                if (logger.IsVerbose)
                {
                    logger.Verbose("SqlMembershipTable.UpdateRow failed: {0}", ex);
                }
                throw;
            }
        }