
2008年7月10日
我在Run Nutch的時候出現這樣的錯誤 -
08/07/07 04:05:41 INFO conf.Configuration: found resource crawl-urlfilter.txt at file:/home/hut/installfiles/nutch-0.9/out/production/nutch-0.9/crawl-urlfilter.txt
08/07/07 04:05:41 INFO conf.Configuration: found resource parse-plugins.xml at file:/home/hut/installfiles/nutch-0.9/out/production/nutch-0.9/parse-plugins.xml
08/07/07 04:05:41 INFO fetcher.Fetcher: fetching http://www.yale.edu/
08/07/07 04:05:41 INFO fetcher.Fetcher: fetching http://www.harvard.edu/
08/07/07 04:05:41 INFO fetcher.Fetcher: fetch of http://www.harvard.edu/ failed with: org.apache.nutch.protocol.ProtocolNotFound: protocol not found for url=http
08/07/07 04:05:41 INFO fetcher.Fetcher: fetch of http://www.yale.edu/ failed with: org.apache.nutch.protocol.ProtocolNotFound: protocol not found for url=http
解決方法:nutch-site.xml
<property>
<name>plugin.includes</name>
<value>
nutch-extensionpoints|protocol-http|urlfilter-regex|parse-(text|html|js)|index-basic|query-(basic|site|url)|summary-basic|scoring-opic|urlnormalizer-(pass|regex|basic)
</value>
<description>Regular expression naming plugin directory names to
include. Any plugin not matching this expression is excluded.
In any case you need at least include the nutch-extensionpoints plugin. By
default Nutch includes crawling just HTML and plain text via HTTP,
and basic indexing and search plugins. In order to use HTTPS please enable
protocol-httpclient, but be aware of possible intermittent problems with the
underlying commons-httpclient library.
</description>
</property>
nutch-extensionpoints|被我錯誤的刪除了,還原以后一切工作正常. 默認情況下nutch0.9的目錄結構中并沒有plugin.includes這個properties, 它會載入nutch-default.xml里面的plugin.includes所以定義的所有的plugin. 在nutch-site.xml編輯/加入 plugin.includes properties的目的是為了加入我們自己的plugin而覆蓋nutch-default.xml定義的.
posted @
2008-07-10 11:38 自己的小屋 閱讀(2335) |
評論 (0) |
編輯 收藏
Nutch0.9 Crawl在Run的時候,有時候會出現 -
java.lang.ArrayIndexOutOfBoundsException: -1
at org.apache.lucene.index.MultiReader.isDeleted(MultiReader.java:113)
at org.apache.nutch.indexer.DeleteDuplicates$InputFormat$DDRecordReader.next(DeleteDuplicates.java:176)
at org.apache.hadoop.mapred.MapTask$1.next(MapTask.java:157)
at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:46)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:175)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:126)
Exception in thread "main" java.io.IOException: Job failed!
at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:604)
at org.apache.nutch.indexer.DeleteDuplicates.dedup(DeleteDuplicates.java:439)
at org.apache.nutch.crawl.Crawl.main(Crawl.java:135)
問題的解決方法:
https://issues.apache.org/jira/browse/NUTCH-525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515955
posted @
2008-07-10 11:32 自己的小屋 閱讀(611) |
評論 (0) |
編輯 收藏

2007年8月15日
那是2007年三月二日,我發了<
定位Java類中的每個方法在類文件中的位置>引起了幾個大蝦的注意并且給我指點,當時看了以后也沒有怎么弄,也不知道怎么弄.
這是cape給我的建議:
最直接的辦法應該是分析class的bytecode,找到每個Method_info->Code Attribute->LineNumberTable Attribute今天空閑得慌而是我拿這個method linenumber幾個keyword在網上狂搜了一把,
http://www.ibm.com/developerworks/cn/java/j-dyn0302/index.html
得到美文一篇,用Javassist來做. Javassist是一個專門操控java class的bytecode的類,可以動態的改變其狀態,我沒有深究它到底有多大的能耐,有興趣可以去它的官方網站看看,
http://www.csg.is.titech.ac.jp/~chiba/javassist/但是它確實可以象cape指點的那樣,讓我實現對java類中的每個方法的定位(得到類中的某個方法的lineRange)
而是我就隨便翻了幾個例子以后根據在線文檔寫了不到100行代碼輕松搞定。:) 我高興啊。
干這個事情的兩個java的source code可以從這里得到:
http://m.tkk7.com/Files/xmp123/MethodParser.zip
代碼很簡單,我就不解釋代碼了。
這是示例結果:
------------------------------------------------------------------------------------------------------------------------------
Analyzing net.blogjava.xmp123.MyMethodInfo ...
net.blogjava.xmp123.MyMethodInfo.getLineList() locate between 56 and 56
net.blogjava.xmp123.MyMethodInfo.updateLineList() locate between 63 and 80
net.blogjava.xmp123.MyMethodInfo.addLineToLineList(int) locate between 87 and 89
net.blogjava.xmp123.MyMethodInfo.setLineList(java.util.List) locate between 95 and 97
...
------------------------------------------------------------------------------------------------------------------------------
希望這東西有用......
posted @
2007-08-15 17:56 自己的小屋 閱讀(1138) |
評論 (0) |
編輯 收藏

2007年3月2日
應該說一般的數據庫都有BackUp的需求, MySql備份數據庫的方式很簡單, 但是在網上說得云里霧里, 也應該是我對MySql數據庫不熟悉.
?
目標(Target) : 將本機中的mysql數據庫備份到本機中的mydatabase數據庫中 - 也就是完全的Copy一個數據庫.
?
#1. C:\Program Files\MySQL\MySQL Server 5.0\bin>mysqldump -u root -p mysql>backup_database.sql
???
Enter password: ******** (你的root帳戶的密碼)
?
完成以后, 在路徑C:\Program Files\MySQL\MySQL Server 5.0\bin下面就有個backup_database.sql的數據庫文件產生,
?
#2. root登陸Mysql的Client, 建立目標數據庫mydatabase,
?
#3. C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p yourdatabase<backup_database.sql
????Enter password: ******** (你的root帳戶的密碼)
?
#4. Completed, (登陸到mysql的Client,用show tables命令檢查yourdatabase里面的結構和表是不是和mysql數據庫中的結構和表一模一樣.
?
Thanks,
?
-Wanglinghua
posted @
2007-03-02 09:07 自己的小屋 閱讀(9177) |
評論 (11) |
編輯 收藏

2006年10月24日
這東西比較有用:[轉載].出處:http://mike20049.spaces.live.com/mmm2006-09-13_01.00/
我收藏啦.:)
import java.io.*;
public class FileOperate {
? public FileOperate() {
? }
? /**
?? * 新建目錄
?? * @param folderPath String 如 c:/fqf
?? * @return boolean
?? */
? public void newFolder(String folderPath) {
??? try {
????? String filePath = folderPath;
????? filePath = filePath.toString();
????? java.io.File myFilePath = new java.io.File(filePath);
????? if (!myFilePath.exists()) {
??????? myFilePath.mkdir();
????? }
??? }
??? catch (Exception e) {
????? System.out.println("新建目錄操作出錯");
????? e.printStackTrace();
??? }
? }
? /**
?? * 新建文件
?? * @param filePathAndName String 文件路徑及名稱 如c:/fqf.txt
?? * @param fileContent String 文件內容
?? * @return boolean
?? */
? public void newFile(String filePathAndName, String fileContent) {
??? try {
????? String filePath = filePathAndName;
????? filePath = filePath.toString();
????? File myFilePath = new File(filePath);
????? if (!myFilePath.exists()) {
??????? myFilePath.createNewFile();
????? }
????? FileWriter resultFile = new FileWriter(myFilePath);
????? PrintWriter myFile = new PrintWriter(resultFile);
????? String strContent = fileContent;
????? myFile.println(strContent);
????? resultFile.close();
??? }
??? catch (Exception e) {
????? System.out.println("新建目錄操作出錯");
????? e.printStackTrace();
??? }
? }
? /**
?? * 刪除文件
?? * @param filePathAndName String 文件路徑及名稱 如c:/fqf.txt
?? * @param fileContent String
?? * @return boolean
?? */
? public void delFile(String filePathAndName) {
??? try {
????? String filePath = filePathAndName;
????? filePath = filePath.toString();
????? java.io.File myDelFile = new java.io.File(filePath);
????? myDelFile.delete();
??? }
??? catch (Exception e) {
????? System.out.println("刪除文件操作出錯");
????? e.printStackTrace();
??? }
? }
? /**
?? * 刪除文件夾
?? * @param filePathAndName String 文件夾路徑及名稱 如c:/fqf
?? * @param fileContent String
?? * @return boolean
?? */
? public void delFolder(String folderPath) {
??? try {
????? delAllFile(folderPath); //刪除完里面所有內容
????? String filePath = folderPath;
????? filePath = filePath.toString();
????? java.io.File myFilePath = new java.io.File(filePath);
????? myFilePath.delete(); //刪除空文件夾
??? }
??? catch (Exception e) {
????? System.out.println("刪除文件夾操作出錯");
????? e.printStackTrace();
??? }
? }
? /**
?? * 刪除文件夾里面的所有文件
?? * @param path String 文件夾路徑 如 c:/fqf
?? */
? public void delAllFile(String path) {
??? File file = new File(path);
??? if (!file.exists()) {
????? return;
??? }
??? if (!file.isDirectory()) {
????? return;
??? }
??? String[] tempList = file.list();
??? File temp = null;
??? for (int i = 0; i < tempList.length; i++) {
????? if (path.endsWith(File.separator)) {
??????? temp = new File(path + tempList[i]);
????? }
????? else {
??????? temp = new File(path + File.separator + tempList[i]);
????? }
????? if (temp.isFile()) {
??????? temp.delete();
????? }
????? if (temp.isDirectory()) {
??????? delAllFile(path+"/"+ tempList[i]);//先刪除文件夾里面的文件
??????? delFolder(path+"/"+ tempList[i]);//再刪除空文件夾
????? }
??? }
? }
? /**
?? * 復制單個文件
?? * @param oldPath String 原文件路徑 如:c:/fqf.txt
?? * @param newPath String 復制后路徑 如:f:/fqf.txt
?? * @return boolean
?? */
? public void copyFile(String oldPath, String newPath) {
??? try {
????? int bytesum = 0;
????? int byteread = 0;
????? File oldfile = new File(oldPath);
????? if (oldfile.exists()) { //文件存在時
??????? InputStream inStream = new FileInputStream(oldPath); //讀入原文件
??????? FileOutputStream fs = new FileOutputStream(newPath);
??????? byte[] buffer = new byte[1444];
??????? int length;
??????? while ( (byteread = inStream.read(buffer)) != -1) {
????????? bytesum += byteread; //字節數 文件大小
????????? System.out.println(bytesum);
????????? fs.write(buffer, 0, byteread);
??????? }
??????? inStream.close();
????? }
??? }
??? catch (Exception e) {
????? System.out.println("復制單個文件操作出錯");
????? e.printStackTrace();
??? }
? }
? /**
?? * 復制整個文件夾內容
?? * @param oldPath String 原文件路徑 如:c:/fqf
?? * @param newPath String 復制后路徑 如:f:/fqf/ff
?? * @return boolean
?? */
? public void copyFolder(String oldPath, String newPath) {
??? try {
????? (new File(newPath)).mkdirs(); //如果文件夾不存在 則建立新文件夾
????? File a=new File(oldPath);
????? String[] file=a.list();
????? File temp=null;
????? for (int i = 0; i < file.length; i++) {
??????? if(oldPath.endsWith(File.separator)){
????????? temp=new File(oldPath+file[i]);
??????? }
??????? else{
????????? temp=new File(oldPath+File.separator+file[i]);
??????? }
??????? if(temp.isFile()){
????????? FileInputStream input = new FileInputStream(temp);
????????? FileOutputStream output = new FileOutputStream(newPath + "/" +
????????????? (temp.getName()).toString());
????????? byte[] b = new byte[1024 * 5];
????????? int len;
????????? while ( (len = input.read(b)) != -1) {
??????????? output.write(b, 0, len);
????????? }
????????? output.flush();
????????? output.close();
????????? input.close();
??????? }
??????? if(temp.isDirectory()){//如果是子文件夾
????????? copyFolder(oldPath+"/"+file[i],newPath+"/"+file[i]);
??????? }
????? }
??? }
??? catch (Exception e) {
????? System.out.println("復制整個文件夾內容操作出錯");
????? e.printStackTrace();
??? }
? }
? /**
?? * 移動文件到指定目錄
?? * @param oldPath String 如:c:/fqf.txt
?? * @param newPath String 如:d:/fqf.txt
?? */
? public void moveFile(String oldPath, String newPath) {
??? copyFile(oldPath, newPath);
??? delFile(oldPath);
? }
? /**
?? * 移動文件到指定目錄
?? * @param oldPath String 如:c:/fqf.txt
?? * @param newPath String 如:d:/fqf.txt
?? */
? public void moveFolder(String oldPath, String newPath) {
??? copyFolder(oldPath, newPath);
??? delFolder(oldPath);
? }
}
posted @
2006-10-24 11:02 自己的小屋 閱讀(873) |
評論 (0) |
編輯 收藏

2006年9月30日
經過幾天的奮戰,終于有點成果。但是的確是傷了不少腦筋。
Mission: 檢測出java類中的所有的方法,以及這些方法在文件位于哪兩行之間.
碰到的問題:
1. 對付重載函數。
2. 如果一個方法占多行。
怎么解決:
1.利用反射得到他們所有的參數,但是某一行是不是含有所有的這樣的參數。
2.根據{來判斷,如果讀到的當前行包含方法的聲明,但是不包含{,那么此時就要保存好當前Readline讀取的內容,然后可以用StringBuffer append一下,在下一個Readline再做比較。
不支持:
比如
public static void main(String[] args)和? // 不支持。因為判斷的時候,前面是作為一個整體來判斷的。
public static? void main(String[] args),
當然這點我們完全可以實現。:)
敢興趣的朋友可以和我聯系:
hut@hf.webex.com
posted @
2006-09-30 17:12 自己的小屋 閱讀(818) |
評論 (0) |
編輯 收藏