1515import net .wekeypedia .manager .MongoManager ;
1616
1717
18-
18+ /** This class allowed the use of the toolkit through command line.
19+ *
20+ * @author jeremie
21+ *
22+ */
1923public class Main {
20-
24+ /** Read the list of titles of the pages to download.
25+ *
26+ * @param is
27+ * @return
28+ * @throws IOException
29+ */
2130 public static List <String > getListOfNames (InputStream is ) throws IOException {
2231 List <String > res = new LinkedList <String >();
2332 BufferedReader reader = new BufferedReader (new InputStreamReader (is ));
@@ -30,7 +39,9 @@ public static List<String> getListOfNames(InputStream is) throws IOException{
3039 return res ;
3140 }
3241
33-
42+ /** Display the options of the command line.
43+ *
44+ */
3445 public static void usage (){
3546 System .out .println ("Usage: wikeypedia [OPTIONS]" );
3647 System .out .println ();
@@ -69,13 +80,13 @@ public static void main(String args[]){
6980 if (args [i ].equals ("-mongoDB" )) mongoDB = args [++i ];
7081 if (args [i ].equals ("-mongoCol" )) mongoCollection = args [++i ];
7182 }
72-
83+
7384 List <String > listNames = null ;
7485 if (file ==null ) listNames = Main .getListOfNames (System .in );
7586 else listNames = Main .getListOfNames (new FileInputStream (file ));
7687 int jobsize =1 +listNames .size ()*10 /nbThread ;
7788 JobManager JM = new JobManager (domain ,listNames ,jobsize );
78-
89+
7990 ManagerInterface MI = null ;
8091 if (mongo ){
8192 MongoManager MM = new MongoManager ();
@@ -92,8 +103,9 @@ public static void main(String args[]){
92103 List <DownloadThread > threads = new LinkedList <DownloadThread >();
93104 for (int j =0 ;j <nbThread ;j ++) threads .add (new DownloadThread (JM ,MI ));
94105 for (DownloadThread df :threads ) df .start ();
95- for (DownloadThread df :threads ) df .wait ();
106+ for (DownloadThread df :threads ) df .join ();
96107 }catch (Exception e ){
108+ e .printStackTrace ();
97109 Main .usage ();
98110 }
99111 }
0 commit comments