public ACMConfig(Ice.Properties p, Ice.Logger l, string prefix, ACMConfig dflt) { Debug.Assert(prefix != null); string timeoutProperty; if ((prefix.Equals("Ice.ACM.Client") || prefix.Equals("Ice.ACM.Server")) && p.getProperty(prefix + ".Timeout").Length == 0) { timeoutProperty = prefix; // Deprecated property. } else { timeoutProperty = prefix + ".Timeout"; } timeout = p.getPropertyAsIntWithDefault(timeoutProperty, dflt.timeout / 1000) * 1000; // To milliseconds if (timeout < 0) { l.warning("invalid value for property `" + timeoutProperty + "', default value will be used instead"); timeout = dflt.timeout; } int hb = p.getPropertyAsIntWithDefault(prefix + ".Heartbeat", (int)dflt.heartbeat); if (hb >= (int)Ice.ACMHeartbeat.HeartbeatOff && hb <= (int)Ice.ACMHeartbeat.HeartbeatAlways) { heartbeat = (Ice.ACMHeartbeat)hb; } else { l.warning("invalid value for property `" + prefix + ".Heartbeat" + "', default value will be used instead"); heartbeat = dflt.heartbeat; } int cl = p.getPropertyAsIntWithDefault(prefix + ".Close", (int)dflt.close); if (cl >= (int)Ice.ACMClose.CloseOff && cl <= (int)Ice.ACMClose.CloseOnIdleForceful) { close = (Ice.ACMClose)cl; } else { l.warning("invalid value for property `" + prefix + ".Close" + "', default value will be used instead"); close = dflt.close; } }
public ACMConfig(Ice.Communicator communicator, Ice.Logger logger, string prefix, ACMConfig defaults) { Debug.Assert(prefix != null); string timeoutProperty; if ((prefix == "Ice.ACM.Client" || prefix == "Ice.ACM.Server") && communicator.GetProperty($"{prefix}.Timeout") == null) { timeoutProperty = prefix; // Deprecated property. } else { timeoutProperty = prefix + ".Timeout"; } timeout = communicator.GetPropertyAsInt(timeoutProperty) * 1000 ?? defaults.timeout; if (timeout < 0) { logger.warning($"invalid value for property `{timeoutProperty}', default value will be used instead"); timeout = defaults.timeout; } int hb = communicator.GetPropertyAsInt($"{prefix}.Heartbeat") ?? (int)defaults.heartbeat; if (hb >= (int)Ice.ACMHeartbeat.HeartbeatOff && hb <= (int)Ice.ACMHeartbeat.HeartbeatAlways) { heartbeat = (Ice.ACMHeartbeat)hb; } else { logger.warning($"invalid value for property `{prefix}.Heartbeat', default value will be used instead"); heartbeat = defaults.heartbeat; } int cl = communicator.GetPropertyAsInt($"{prefix}.Close") ?? (int)defaults.close; if (cl >= (int)Ice.ACMClose.CloseOff && cl <= (int)Ice.ACMClose.CloseOnIdleForceful) { close = (Ice.ACMClose)cl; } else { logger.warning($"invalid value for property `{prefix}.Close', default value will be used instead"); close = defaults.close; } }
internal bool addOrUpdateMap(Ice.Properties properties, string mapName, IMetricsMapFactory factory, Ice.Logger logger) { // // Add maps to views configured with the given map. // string viewPrefix = "IceMX.Metrics." + _name + "."; string mapsPrefix = viewPrefix + "Map."; Dictionary <string, string> mapsProps = properties.getPropertiesForPrefix(mapsPrefix); string mapPrefix; Dictionary <string, string> mapProps = new Dictionary <string, string>(); if (mapsProps.Count > 0) { mapPrefix = mapsPrefix + mapName + "."; mapProps = properties.getPropertiesForPrefix(mapPrefix); if (mapProps.Count == 0) { // This map isn't configured for this view. return(_maps.Remove(mapName)); } } else { mapPrefix = viewPrefix; mapProps = properties.getPropertiesForPrefix(mapPrefix); } if (properties.getPropertyAsInt(mapPrefix + "Disabled") > 0) { // This map is disabled for this view. return(_maps.Remove(mapName)); } IMetricsMap m; if (_maps.TryGetValue(mapName, out m) && IceUtilInternal.Collections.DictionaryEquals(m.getProperties(), mapProps)) { return(false); // The map configuration didn't change, no need to re-create. } try { _maps[mapName] = factory.create(mapPrefix, properties); } catch (Exception ex) { logger.warning("unexpected exception while creating metrics map:\n" + ex); _maps.Remove(mapName); } return(true); }
internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) { string val; defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); val = properties.getProperty("Ice.Default.Host"); if (val.Length != 0) { defaultHost = val; } else { defaultHost = null; } val = properties.getProperty("Ice.Default.SourceAddress"); if (val.Length > 0) { defaultSourceAddress = Network.getNumericAddress(val); if (defaultSourceAddress == null) { throw new Ice.InitializationException("invalid IP address set for Ice.Default.SourceAddress: `" + val + "'"); } } else { defaultSourceAddress = null; } val = properties.getProperty("Ice.Override.Timeout"); if (val.Length > 0) { overrideTimeout = true; overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout"); if (overrideTimeoutValue < 1 && overrideTimeoutValue != -1) { overrideTimeoutValue = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Override.Timeout `"); msg.Append(properties.getProperty("Ice.Override.Timeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } } else { overrideTimeout = false; overrideTimeoutValue = -1; } val = properties.getProperty("Ice.Override.ConnectTimeout"); if (val.Length > 0) { overrideConnectTimeout = true; overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout"); if (overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1) { overrideConnectTimeoutValue = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Override.ConnectTimeout `"); msg.Append(properties.getProperty("Ice.Override.ConnectTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } } else { overrideConnectTimeout = false; overrideConnectTimeoutValue = -1; } val = properties.getProperty("Ice.Override.CloseTimeout"); if (val.Length > 0) { overrideCloseTimeout = true; overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout"); if (overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1) { overrideCloseTimeoutValue = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Override.CloseTimeout `"); msg.Append(properties.getProperty("Ice.Override.CloseTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } } else { overrideCloseTimeout = false; overrideCloseTimeoutValue = -1; } val = properties.getProperty("Ice.Override.Compress"); if (val.Length > 0) { overrideCompress = true; overrideCompressValue = properties.getPropertyAsInt("Ice.Override.Compress") > 0; if (!BZip2.supported() && overrideCompressValue) { string lib = AssemblyUtil.isWindows ? "bzip2.dll" : "libbz2.so.1"; Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored."); overrideCompressValue = false; } } else { overrideCompress = !BZip2.supported(); overrideCompressValue = false; } val = properties.getProperty("Ice.Override.Secure"); if (val.Length > 0) { overrideSecure = true; overrideSecureValue = properties.getPropertyAsInt("Ice.Override.Secure") > 0; } else { overrideSecure = false; overrideSecureValue = false; } defaultCollocationOptimization = properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0; val = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random"); if (val.Equals("Random")) { defaultEndpointSelection = Ice.EndpointSelectionType.Random; } else if (val.Equals("Ordered")) { defaultEndpointSelection = Ice.EndpointSelectionType.Ordered; } else { Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException(); ex.str = "illegal value `" + val + "'; expected `Random' or `Ordered'"; throw ex; } defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000); if (defaultTimeout < 1 && defaultTimeout != -1) { defaultTimeout = 60000; StringBuilder msg = new StringBuilder("invalid value for Ice.Default.Timeout `"); msg.Append(properties.getProperty("Ice.Default.Timeout")); msg.Append("': defaulting to 60000"); logger.warning(msg.ToString()); } defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); if (defaultLocatorCacheTimeout < -1) { defaultLocatorCacheTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `"); msg.Append(properties.getProperty("Ice.Default.LocatorCacheTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); if (defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1 && defaultInvocationTimeout != -2) { defaultInvocationTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Default.InvocationTimeout `"); msg.Append(properties.getProperty("Ice.Default.InvocationTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0; val = properties.getPropertyWithDefault("Ice.Default.EncodingVersion", Ice.Util.encodingVersionToString(Ice.Util.currentEncoding)); defaultEncoding = Ice.Util.stringToEncodingVersion(val); Protocol.checkSupportedEncoding(defaultEncoding); bool slicedFormat = properties.getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0; defaultFormat = slicedFormat ? Ice.FormatType.SlicedFormat : Ice.FormatType.CompactFormat; }