コード例 #1
0
ファイル: ConfigBuilder.cs プロジェクト: orf53975/hadoop.net
 /// <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);
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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());
     }
 }
コード例 #4
0
ファイル: ConfigUtil.cs プロジェクト: orf53975/hadoop.net
        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);
            }
        }