cvsimport
[beagle.git] / beagled / RemoteControlExecutors.cs
blobff794805b23b45468c0018c6c0795173c0af36bc
1 //
2 // SnippetExecutor.cs
3 //
4 // Copyright (C) 2005 Novell, Inc.
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
27 using System;
28 using System.Collections;
29 using System.Threading;
30 using System.Xml.Serialization;
32 using Beagle.Util;
34 namespace Beagle.Daemon {
36 [RequestMessage (typeof (DaemonInformationRequest))]
37 public class DaemonInformationExecutor : RequestMessageExecutor {
39 public override ResponseMessage Execute (RequestMessage request)
41 DaemonInformationResponse response = new DaemonInformationResponse ();
42 DaemonInformationRequest req = (DaemonInformationRequest) request;
44 if (req.GetVersion)
45 response.Version = ExternalStringsHack.Version;
47 if (req.GetSchedInfo)
48 response.SchedulerInformation = Scheduler.Global.GetCurrentStatus ();
50 if (req.GetIndexStatus) {
51 response.IndexStatus = new ArrayList ();
52 foreach (QueryableStatus status in QueryDriver.GetIndexInformation ())
53 response.IndexStatus.Add (status);
56 if (req.GetIsIndexing)
57 response.IsIndexing = QueryDriver.IsIndexing;
59 return response;
63 [RequestMessage (typeof (ShutdownRequest))]
64 public class ShutdownExecutor : RequestMessageExecutor {
66 private void DoShutdown ()
68 Shutdown.BeginShutdown ();
71 public override ResponseMessage Execute (RequestMessage req)
73 // Start the shutdown process in a separate thread
74 // to avoid a deadlock: BeginShutdown() waits until
75 // all worker process are finished, but this method
76 // itself is part of a worker.
77 ExceptionHandlingThread.Start (new ThreadStart (DoShutdown));
79 return new EmptyResponse ();
83 [RequestMessage (typeof (ReloadConfigRequest))]
84 public class ReloadConfigExecutor : RequestMessageExecutor {
86 public override ResponseMessage Execute (RequestMessage req)
88 Conf.Load (true);
89 return new EmptyResponse ();
93 [RequestMessage (typeof (OptimizeIndexesRequest))]
94 public class OptimizeIndexesExecutor : RequestMessageExecutor {
96 public override ResponseMessage Execute (RequestMessage req)
98 LuceneQueryable.OptimizeAll ();
99 return new EmptyResponse ();