public override void Init(string contextName, ContextFactory factory) { base.Init(contextName, factory); Log.Debug("Initializing the GangliaContext31 for Ganglia 3.1 metrics."); // Take the hostname from the DNS class. Configuration conf = new Configuration(); if (conf.Get("slave.host.name") != null) { hostName = conf.Get("slave.host.name"); } else { try { hostName = DNS.GetDefaultHost(conf.Get("dfs.datanode.dns.interface", "default"), conf.Get("dfs.datanode.dns.nameserver", "default")); } catch (UnknownHostException uhe) { Log.Error(uhe); hostName = "UNKNOWN.example.com"; } } }
/* * Output of "gmetric --help" showing allowable values * -t, --type=STRING * Either string|int8|uint8|int16|uint16|int32|uint32|float|double * -u, --units=STRING Unit of measure for the value e.g. Kilobytes, Celcius * (default='') * -s, --slope=STRING Either zero|positive|negative|both * (default='both') * -x, --tmax=INT The maximum time in seconds between gmetric calls * (default='60') */ // as per libgmond.c // 0 // 1 // 2 // 3 /* * (non-Javadoc) * * @see * org.apache.hadoop.metrics2.MetricsPlugin#init(org.apache.commons.configuration * .SubsetConfiguration) */ public virtual void Init(SubsetConfiguration conf) { Log.Debug("Initializing the GangliaSink for Ganglia metrics."); this.conf = conf; // Take the hostname from the DNS class. if (conf.GetString("slave.host.name") != null) { hostName = conf.GetString("slave.host.name"); } else { try { hostName = DNS.GetDefaultHost(conf.GetString("dfs.datanode.dns.interface", "default" ), conf.GetString("dfs.datanode.dns.nameserver", "default")); } catch (UnknownHostException uhe) { Log.Error(uhe); hostName = "UNKNOWN.example.com"; } } // load the gannglia servers from properties metricsServers = Servers.Parse(conf.GetString(ServersProperty), DefaultPort); multicastEnabled = conf.GetBoolean(MulticastEnabledProperty, DefaultMulticastEnabled ); multicastTtl = conf.GetInt(MulticastTtlProperty, DefaultMulticastTtl); // extract the Ganglia conf per metrics gangliaConfMap = new Dictionary <string, GangliaConf>(); LoadGangliaConf(AbstractGangliaSink.GangliaConfType.units); LoadGangliaConf(AbstractGangliaSink.GangliaConfType.tmax); LoadGangliaConf(AbstractGangliaSink.GangliaConfType.dmax); LoadGangliaConf(AbstractGangliaSink.GangliaConfType.slope); try { if (multicastEnabled) { Log.Info("Enabling multicast for Ganglia with TTL " + multicastTtl); datagramSocket = new MulticastSocket(); ((MulticastSocket)datagramSocket).SetTimeToLive(multicastTtl); } else { datagramSocket = new DatagramSocket(); } } catch (IOException e) { Log.Error(e); } // see if sparseMetrics is supported. Default is false supportSparseMetrics = conf.GetBoolean(SupportSparseMetricsProperty, SupportSparseMetricsDefault ); }
/// <summary> /// Attempt to determine the fully qualified domain name for this host /// to compare during testing. /// </summary> /// <remarks> /// Attempt to determine the fully qualified domain name for this host /// to compare during testing. /// This is necessary because in order for the BackupNode test to correctly /// work, the namenode must have its http server started with the fully /// qualified address, as this is the one the backupnode will attempt to start /// on as well. /// </remarks> /// <returns>Fully qualified hostname, or 127.0.0.1 if can't determine</returns> public static string GetFullHostName() { try { return(DNS.GetDefaultHost("default")); } catch (UnknownHostException) { Log.Warn("Unable to determine hostname. May interfere with obtaining " + "valid test results." ); return("127.0.0.1"); } }