/// <summary>Save the config to a file</summary> /// <param name="filename">to save</param> /// <returns>self</returns> /// <exception cref="RuntimeException"/> public virtual Org.Apache.Hadoop.Metrics2.Impl.ConfigBuilder Save(string filename ) { try { config.Save(filename); } catch (Exception e) { throw new RuntimeException("Error saving config", e); } return(this); }
internal static string ToString(Org.Apache.Commons.Configuration.Configuration c) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { TextWriter ps = new TextWriter(buffer, false, "UTF-8"); PropertiesConfiguration tmp = new PropertiesConfiguration(); tmp.Copy(c); tmp.Save(ps); return(buffer.ToString("UTF-8")); } catch (Exception e) { throw new MetricsConfigException(e); } }
public override string CurrentConfig() { lock (this) { PropertiesConfiguration saver = new PropertiesConfiguration(); StringWriter writer = new StringWriter(); saver.Copy(config); try { saver.Save(writer); } catch (Exception e) { throw new MetricsConfigException("Error stringify config", e); } return(writer.ToString()); } }
internal static void Dump(string header, Org.Apache.Commons.Configuration.Configuration c, TextWriter @out) { PropertiesConfiguration p = new PropertiesConfiguration(); p.Copy(c); if (header != null) { @out.WriteLine(header); } try { p.Save(@out); } catch (Exception e) { throw new RuntimeException("Error saving config", e); } }