KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > core > task > Scheduler


1 package net.javacoding.jspider.core.task;
2
3 import net.javacoding.jspider.core.exception.TaskAssignmentException;
4 import net.javacoding.jspider.core.task.work.DecideOnSpideringTask;
5
6 import java.net.URL JavaDoc;
7
8
9 /**
10  * Interface that will be implemented upon each object that will act as a task
11  * scheduler.
12  * The Task scheduler will keep track of all work that is being done and all
13  * tasks that still have to be carried out.
14  *
15  * $Id: Scheduler.java,v 1.10 2003/04/25 21:28:59 vanrogu Exp $
16  *
17  * @author Günther Van Roey
18  */

19 public interface Scheduler {
20
21     /**
22      * Schedules a Worker Task to be executed. The scheduler will keep a
23      * reference to the task and return it later on to be processed.
24      * @param task task to be scheduled
25      */

26     public void schedule(WorkerTask task);
27
28     /**
29      * Block a task for a certain siteURL. This is used to block any
30      * resource handling for a site for which we didn't interpret the
31      * robots.txt file yet.
32      * @param siteURL the site for which the task is
33      * @param task the task to be temporarily blocked
34      */

35     public void block( URL JavaDoc siteURL, DecideOnSpideringTask task);
36
37     /**
38      * Returns all tasks that were blocked for the specified site, and
39      * removes them from the blocked resources pool.
40      * @param siteURL the site we want to unblock all resources for
41      * @return array with all tasks that were blocked for this site
42      */

43     public DecideOnSpideringTask[] unblock(URL JavaDoc siteURL);
44
45     /**
46      * Flags a task as done. This way, we are able to remove the task from
47      * the in-process list.
48      * @param task task that was completed
49      */

50     public void flagDone(WorkerTask task);
51
52     /**
53      * Returns a thinker task to be processed
54      * @return Task to be carried out
55      * @throws TaskAssignmentException if all the work is done or no suitable
56      * items are found for the moment.
57      */

58     public WorkerTask getThinkerTask() throws TaskAssignmentException;
59
60     /**
61      * Returns a fetch task to be processed
62      * @return Task to be carried out
63      * @throws TaskAssignmentException if all the work is done or no suitable
64      * items are found for the moment.
65      */

66     public WorkerTask getFethTask() throws TaskAssignmentException;
67
68     /**
69      * Determines whether all the tasks are done. If there are no more tasks
70      * scheduled for process, and no ongoing tasks, it is impossible that new
71      * work will arrive, so the spidering is done.
72      * @return boolean value determining whether all work is done
73      */

74     public boolean allTasksDone();
75
76     /**
77      * Statistics method.
78      * @return blocked jobs counter
79      */

80     public int getBlockedCount( );
81
82     /**
83      * Statistics method.
84      * @return assigned jobs counter
85      */

86     public int getAssignedCount( );
87
88     /**
89      * Statistics method.
90      * @return total jobs counter
91      */

92     public int getJobCount ( );
93
94     /**
95      * Statistics method.
96      * @return total thinker jobs counter
97      */

98     public int getThinkerJobCount ( );
99
100     /**
101      * Statistics method.
102      * @return total spider jobs counter
103      */

104     public int getSpiderJobCount ( );
105
106     /**
107      * Statistics method.
108      * @return jobs finished counter
109      */

110     public int getJobsDone ( );
111
112     /**
113      * Statistics method.
114      * @return finished spider jobs counter
115      */

116     public int getSpiderJobsDone ( );
117
118     /**
119      * Statistics method.
120      * @return finished thinker jobs counter
121      */

122     public int getThinkerJobsDone ( );
123
124 }
125
Popular Tags