View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.aggregator;
18  
19  import org.apache.jetspeed.util.Queue;
20  
21  /***
22   * The Worker Monitor is a thread manager and monitor for async portlet aggregation
23   * and rendering.
24   *
25   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
26   * @version $Id: $
27   */
28  public interface WorkerMonitor 
29  {
30      /***
31       * Start processing the worker monitor
32       *
33       */
34      void start();
35      
36      /***
37       * Stop processing the worker monitor
38       * Finish all jobs
39       *
40       */
41      void stop();
42      
43      /***
44       * Retrieves a snapshot of job count in the waiting (backlogged) queue
45       * 
46       * @return snapshot count of waiting jobs
47       */
48      int getQueuedJobsCount();
49      
50      /***
51       * Returns a snapshot count of the available jobs
52       * @return available jobs count
53       */
54      int getAvailableJobsCount();
55      
56      /***
57       * Returns a snapshot count of the jobs currently running
58       * 
59       * @return snapshot count of running jobs
60       */
61      int getRunningJobsCount();
62      
63      void setQueue(Queue queue);
64      
65      Worker getWorker();
66      
67      /*** 
68       * Start processing a job, assign it to a worker thread.
69       * 
70       * @param job
71       */
72      void process(RenderingJob job);
73      
74      /***
75       * Release a job on completion
76       * 
77       * @param worker
78       */
79      void release(Worker worker);
80  }