Exemplo n.º 1
0
        /// <summary>
        /// For testing purposes only.
        /// Returns the directory information held by the local silo for the provided grain ID.
        /// The result will be null if no information is held.
        /// </summary>
        /// <param name="grain"></param>
        /// <param name="isPrimary"></param>
        /// <returns></returns>
        public List <ActivationAddress> GetLocalDataForGrain(GrainId grain, out bool isPrimary)
        {
            var primary = CalculateTargetSilo(grain);
            List <ActivationAddress> backupData = HandoffManager.GetHandedOffInfo(grain);

            if (MyAddress.Equals(primary))
            {
                log.Assert(ErrorCode.DirectoryBothPrimaryAndBackupForGrain, backupData == null,
                           "Silo contains both primary and backup directory data for grain " + grain);
                isPrimary = true;
                return(GetLocalDirectoryData(grain));
            }

            isPrimary = false;
            return(backupData);
        }
Exemplo n.º 2
0
        /// Adjust local cache following the removal of a silo by dropping:
        /// 1) entries that point to activations located on the removed silo
        /// 2) entries for grains that are now owned by this silo (me)
        /// 3) entries for grains that were owned by this removed silo - we currently do NOT do that.
        ///     If we did 3, we need to do that BEFORE we change the membershipRingList (based on old Membership).
        ///     We don't do that since first cache refresh handles that.
        ///     Second, since Membership events are not guaranteed to be ordered, we may remove a cache entry that does not really point to a failed silo.
        ///     To do that properly, we need to store for each cache entry who was the directory owner that registered this activation (the original partition owner).
        protected void AdjustLocalCache(SiloAddress silo, bool dead)
        {
            // remove all records of activations located on the removed silo
            foreach (var tuple in DirectoryCache.KeyValues)
            {
                var activationAddress = tuple.ActivationAddress;

                // 2) remove entries now owned by me (they should be retrieved from my directory partition)
                if (MyAddress.Equals(CalculateGrainDirectoryPartition(activationAddress.GrainId)))
                {
                    DirectoryCache.Remove(activationAddress.GrainId);
                }

                // 1) remove entries that point to activations located on the removed silo
                // For dead silos, remove any activation registered to that silo or one of its predecessors.
                // For new silos, remove any activation registered to one of its predecessors.
                if (activationAddress.SiloAddress.IsPredecessorOf(silo) || (activationAddress.SiloAddress.Equals(silo) && dead))
                {
                    DirectoryCache.Remove(activationAddress.GrainId);
                }
            }
        }
Exemplo n.º 3
0
        public string RingStatusToString()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("Silo address is {0}, silo consistent hash is {1:X}.", MyAddress, MyAddress.GetConsistentHashCode()).AppendLine();
            sb.AppendLine("Ring is:");
            lock (membershipCache)
            {
                foreach (var silo in membershipRingList)
                {
                    sb.AppendFormat("    Silo {0}, consistent hash is {1:X}", silo, silo.GetConsistentHashCode()).AppendLine();
                }
            }

            sb.AppendFormat("My predecessors: {0}", FindPredecessors(MyAddress, 1).ToStrings(addr => String.Format("{0}/{1:X}---", addr, addr.GetConsistentHashCode()), " -- ")).AppendLine();
            sb.AppendFormat("My successors: {0}", FindSuccessors(MyAddress, 1).ToStrings(addr => String.Format("{0}/{1:X}---", addr, addr.GetConsistentHashCode()), " -- "));
            return(sb.ToString());
        }
Exemplo n.º 4
0
 public static extern Int32 VM_CMS_CAMToRTSP(ref LPCMS_CONFIG_HIKVISION lpBuf, emCMS_CAM_TYPE emType, ref MyAddress szRtspOutput);//先声明szRtspOutput变量,返回地址
Exemplo n.º 5
0
        public string ToStructHex()
        {
            var output = "{ " + "0x" + MyAddress.toStringHex() + ", " + "0x" + Value.toStringHex() + " },";

            return(output);
        }
Exemplo n.º 6
0
        public string ToStringHexCSV()
        {
            var output = "0x" + MyAddress.toStringHex() + ";" + "0x" + Value.toStringHex();

            return(output);
        }
Exemplo n.º 7
0
        public override string ToString()
        {
            var output = MyAddress.toString().ToString() + ";" + Value.toString();

            return(output);
        }