1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.archive.hcc.client;
26
27 import java.net.InetSocketAddress;
28 import java.util.Collection;
29
30 /***
31 *
32 * @author dbernstein
33 *
34 */
35 public interface ClusterControllerClient {
36
37 /***
38 * Creates a new instance of the crawler.
39 * @return
40 * @throws InsufficientCrawlingResourcesException If no crawling machines have capicity for another crawler instance.
41 * @throws ClusterException
42 */
43 public Crawler createCrawler()
44 throws InsufficientCrawlingResourcesException, ClusterException;
45
46 /***
47 * Lists all the crawler instances in the cluster.
48 * @return
49 * @throws ClusterException
50 */
51 public Collection<Crawler> listCrawlers() throws ClusterException;
52
53
54 /***
55 * Issues destroy commands to all the crawlers managed by the controller.
56 * @throws ClusterException
57 */
58 public void destroyAllCrawlers() throws ClusterException;
59
60 /***
61 * Destroys the cluster controller bean which the client is communicating with.
62 * It doesn't actually affect any objects within the cluster - ie containers,
63 * crawlers, and jobs.
64 *
65 */
66 public void destroy();
67
68 /***
69 * Returns the matching crawler.
70 * @param uid A crawl job's id.
71 * @param address The remote address of the crawler (ie not the hcc proxied address)
72 * @return The crawler or null if the parent cannot be found.
73 * @throws ClusterException
74 */
75 public Crawler findCrawlJobParent(String uid, InetSocketAddress address)
76 throws ClusterException;
77
78
79 /***
80 * Returns the current job running on the specified crawler. If the crawler is not
81 * found or the crawler is not currently running a job, null will be returned.
82 * @param crawler
83 * @return
84 * @throws ClusterException
85 */
86 public CurrentCrawlJob getCurrentCrawlJob(Crawler crawler) throws ClusterException;
87 /***
88 * Adds a crawler lifecycle listener.
89 * @param l
90 */
91 public void addCrawlerLifecycleListener(CrawlerLifecycleListener l);
92
93 /***
94 * Removes a crawler lifecycle listener.
95 * @param l
96 */
97 public void removeCrawlerLifecycleListener(CrawlerLifecycleListener l);
98
99 /***
100 * Adds a crawl job listener.
101 * @param l
102 */
103 public void addCrawlJobListener(CurrentCrawlJobListener l);
104
105 /***
106 * Removes a crawl job listener.
107 * @param l
108 */
109 public void removeCrawlJobListener(CurrentCrawlJobListener l);
110
111 /***
112 * Returns the maximum number of instances allowed for this container.
113 * If the container does not exist, -1 is returned.
114 * @param hostname
115 * @param port
116 * @return
117 */
118 public int getMaxInstances(String hostname, int port)
119 throws ClusterException;
120
121 /***
122 * Sets the maximum number of instances that may run on a
123 * specified container defined by a host and port.
124 * @param hostname
125 * @param port
126 * @param maxInstances
127 */
128 public void setMaxInstances(String hostname, int port, int maxInstances)
129 throws ClusterException;
130
131
132 /***
133 *
134 * @return true if pause was successfully invoked on all running jobs.
135 * @throws ClusterControllerException
136 */
137 public boolean pauseAllJobs()
138 throws ClusterException;
139
140 /***
141 *
142 * @return true if resume was successfully invoked on all paused or pausing jobs.
143 * @throws ClusterControllerException
144 */
145 public boolean resumeAllPausedJobs()
146 throws ClusterException;
147
148
149 }