close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": libsvn_fs-1.so.1: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Jul 8, 2008, 10:25:42 AM (17 years ago)
- Author:
-
waue
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
|
v22
|
v23
|
|
| 50 | 50 | }}} |
| 51 | 51 | !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 | |
| 60 | 53 | 1. HBaseConfiguration conf為重要的控制設定參數,其定義了很多方法可以設定或取得map reduce程式運作所需要的值 |
| 61 | 54 | 2. 定義 TABLE 為 "table.name",table.name為 name property |
| 62 | | 3. String !tableName 為資料表名稱 |
| | 55 | 3. String tableName 為資料表名稱 |
| 63 | 56 | 4. Htable table 在定義一個HBase的操作變數 |
| 64 | 57 | 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的資料表 |
| 68 | 61 | 9. void main(String[] args) main 函數 |
| 69 | 62 | |
| … |
… |
|
| 72 | 65 | |
| 73 | 66 | {{{ |
| | 67 | #!java |
| 74 | 68 | public static void main(String[] args) throws IOException { |
| 75 | 69 | String table_name = "apache-log2"; |
| … |
… |
|
| 82 | 76 | |
| 83 | 77 | 首先看到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 |
| 85 | 79 | |
| 86 | 80 | ------------------------------------ |
| 87 | 81 | {{{ |
| | 82 | #!java |
| 88 | 83 | public static class MapClass extends MapReduceBase implements |
| 89 | 84 | Mapper<WritableComparable, Text, Text, Writable> { |
| … |
… |
|
| 140 | 135 | ------------------------------ |
| 141 | 136 | {{{ |
| | 137 | #!java |
| 142 | 138 | static public Path[] listPaths(FileSystem fsm, Path path) |
| 143 | 139 | throws IOException { |
| … |
… |
|
| 153 | 149 | |
| 154 | 150 | {{{ |
| | 151 | #!java |
| 155 | 152 | public static void runMapReduce(String table, String dir) |
| 156 | 153 | throws IOException { |
| … |
… |
|
| 191 | 188 | |
| 192 | 189 | {{{ |
| | 190 | #!java |
| 193 | 191 | public static void creatTable(String table) throws IOException { |
| 194 | 192 | HBaseAdmin admin = new HBaseAdmin(conf); |
| … |
… |
|
| 214 | 212 | |
| 215 | 213 | {{{ |
| | 214 | #!java |
| 216 | 215 | private String ip; |
| 217 | 216 | private String protocol; |
| … |
… |
|
| 243 | 242 | ---------------------------- |
| 244 | 243 | {{{ |
| | 244 | #!java |
| 245 | 245 | public LogParser(String line) throws ParseException, Exception{ |
| 246 | 246 | Matcher matcher = p.matcher(line); |
| … |
… |
|
| 271 | 271 | |
| 272 | 272 | {{{ |
| | 273 | #!java |
| 273 | 274 | public static boolean isIpAddress(String inputString) { |
| 274 | 275 | StringTokenizer tokenizer = new StringTokenizer(inputString, "."); |