Пример #1
0
        /// <summary>
        /// Calculates <see cref="BulkMessageInfo"/> statistics for IN messages for the
        /// specified type.
        /// </summary>
        /// <param name="typeID">The id of the type to collect statistics for.</param>
        /// <param name="messageLength">The number of messages sent in the bulk message.</param>
        /// <param name="milliseconds">The time it takes to send the message.</param>
        public void CalculateBulkInStatistics(short typeID, int messageLength, long milliseconds)
        {
            TypeSettingStatus status = RetrieveTypeSettingStatusForCalc(typeID);

            if (status == null)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:CalculateBulkInStatistics " +
                                 "TypeSettingStatus is null for typeId:{0}",
                                 typeID);
                return;
            }
            if (!status.GatherStatistics)
            {
                return;
            }

            if (status.BulkInMessageInfo == null)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:CalculateBulkInStatistics " +
                                 "BulkInMessageInfo is null for typeId:{0}",
                                 typeID);
                return;
            }

            status.BulkInMessageInfo.CaculateStatisics(messageLength, milliseconds);
        }
Пример #2
0
        public NodeGroupStatus GetNodeGroupStatus(TypeSettingCollection typeSettingCollection)
        {
            NodeGroupStatus nodeGroupStatus = new NodeGroupStatus();

            nodeGroupStatus.GroupName = this.GroupName;

            if (typeSettingCollection != null)
            {
                foreach (TypeSetting ts in typeSettingCollection)
                {
                    if (ts.GroupName != null && ts.GroupName.ToUpperInvariant() == GroupName.ToUpperInvariant())
                    {
                        TypeSettingStatus tss = TypeSpecificStatisticsManager.Instance.GetStatus(ts.TypeId);
                        if (tss == null)                       //should not be null
                        {
                            _log.WarnFormat("NodeGroup:GetNodeGroupStatus " +
                                            "TypeSettingStatus is null for typeId:{0}",
                                            ts.TypeId);
                            tss = new TypeSettingStatus();                            //add empty one to hold place and show error
                        }
                        nodeGroupStatus.TypeSettingStatuses.Add(tss);
                    }
                }
            }

            foreach (NodeCluster cluster in Clusters)
            {
                nodeGroupStatus.NodeClusterStatuses.Add(cluster.GetNodeClusterStatus());
            }

            return(nodeGroupStatus);
        }
Пример #3
0
        /// <summary>
        /// Returns statistical information collected by the <see cref="Forwarder"/>.
        /// </summary>
        /// <returns>Returns the <see cref="ForwarderStatus"/> object.</returns>
        public ForwarderStatus GetForwarderStatus()
        {
            ForwarderStatus forwarderStatus = new ForwarderStatus();

            forwarderStatus.RelayStatistics = new RelayStatistics();

            forwarderStatus.RelayStatistics.CurrentServerTime  = DateTime.Now;
            forwarderStatus.RelayStatistics.InitializationTime = _initDate;

            TypeSettingStatus tss = TypeSpecificStatisticsManager.Instance.GetStatus(0);

            if (tss == null)           //should not be null
            {
                log.Warn("Fowarder:GetForwarderStatus " +
                         "TypeSettingStatus is null for typeId:0");
                tss = new TypeSettingStatus();                //add empty one to hold place and show error
            }
            forwarderStatus.RelayStatistics.ZeroTypeSettingStatus = tss;

            if (NodeManager.Instance.NodeGroups != null)
            {
                foreach (NodeGroup group in NodeManager.Instance.NodeGroups)
                {
                    forwarderStatus.NodeGroupStatuses.Add(group.GetNodeGroupStatus(NodeManager.Instance.Config.TypeSettings.TypeSettingCollection));
                }
            }
            return(forwarderStatus);
        }
Пример #4
0
        /// <summary>
        /// Returns the <see cref="TypeSettingStatus"/> for the specified type.
        /// </summary>
        /// <param name="typeId">The <see cref="TypeSetting.TypeId"/> to return the Status for.</param>
        /// <returns>The statistics collected for the specified type.</returns>
        public TypeSettingStatus GetStatus(short typeId)
        {
            TypeSettingStatus status = RetrieveTypeSettingStatus(typeId);

            if (status == null)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:GetStatus " +
                                 "TypeSettingStatus is null for typeId:{0}",
                                 typeId);
                return(null);
            }
            return(status.GetStatus());
        }
Пример #5
0
        private TypeSettingStatus RetrieveTypeSettingStatusForCalc(short typeID)
        {
            TypeSettingStatus status = RetrieveTypeSettingStatus(typeID);

            if (status == null)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:RetrieveTypeSettingStatusForCalc " +
                                 "TypeSettingStatus is null for typeId:{0}",
                                 typeID);
                return(null);
            }
            if (!status.GatherStatistics)
            {
                return(null);
            }

            return(status);
        }
Пример #6
0
        public NodeGroupStatus GetNodeGroupStatus(TypeSettingCollection typeSettingCollection)
        {
            NodeGroupStatus nodeGroupStatus = new NodeGroupStatus();

            nodeGroupStatus.GroupName = this.GroupName;

            if (typeSettingCollection != null)
            {
                foreach (TypeSetting ts in typeSettingCollection)
                {
                    if (ts.GroupName.ToUpperInvariant() == GroupName.ToUpperInvariant())
                    {
                        TypeSettingStatus typeSettingStatus = new TypeSettingStatus();
                        typeSettingStatus.TypeName           = ts.TypeName;
                        typeSettingStatus.GroupName          = ts.GroupName;
                        typeSettingStatus.TypeId             = ts.TypeId;
                        typeSettingStatus.Disabled           = ts.Disabled;
                        typeSettingStatus.Compress           = ts.Compress;
                        typeSettingStatus.CheckRaceCondition = ts.CheckRaceCondition;
                        typeSettingStatus.TTLSetting         = ts.TTLSetting;
                        typeSettingStatus.RelatedIndexTypeId = ts.RelatedIndexTypeId;
                        if (ts.HydrationPolicy != null)
                        {
                            typeSettingStatus.HydrationPolicyStatus               = new HydrationPolicyStatus();
                            typeSettingStatus.HydrationPolicyStatus.KeyType       = ts.HydrationPolicy.KeyType.ToString();
                            typeSettingStatus.HydrationPolicyStatus.HydrateMisses = (ts.HydrationPolicy.Options &
                                                                                     RelayHydrationOptions.HydrateOnMiss) ==
                                                                                    RelayHydrationOptions.HydrateOnMiss;
                            typeSettingStatus.HydrationPolicyStatus.HydrateBulkMisses = (ts.HydrationPolicy.Options &
                                                                                         RelayHydrationOptions.HydrateOnBulkMiss) == RelayHydrationOptions.HydrateOnBulkMiss;
                        }
                        nodeGroupStatus.TypeSettingStatuses.Add(typeSettingStatus);
                    }
                }
            }

            foreach (NodeCluster cluster in Clusters)
            {
                nodeGroupStatus.NodeClusterStatuses.Add(cluster.GetNodeClusterStatus());
            }

            return(nodeGroupStatus);
        }
Пример #7
0
        private TypeSettingStatus[] UpdateTypeSettingStatusCollection(TypeSettingCollection typeSettingCollection)
        {
            //create fresh list
            TypeSettingStatus[] newTypeSettingStatusCollection = null;

            newTypeSettingStatusCollection = new TypeSettingStatus[typeSettingCollection.MaxTypeId + 1];
            //Go through type settings
            foreach (var setting in typeSettingCollection)
            {
                //Add old TypeSettingStatus to the appropriate TypeId slot if key items are the same
                if (_typeSettingStatusCollection != null &&
                    setting.TypeId < _typeSettingStatusCollection.Length &&
                    _typeSettingStatusCollection[setting.TypeId] != null &&
                    _typeSettingStatusCollection[setting.TypeId].TypeName == setting.TypeName &&
                    setting.GatherStatistics == true)
                {
                    newTypeSettingStatusCollection[setting.TypeId] = _typeSettingStatusCollection[setting.TypeId].Clone();
                }
                else
                //If there is a new item or one of the key items changed create a new empty TypeSettingStatus for the TypeId slot
                {
                    newTypeSettingStatusCollection[setting.TypeId] = new TypeSettingStatus();
                }
                newTypeSettingStatusCollection[setting.TypeId].Update(setting);
            }
            //Add status for typeId Zero (DeleteAllTypes) which is not specific to a group
            //or specified in RelayTypeSettings configuration
            if (_typeSettingStatusCollection != null &&
                _typeSettingStatusCollection[0] != null)
            {
                newTypeSettingStatusCollection[0] = _typeSettingStatusCollection[0].Clone();
            }
            else
            //If there is a new item or one of the key items changed create a new empty TypeSettingStatus for the TypeId slot
            {
                newTypeSettingStatusCollection[0] = new TypeSettingStatus();
            }
            TypeSetting zeroTypeSetting = CreateZeroTypeSetting();

            newTypeSettingStatusCollection[0].Update(zeroTypeSetting);

            return(newTypeSettingStatusCollection);
        }
Пример #8
0
        /// <summary>
        /// Returns a copy of the <see cref="TypeSettingStatus"/> without items that are not used.
        /// This is to ensure XML output will exclude unused items.
        /// </summary>
        /// <returns>A copy of the <see cref="TypeSettingStatus"/> without items that are not used.</returns>
        internal TypeSettingStatus GetStatus()
        {
            TypeSettingStatus typeSettingStatus = new TypeSettingStatus();

            typeSettingStatus.TypeName              = TypeName;
            typeSettingStatus.TypeId                = TypeId;
            typeSettingStatus.Disabled              = Disabled;
            typeSettingStatus.Compress              = Compress;
            typeSettingStatus.GroupName             = GroupName;
            typeSettingStatus.RelatedIndexTypeId    = RelatedIndexTypeId;
            typeSettingStatus.CheckRaceCondition    = CheckRaceCondition;
            typeSettingStatus.TTLSettingStatus      = TTLSettingStatus.GetStatus();
            typeSettingStatus.SyncInMessages        = SyncInMessages;
            typeSettingStatus.ThrowOnSyncFailure    = ThrowOnSyncFailure;
            typeSettingStatus.GatherStatistics      = GatherStatistics;
            typeSettingStatus.Description           = Description;
            typeSettingStatus.HydrationPolicyStatus = HydrationPolicyStatus.GetStatus();
            typeSettingStatus.BulkInMessageInfo     = BulkInMessageInfo.GetStatus();
            typeSettingStatus.BulkOutMessageInfo    = BulkOutMessageInfo.GetStatus();
            typeSettingStatus.MessageInfo           = MessageInfo.GetStatus();

            return(typeSettingStatus);
        }
Пример #9
0
        private void InitializeInstance(TypeSettingCollection typeSettingCollection)
        {
            if (typeSettingCollection == null)
            {
                _log.Warn("TypeSpecificStatisticsManager:InitializeInstance " +
                          "typeSettingCollection is null.");
                return;
            }

            //set up status collection with max size and whether each element should collect stats
            _typeSettingStatusCollection = new TypeSettingStatus[typeSettingCollection.MaxTypeId + 1];
            foreach (var setting in typeSettingCollection)
            {
                _typeSettingStatusCollection[setting.TypeId] = new TypeSettingStatus();
                _typeSettingStatusCollection[setting.TypeId].Update(setting);
            }

            //Add status for typeId Zero (DeleteAllTypes) which is not specific to a group
            //or specified in RelayTypeSettings configuration
            TypeSetting zeroTypeSetting = CreateZeroTypeSetting();

            _typeSettingStatusCollection[0] = new TypeSettingStatus();
            _typeSettingStatusCollection[0].Update(zeroTypeSetting);
        }
Пример #10
0
        /// <summary>
        /// Determines whether statistics are supposed to be calculated for the specified type.
        /// </summary>
        /// <param name="typeID">The id of the type to collect statistics for.</param>
        /// <returns>True if statistics are to be gathered for the specified type; otherwise false.</returns>
        public bool GatherStats(short typeID)
        {
            if (_typeSettingStatusCollection == null)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:GatherStats " +
                                 "collection is null. Called for typeId:{0}.",
                                 typeID);
                return(false);
            }

            if (typeID >= _typeSettingStatusCollection.Length)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:GatherStats " +
                                 "typeId:{0} is outside of collection bounds:{1}.",
                                 typeID, _typeSettingStatusCollection.Length);
                return(false);
            }
            if (typeID < 0)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:GatherStats " +
                                 "typeId:{0} is less than zero.",
                                 typeID);
                return(false);
            }

            TypeSettingStatus status = _typeSettingStatusCollection[typeID];

            if (status == null)
            {
                LogTypeIdMessage("TypeSpecificStatisticsManager:GatherStats " +
                                 "TypeSettingStatus is null for typeId:{0}",
                                 typeID);
                return(false);
            }
            return(_typeSettingStatusCollection[typeID].GatherStatistics);
        }
Пример #11
0
		public NodeGroupStatus GetNodeGroupStatus(TypeSettingCollection typeSettingCollection)
		{
		 	NodeGroupStatus nodeGroupStatus = new NodeGroupStatus();

			nodeGroupStatus.GroupName = this.GroupName;

			if (typeSettingCollection != null)
			{
				foreach (TypeSetting ts in typeSettingCollection)
				{
					if (ts.GroupName.ToUpperInvariant() == GroupName.ToUpperInvariant())
					{
						TypeSettingStatus typeSettingStatus = new TypeSettingStatus();
						typeSettingStatus.TypeName = ts.TypeName;
						typeSettingStatus.GroupName = ts.GroupName;
						typeSettingStatus.TypeId = ts.TypeId;
						typeSettingStatus.Disabled = ts.Disabled;
						typeSettingStatus.Compress = ts.Compress;
						typeSettingStatus.CheckRaceCondition = ts.CheckRaceCondition;
						typeSettingStatus.TTLSetting = ts.TTLSetting;
						typeSettingStatus.RelatedIndexTypeId = ts.RelatedIndexTypeId;
						if (ts.HydrationPolicy != null)
						{
							typeSettingStatus.HydrationPolicyStatus = new HydrationPolicyStatus();
							typeSettingStatus.HydrationPolicyStatus.KeyType = ts.HydrationPolicy.KeyType.ToString();
							typeSettingStatus.HydrationPolicyStatus.HydrateMisses = (ts.HydrationPolicy.Options &
							                                                         RelayHydrationOptions.HydrateOnMiss) ==
							                                                        RelayHydrationOptions.HydrateOnMiss;
							typeSettingStatus.HydrationPolicyStatus.HydrateBulkMisses = (ts.HydrationPolicy.Options & 
								RelayHydrationOptions.HydrateOnBulkMiss) == RelayHydrationOptions.HydrateOnBulkMiss;
						}
						nodeGroupStatus.TypeSettingStatuses.Add(typeSettingStatus);				
					}
				}
			}

			foreach (NodeCluster cluster in Clusters)
			{
				nodeGroupStatus.NodeClusterStatuses.Add(cluster.GetNodeClusterStatus());
			}

			return nodeGroupStatus;
		}