隨筆-8  評論-31  文章-0  trackbacks-0
            2006年10月24日
          我在Run Nutch的時候出現(xiàn)這樣的錯誤 -

          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|被我錯誤的刪除了,還原以后一切工作正常. 默認(rèn)情況下nutch0.9的目錄結(jié)構(gòu)中并沒有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 自己的小屋 閱讀(2345) | 評論 (0)編輯 收藏
          Nutch0.9 Crawl在Run的時候,有時候會出現(xiàn) -


          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 自己的小屋 閱讀(621) | 評論 (0)編輯 收藏
          那是2007年三月二日,我發(fā)了<定位Java類中的每個方法在類文件中的位置>
          引起了幾個大蝦的注意并且給我指點(diǎn),當(dāng)時看了以后也沒有怎么弄,也不知道怎么弄.

          這是cape給我的建議:

          最直接的辦法應(yīng)該是分析class的bytecode,找到每個Method_info->Code Attribute->LineNumberTable Attribute

          今天空閑得慌而是我拿這個method linenumber幾個keyword在網(wǎng)上狂搜了一把,
          http://www.ibm.com/developerworks/cn/java/j-dyn0302/index.html

          得到美文一篇,用Javassist來做. Javassist是一個專門操控java class的bytecode的類,可以動態(tài)的改變其狀態(tài),我沒有深究它到底有多大的能耐,有興趣可以去它的官方網(wǎng)站看看,

          http://www.csg.is.titech.ac.jp/~chiba/javassist/

          但是它確實(shí)可以象cape指點(diǎn)的那樣,讓我實(shí)現(xiàn)對java類中的每個方法的定位(得到類中的某個方法的lineRange)

          而是我就隨便翻了幾個例子以后根據(jù)在線文檔寫了不到100行代碼輕松搞定。:) 我高興啊。

          干這個事情的兩個java的source code可以從這里得到:

          http://www.aygfsteel.com/Files/xmp123/MethodParser.zip

          代碼很簡單,我就不解釋代碼了。

          這是示例結(jié)果:
          ------------------------------------------------------------------------------------------------------------------------------
          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 自己的小屋 閱讀(1147) | 評論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2007-03-12 15:40 自己的小屋 閱讀(2271) | 評論 (9)編輯 收藏
          應(yīng)該說一般的數(shù)據(jù)庫都有BackUp的需求, MySql備份數(shù)據(jù)庫的方式很簡單, 但是在網(wǎng)上說得云里霧里, 也應(yīng)該是我對MySql數(shù)據(jù)庫不熟悉.
          ?
          目標(biāo)(Target) : 將本機(jī)中的mysql數(shù)據(jù)庫備份到本機(jī)中的mydatabase數(shù)據(jù)庫中 - 也就是完全的Copy一個數(shù)據(jù)庫.
          ?
          #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的數(shù)據(jù)庫文件產(chǎn)生,
          ?
          #2. root登陸Mysql的Client, 建立目標(biāo)數(shù)據(jù)庫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里面的結(jié)構(gòu)和表是不是和mysql數(shù)據(jù)庫中的結(jié)構(gòu)和表一模一樣.
          ?
          Thanks,
          ?
          -Wanglinghua
          posted @ 2007-03-02 09:07 自己的小屋 閱讀(9183) | 評論 (11)編輯 收藏

          這東西比較有用:[轉(zhuǎn)載].出處: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 文件內(nèi)容
          ?? * @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); //刪除完里面所有內(nèi)容
          ????? 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]);//再刪除空文件夾
          ????? }
          ??? }
          ? }

          ? /**
          ?? * 復(fù)制單個文件
          ?? * @param oldPath String 原文件路徑 如:c:/fqf.txt
          ?? * @param newPath String 復(fù)制后路徑 如: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; //字節(jié)數(shù) 文件大小
          ????????? System.out.println(bytesum);
          ????????? fs.write(buffer, 0, byteread);
          ??????? }
          ??????? inStream.close();
          ????? }
          ??? }
          ??? catch (Exception e) {
          ????? System.out.println("復(fù)制單個文件操作出錯");
          ????? e.printStackTrace();

          ??? }

          ? }

          ? /**
          ?? * 復(fù)制整個文件夾內(nèi)容
          ?? * @param oldPath String 原文件路徑 如:c:/fqf
          ?? * @param newPath String 復(fù)制后路徑 如: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("復(fù)制整個文件夾內(nèi)容操作出錯");
          ????? 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 自己的小屋 閱讀(885) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 根河市| 毕节市| 罗源县| 阳西县| 泰和县| 潜山县| 奉贤区| 上栗县| 宿州市| 沅陵县| 昔阳县| 广东省| 蒲江县| 灵武市| 梅河口市| 栾川县| 郸城县| 师宗县| 蕉岭县| 嘉兴市| 浠水县| 宁波市| 鄯善县| 定边县| 永丰县| 陇南市| 兴文县| 攀枝花市| 蛟河市| 略阳县| 泊头市| 昆山市| 马山县| 库车县| 吴旗县| 卢氏县| 洪洞县| 屯留县| 仪陇县| 吐鲁番市| 华容县|