private ResponseMessage HandleMessage(RequestMessage msg)
        {
            IndexingServiceRequest isr = (IndexingServiceRequest)msg;

            LuceneQueryable backend = this;

            if (isr.Source != null)
            {
                Queryable target = QueryDriver.GetQueryable(isr.Source);

                if (target == null)
                {
                    string err = String.Format("Unable to find backend matching '{0}'", isr.Source);

                    Log.Error(err);
                    return(new ErrorResponse(err));
                }

                if (!(target.IQueryable is LuceneQueryable))
                {
                    string err = String.Format("Backend '{0}' is not an indexed backend", isr.Source);

                    Log.Error(err);
                    return(new ErrorResponse(err));
                }

                backend = (LuceneQueryable)target.IQueryable;
                Log.Debug("Found backend for IndexingServiceRequest: {0}", backend.IndexName);
            }

            // FIXME: There should be a way for the request to control the
            // scheduler priority of the task.

            if (isr.ToAdd.Count > 0 || isr.ToRemove.Count > 0)
            {
                Log.Debug("IndexingService: Adding {0} indexables, removing {1} indexables.", isr.ToAdd.Count, isr.ToRemove.Count);

                IndexableGenerator ind_gen;
                ind_gen = new IndexableGenerator(isr.ToAdd, isr.ToRemove, this);
                Scheduler.Task task = backend.NewAddTask(ind_gen);
                task.Priority = Scheduler.Priority.Immediate;
                ThisScheduler.Add(task);
            }

            // FIXME: There should be an asynchronous response  (fired by a Scheduler.Hook)
            // that fires when all of the items have been added to the index.

            // No response
            return(new EmptyResponse());
        }
Пример #2
0
		private void StartWorker ()
		{
			string index_path = Path.Combine (PathFinder.StorageDir, "ToIndex");

			if (!Directory.Exists (index_path))
				Directory.CreateDirectory (index_path);

			if (Inotify.Enabled)
				Inotify.Subscribe (index_path, OnInotifyEvent, Inotify.EventType.CloseWrite);

			Logger.Log.Info ("Setting up an initial crawl of the IndexingService directory");

			IndexableGenerator generator = new IndexableGenerator (GetIndexables (index_path));
			Scheduler.Task task = NewAddTask (generator);
			task.Tag = "IndexingService initial crawl";
			ThisScheduler.Add (task);
		}
        private void StartWorker()
        {
            string index_path = Path.Combine(PathFinder.StorageDir, "ToIndex");

            if (!Directory.Exists(index_path))
            {
                Directory.CreateDirectory(index_path);
            }

            if (Inotify.Enabled)
            {
                Inotify.Subscribe(index_path, OnInotifyEvent, Inotify.EventType.CloseWrite);
            }

            Logger.Log.Info("Setting up an initial crawl of the IndexingService directory");

            IndexableGenerator generator = new IndexableGenerator(GetIndexables(index_path));

            Scheduler.Task task = NewAddTask(generator);
            task.Tag = "IndexingService initial crawl";
            ThisScheduler.Add(task);
        }
Пример #4
0
		private ResponseMessage HandleMessage (RequestMessage msg)
		{
			IndexingServiceRequest isr = (IndexingServiceRequest) msg;

			LuceneQueryable backend = this;

			if (isr.Source != null) {
				Queryable target = QueryDriver.GetQueryable (isr.Source);

				if (target == null) {
					string err = String.Format ("Unable to find backend matching '{0}'", isr.Source);

					Log.Error (err);
					return new ErrorResponse (err);
				}

				if (! (target.IQueryable is LuceneQueryable)) {
					string err = String.Format ("Backend '{0}' is not an indexed backend", isr.Source);

					Log.Error (err);
					return new ErrorResponse (err);
				}

				backend = (LuceneQueryable) target.IQueryable;
				Log.Debug ("Found backend for IndexingServiceRequest: {0}", backend.IndexName);
			}

			// FIXME: There should be a way for the request to control the
			// scheduler priority of the task.

			if (isr.ToAdd.Count > 0 || isr.ToRemove.Count > 0) {
				Log.Debug ("IndexingService: Adding {0} indexables, removing {1} indexables.", isr.ToAdd.Count, isr.ToRemove.Count);

				IndexableGenerator ind_gen;
				ind_gen = new IndexableGenerator (isr.ToAdd, isr.ToRemove, this);
				Scheduler.Task task = backend.NewAddTask (ind_gen);
				task.Priority = Scheduler.Priority.Immediate;
				ThisScheduler.Add (task);
			}

			// FIXME: There should be an asynchronous response  (fired by a Scheduler.Hook)
			// that fires when all of the items have been added to the index.
			
			// No response
			return new EmptyResponse ();
		}