/// <exception cref="System.Exception"/> protected override void ServiceInit(Configuration conf) { FsPermission storeDirPerms = new FsPermission((short)0x1c0); Path stateStoreRoot = null; FileSystem stateStoreFs = null; bool recoveryEnabled = conf.GetBoolean(YarnConfiguration.NmRecoveryEnabled, YarnConfiguration .DefaultNmRecoveryEnabled); if (recoveryEnabled) { stateStoreRoot = new Path(conf.Get(YarnConfiguration.NmRecoveryDir), StateStoreRootName ); stateStoreFs = FileSystem.GetLocal(conf); } ICollection <string> auxNames = conf.GetStringCollection(YarnConfiguration.NmAuxServices ); foreach (string sName in auxNames) { try { Preconditions.CheckArgument(ValidateAuxServiceName(sName), "The ServiceName: " + sName + " set in " + YarnConfiguration.NmAuxServices + " is invalid." + "The valid service name should only contain a-zA-Z0-9_ " + "and can not start with numbers"); Type sClass = conf.GetClass <AuxiliaryService>(string.Format(YarnConfiguration.NmAuxServiceFmt , sName), null); if (null == sClass) { throw new RuntimeException("No class defined for " + sName); } AuxiliaryService s = ReflectionUtils.NewInstance(sClass, conf); // TODO better use s.getName()? if (!sName.Equals(s.GetName())) { Log.Warn("The Auxilurary Service named '" + sName + "' in the " + "configuration is for " + sClass + " which has " + "a name of '" + s.GetName() + "'. Because these are " + "not the same tools trying to send ServiceData and read " + "Service Meta Data may have issues unless the refer to " + "the name in the config."); } AddService(sName, s); if (recoveryEnabled) { Path storePath = new Path(stateStoreRoot, sName); stateStoreFs.Mkdirs(storePath, storeDirPerms); s.SetRecoveryPath(storePath); } s.Init(conf); } catch (RuntimeException e) { Log.Fatal("Failed to initialize " + sName, e); throw; } } base.ServiceInit(conf); }
// Obtain services from configuration in init() protected internal void AddService(string name, AuxiliaryService service) { lock (this) { Log.Info("Adding auxiliary service " + service.GetName() + ", \"" + name + "\""); serviceMap[name] = service; } }
private void LogWarningWhenAuxServiceThrowExceptions(AuxiliaryService service, AuxServicesEventType eventType, Exception th) { Log.Warn((null == service ? "The auxService is null" : "The auxService name is " + service.GetName()) + " and it got an error at event: " + eventType, th); }