/// <summary> /// To ensure there are not multiple instances of the SCM running on a given /// cluster, a global pid file is used. /// </summary> /// <remarks> /// To ensure there are not multiple instances of the SCM running on a given /// cluster, a global pid file is used. This file contains the hostname of the /// machine that owns the pid file. /// </remarks> /// <returns>true if the pid file was written, false otherwise</returns> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> private bool WriteGlobalCleanerPidFile() { string root = conf.Get(YarnConfiguration.SharedCacheRoot, YarnConfiguration.DefaultSharedCacheRoot ); Path pidPath = new Path(root, GlobalCleanerPid); try { FileSystem fs = FileSystem.Get(this.conf); if (fs.Exists(pidPath)) { return(false); } FSDataOutputStream os = fs.Create(pidPath, false); // write the hostname and the process id in the global cleaner pid file string Id = ManagementFactory.GetRuntimeMXBean().GetName(); os.WriteUTF(Id); os.Close(); // add it to the delete-on-exit to ensure it gets deleted when the JVM // exits fs.DeleteOnExit(pidPath); } catch (IOException e) { throw new YarnException(e); } Log.Info("Created the global cleaner pid file at " + pidPath.ToString()); return(true); }