Changes between Version 22 and Version 23 of LogParser


Ignore:
Timestamp:
Jul 8, 2008, 10:25:42 AM (16 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LogParser

    v22 v23  
    5050}}}
    5151!LogParserGo共宣告了以下幾個全域變數及方法:
    52  1. Item 1
    53    a. Item 1.a
    54    a. Item 1.b
    55       i. Item 1.b.i
    56       i. Item 1.b.ii
    57  1. Item 2
    58 And numbered lists can also be given an explicit number:
    59  3. Item 3
     52
    6053 1. HBaseConfiguration conf為重要的控制設定參數,其定義了很多方法可以設定或取得map reduce程式運作所需要的值
    6154 2. 定義 TABLE 為 "table.name",table.name為 name property
    62  3. String !tableName 為資料表名稱
     55 3. String tableName 為資料表名稱
    6356 4. Htable table 在定義一個HBase的操作變數
    6457 5. class !MapClass 為實做map的一個內部類別
    65  6. Path[] !listPaths 是個可以列出指定路徑下的檔案和目錄,原本0.16 API即宣告 Deprecated,因此為了解決warning在此實做
    66  7. void !runMapReduce(String table, String dir) 跑MapReduce的程序
    67  8. void !creatTable(String table)  建立hbase的資料表
     58 6. Path[] listPaths 是個可以列出指定路徑下的檔案和目錄,原本0.16 API即宣告 Deprecated,因此為了解決warning在此實做
     59 7. void runMapReduce(String table, String dir) 跑!MapReduce的程序
     60 8. void creatTable(String table)  建立hbase的資料表
    6861 9. void main(String[] args)  main 函數
    6962
     
    7265
    7366{{{
     67#!java
    7468        public static void main(String[] args) throws IOException {
    7569                String table_name = "apache-log2";
     
    8276
    8377首先看到main函數究竟搞了些什麼?[[br]][[br]]
    84 宣告了table的名稱,要parser的檔案放在'''hdfs'''當中的哪個路徑下,注意此路徑為hdfs,若給的是local file system的路徑的話,程式跑的時候會產生!NullPointer Exception的錯誤。然後呼叫!creatTable函數其功能用來創建table,接著跑!runMapReduce函數,而整個程式主體就是在!runMapReduce
     78宣告了table的名稱,要parser的檔案放在'''hdfs'''當中的哪個路徑下,注意此路徑為hdfs,若給的是local file system的路徑的話,程式跑的時候會產生!NullPointer Exception的錯誤。然後呼叫creatTable函數其功能用來創建table,接著跑runMapReduce函數,而整個程式主體就是在runMapReduce
    8579
    8680------------------------------------
    8781{{{
     82#!java
    8883        public static class MapClass extends MapReduceBase implements
    8984                        Mapper<WritableComparable, Text, Text, Writable> {
     
    140135------------------------------
    141136{{{
     137#!java
    142138        static public Path[] listPaths(FileSystem fsm, Path path)
    143139                        throws IOException {
     
    153149
    154150{{{
     151#!java
    155152        public static void runMapReduce(String table, String dir)
    156153                        throws IOException {
     
    191188
    192189{{{
     190#!java
    193191        public static void creatTable(String table) throws IOException {
    194192                HBaseAdmin admin = new HBaseAdmin(conf);
     
    214212
    215213{{{
     214#!java
    216215  private String ip;
    217216  private String protocol;
     
    243242----------------------------
    244243{{{
     244#!java
    245245  public LogParser(String line) throws ParseException, Exception{
    246246         Matcher matcher = p.matcher(line);
     
    271271
    272272{{{
     273#!java
    273274  public static boolean isIpAddress(String inputString) {
    274275    StringTokenizer tokenizer = new StringTokenizer(inputString, ".");