You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by th...@apache.org on 2008/03/14 12:41:20 UTC
svn commit: r637069 -
/labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java
Author: thorsten
Date: Fri Mar 14 04:41:19 2008
New Revision: 637069
URL: http://svn.apache.org/viewvc?rev=637069&view=rev
Log:
Adding some javadoc comments
Modified:
labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java
Modified: labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java?rev=637069&r1=637068&r2=637069&view=diff
==============================================================================
--- labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java (original)
+++ labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java Fri Mar 14 04:41:19 2008
@@ -28,7 +28,16 @@
import org.apache.droids.api.Task;
import org.apache.droids.api.Worker;
import org.apache.droids.queue.QueueLink;
-
+/**
+ * Default implementation of a crawler.
+ * The crawler needs a starting url and
+ * extract then the next links with the
+ * help of the defaultWorker.
+ *
+ * Extend this method for your own Droid.
+ * @author thorsten
+ *
+ */
public class DefaultCrawler implements Droid {
protected Queue queue;
@@ -38,6 +47,10 @@
private ConcurrentHashMap<Long, Worker> runningWorker;
+ /**
+ * Do the work (whatever it is defined
+ * in the Droid and their workers)
+ */
public void run() {
runningThreads = 0;
taskDate = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System
@@ -66,11 +79,18 @@
return id;
}
+ /**
+ * Start the queue.
+ */
public synchronized void initQueue() {
QueueLink initialLink = new QueueLink(url, taskDate, 0);
queue.init((Task[]) new Task[] { initialLink });
}
+ /**
+ * Get the default worker for the class.
+ * @return
+ */
public synchronized Worker getWorker() {
DefaultWorker worker = new DefaultWorker();
worker.setQueue(getQueue());
@@ -122,6 +142,12 @@
}
protected ThreadPoolExecutor pool;
+
+ /**
+ * Shutdown all threads, close the pools and leave.
+ * If it is not working by asking nice to shutdown just kill all
+ * threads.
+ */
protected synchronized void shutdownAndAwaitTermination() {
Core.threadMessage("SHUTTING DOWN");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org