随笔-8  评论-31  文章-0  trackbacks-0
  2006年10月24日
我在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 自己的小屋 阅读(2298) | 评论 (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 自己的小屋 阅读(585) | 评论 (0)编辑 收藏
那是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://www.blogjava.net/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 自己的小屋 阅读(1102) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2007-03-12 15:40 自己的小屋 阅读(2235) | 评论 (9)编辑 收藏
应该说一般的数据库都有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 自己的小屋 阅读(9138) | 评论 (11)编辑 收藏

这东西比较有用:[转载].出处: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 自己的小屋 阅读(848) | 评论 (0)编辑 收藏