diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring/WorkManager.cs')
-rw-r--r-- | OpenSim/Framework/Monitoring/WorkManager.cs | 76 |
1 files changed, 74 insertions, 2 deletions
diff --git a/OpenSim/Framework/Monitoring/WorkManager.cs b/OpenSim/Framework/Monitoring/WorkManager.cs index 9d0eefc..134661b 100644 --- a/OpenSim/Framework/Monitoring/WorkManager.cs +++ b/OpenSim/Framework/Monitoring/WorkManager.cs | |||
@@ -57,7 +57,29 @@ namespace OpenSim.Framework.Monitoring | |||
57 | 57 | ||
58 | static WorkManager() | 58 | static WorkManager() |
59 | { | 59 | { |
60 | JobEngine = new JobEngine(); | 60 | JobEngine = new JobEngine("Non-blocking non-critical job engine", "JOB ENGINE"); |
61 | |||
62 | StatsManager.RegisterStat( | ||
63 | new Stat( | ||
64 | "JobsWaiting", | ||
65 | "Number of jobs waiting for processing.", | ||
66 | "", | ||
67 | "", | ||
68 | "server", | ||
69 | "jobengine", | ||
70 | StatType.Pull, | ||
71 | MeasuresOfInterest.None, | ||
72 | stat => stat.Value = JobEngine.JobsWaiting, | ||
73 | StatVerbosity.Debug)); | ||
74 | |||
75 | MainConsole.Instance.Commands.AddCommand( | ||
76 | "Debug", | ||
77 | false, | ||
78 | "debug jobengine", | ||
79 | "debug jobengine <start|stop|status|log>", | ||
80 | "Start, stop, get status or set logging level of the job engine.", | ||
81 | "If stopped then all outstanding jobs are processed immediately.", | ||
82 | HandleControlCommand); | ||
61 | } | 83 | } |
62 | 84 | ||
63 | /// <summary> | 85 | /// <summary> |
@@ -200,7 +222,7 @@ namespace OpenSim.Framework.Monitoring | |||
200 | } | 222 | } |
201 | 223 | ||
202 | if (JobEngine.IsRunning) | 224 | if (JobEngine.IsRunning) |
203 | JobEngine.QueueRequest(name, callback, obj); | 225 | JobEngine.QueueJob(name, () => callback(obj)); |
204 | else if (canRunInThisThread) | 226 | else if (canRunInThisThread) |
205 | callback(obj); | 227 | callback(obj); |
206 | else if (mustNotTimeout) | 228 | else if (mustNotTimeout) |
@@ -208,5 +230,55 @@ namespace OpenSim.Framework.Monitoring | |||
208 | else | 230 | else |
209 | Util.FireAndForget(callback, obj, name); | 231 | Util.FireAndForget(callback, obj, name); |
210 | } | 232 | } |
233 | |||
234 | private static void HandleControlCommand(string module, string[] args) | ||
235 | { | ||
236 | // if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) | ||
237 | // return; | ||
238 | |||
239 | if (args.Length < 3) | ||
240 | { | ||
241 | MainConsole.Instance.Output("Usage: debug jobengine <stop|start|status|log>"); | ||
242 | return; | ||
243 | } | ||
244 | |||
245 | string subCommand = args[2]; | ||
246 | |||
247 | if (subCommand == "stop") | ||
248 | { | ||
249 | JobEngine.Stop(); | ||
250 | MainConsole.Instance.OutputFormat("Stopped job engine."); | ||
251 | } | ||
252 | else if (subCommand == "start") | ||
253 | { | ||
254 | JobEngine.Start(); | ||
255 | MainConsole.Instance.OutputFormat("Started job engine."); | ||
256 | } | ||
257 | else if (subCommand == "status") | ||
258 | { | ||
259 | MainConsole.Instance.OutputFormat("Job engine running: {0}", JobEngine.IsRunning); | ||
260 | |||
261 | JobEngine.Job job = JobEngine.CurrentJob; | ||
262 | MainConsole.Instance.OutputFormat("Current job {0}", job != null ? job.Name : "none"); | ||
263 | |||
264 | MainConsole.Instance.OutputFormat( | ||
265 | "Jobs waiting: {0}", JobEngine.IsRunning ? JobEngine.JobsWaiting.ToString() : "n/a"); | ||
266 | MainConsole.Instance.OutputFormat("Log Level: {0}", JobEngine.LogLevel); | ||
267 | } | ||
268 | else if (subCommand == "log") | ||
269 | { | ||
270 | // int logLevel; | ||
271 | int logLevel = int.Parse(args[3]); | ||
272 | // if (ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out logLevel)) | ||
273 | // { | ||
274 | JobEngine.LogLevel = logLevel; | ||
275 | MainConsole.Instance.OutputFormat("Set debug log level to {0}", JobEngine.LogLevel); | ||
276 | // } | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | MainConsole.Instance.OutputFormat("Unrecognized job engine subcommand {0}", subCommand); | ||
281 | } | ||
282 | } | ||
211 | } | 283 | } |
212 | } \ No newline at end of file | 284 | } \ No newline at end of file |