Exemple #1
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);
        }
Exemple #2
0
        /// <summary>
        /// Our Xen hosted machines all think they have the same IP address at the NIC level. When
        /// they boot, an Environment variable "IPADDRESS" is set to give us a locally visible
        /// copy of their external IP address.
        /// </summary>
        /// <returns>Returns <see langword="null"/> if no environment address is defined; otherwise, returns the IP address.</returns>
        public static IPAddress GetEnvironmentDefinedIPAddress()
        {
            IPAddress environmentIP = null;

            try
            {
                string environmentIPstring = Environment.GetEnvironmentVariable("IPADDRESS", EnvironmentVariableTarget.Machine);
                if (String.IsNullOrEmpty(environmentIPstring) == false)
                {
                    if (IPAddress.TryParse(environmentIPstring, out environmentIP))
                    {
                        if (_log.IsInfoEnabled)
                        {
                            _log.InfoFormat("Got IPAddress {0} from environment variable \"IPADDRESS\"", environmentIP);
                        }
                    }
                    else
                    {
                        if (_log.IsWarnEnabled)
                        {
                            _log.WarnFormat("Could not parse address {0} from environment variable \"IPADDRESS\"", environmentIPstring);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _log.ErrorFormat("Exception getting IP address from environment variable \"IPAddress\": {0}", e);
                throw;
            }

            return(environmentIP);
        }
        static LocalCache()
        {
            _log = new LogWrapper();
            ITypePolicy    policy  = null;
            IObjectStorage storage = null;
            var            section = LocalCacheConfigurationSection.GetInstance();

            if (section != null)
            {
                if (section.TypePolicy != null)
                {
                    policy = section.TypePolicy.ObtainInstance();
                }
                if (section.Storage != null)
                {
                    storage = section.Storage.ObtainInstance();
                }
            }

            if (policy == null)
            {
                _log.WarnFormat("ITypePolicy implementation not found.  Local caching disabled.");
                policy = new ByNameTypePolicyFactory().ObtainInstance();                 // We need a policy as TypeStace and CacheTypeStatic calls need one.
            }

            if (storage == null)
            {
                _log.WarnFormat("IObjectStorage implementation not found.  Local caching disabled.");
            }

            Policy = policy;

            if (storage != null)
            {
                _storage          = storage;
                _storage.Dropped += StorageItemDropped;
            }
            else
            {
                _storage = null;
            }
        }
        private static int _reloadWindowSeconds = 10;     //not const to allow test to change

        #endregion

        #region Ctor

        static AssemblyLoader()
        {
            try
            {
                string value = ConfigurationManager.AppSettings["ReloadOnFileChanges"];
                if (value != null)
                {
                    bool reload;
                    if (bool.TryParse(value, out reload))
                    {
                        _reloadOnAssemblyChanges = reload;
                    }
                    else
                    {
                        _log.WarnFormat("Invalid appSetting value for key 'ReloadOnFileChanges': {0}", value ?? "null");
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error("Couldn't access app settings", ex);
            }
        }
        private void InitializeCounters()
        {
            _log.InfoFormat("Verifying performance counter installation for category '{0}'...", _category);

            try
            {
                if (!PerformanceCounterCategory.Exists(_category))
                {
                    _log.WarnFormat("Performance counters in category '{0}' are not installed.", _category);
                    return;
                }

                // Zero all counters in the current category.
                _log.InfoFormat("Zeroing all performance counters in category/instance '{0}'/'{1}' ", _category, _instanceName);

                var cat = new PerformanceCounterCategory(_category);
                if (cat.InstanceExists(_instanceName))
                {
                    foreach (PerformanceCounter counter in cat.GetCounters(_instanceName))
                    {
                        try
                        {
                            counter.ReadOnly = false;
                            counter.RawValue = 0;
                        }
                        finally
                        {
                            counter.Dispose();
                        }
                    }
                }
            }
            catch (Exception x)
            {
                _log.Error(String.Format("Initializing perf counter category/instance {0}/{1} failed.", _category, _instanceName), x);
            }
        }
Exemple #6
0
 /// <summary>
 /// 警告
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 public static void Warn(string format, object[] args)
 {
     _log.WarnFormat(format, args);
 }
Exemple #7
0
 private static void LogTypeIdMessage(string message, short typeId)
 {
     _log.WarnFormat(message, typeId);
 }