/// <exception cref="System.Exception"/> public T Run() { FileSystem fs = this._enclosing.CreateFileSystem(conf); Instrumentation instrumentation = this._enclosing.GetServer().Get <Instrumentation >(); Instrumentation.Cron cron = instrumentation.CreateCron(); try { this._enclosing.CheckNameNodeHealth(fs); cron.Start(); return(executor.Execute(fs)); } finally { cron.Stop(); instrumentation.AddCron(FileSystemAccessService.InstrumentationGroup, executor.GetType ().Name, cron); this._enclosing.CloseFileSystem(fs); } }
public void Run() { string instrName = callable.GetType().Name; Instrumentation instr = this._enclosing.GetServer().Get <Instrumentation>(); if (this._enclosing.GetServer().GetStatus() == Server.Status.Halted) { Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.Log.Debug("Skipping [{}], server status [{}]" , callable, this._enclosing.GetServer().GetStatus()); instr.Incr(Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.InstGroup, instrName + ".skips", 1); } else { Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.Log.Debug("Executing [{}]" , callable); instr.Incr(Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.InstGroup, instrName + ".execs", 1); Instrumentation.Cron cron = instr.CreateCron().Start(); try { callable.Call(); } catch (Exception ex) { instr.Incr(Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.InstGroup, instrName + ".fails", 1); Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.Log.Error("Error executing [{}], {}" , new object[] { callable, ex.Message, ex }); } finally { instr.AddCron(Org.Apache.Hadoop.Lib.Service.Scheduler.SchedulerService.InstGroup, instrName, cron.Stop()); } } }
public virtual void Service() { string dir = TestDirHelper.GetTestDir().GetAbsolutePath(); string services = StringUtils.Join(",", Arrays.AsList(typeof(InstrumentationService ).FullName)); Configuration conf = new Configuration(false); conf.Set("server.services", services); Org.Apache.Hadoop.Lib.Server.Server server = new Org.Apache.Hadoop.Lib.Server.Server ("server", dir, dir, dir, dir, conf); server.Init(); Org.Apache.Hadoop.Lib.Service.Instrumentation instrumentation = server.Get <Org.Apache.Hadoop.Lib.Service.Instrumentation >(); NUnit.Framework.Assert.IsNotNull(instrumentation); instrumentation.Incr("g", "c", 1); instrumentation.Incr("g", "c", 2); instrumentation.Incr("g", "c1", 2); Instrumentation.Cron cron = instrumentation.CreateCron(); cron.Start(); Sleep(100); cron.Stop(); instrumentation.AddCron("g", "t", cron); cron = instrumentation.CreateCron(); cron.Start(); Sleep(200); cron.Stop(); instrumentation.AddCron("g", "t", cron); Instrumentation.Variable <string> var = new _Variable_329(); instrumentation.AddVariable("g", "v", var); Instrumentation.Variable <long> varToSample = new _Variable_337(); instrumentation.AddSampler("g", "s", 10, varToSample); IDictionary <string, object> snapshot = instrumentation.GetSnapshot(); NUnit.Framework.Assert.IsNotNull(snapshot["os-env"]); NUnit.Framework.Assert.IsNotNull(snapshot["sys-props"]); NUnit.Framework.Assert.IsNotNull(snapshot["jvm"]); NUnit.Framework.Assert.IsNotNull(snapshot["counters"]); NUnit.Framework.Assert.IsNotNull(snapshot["timers"]); NUnit.Framework.Assert.IsNotNull(snapshot["variables"]); NUnit.Framework.Assert.IsNotNull(snapshot["samplers"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, string>)snapshot["os-env"] )["PATH"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, string>)snapshot["sys-props" ])["java.version"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, object>)snapshot["jvm"])["free.memory" ]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, object>)snapshot["jvm"])["max.memory" ]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, object>)snapshot["jvm"])["total.memory" ]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["counters"])["g"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["timers"])["g"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["variables"])["g"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["samplers"])["g"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["counters"])["g"]["c"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["counters"])["g"]["c1"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["timers"])["g"]["t"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["variables"])["g"]["v"]); NUnit.Framework.Assert.IsNotNull(((IDictionary <string, IDictionary <string, object > >)snapshot["samplers"])["g"]["s"]); StringWriter writer = new StringWriter(); JSONObject.WriteJSONString(snapshot, writer); writer.Close(); server.Destroy(); }