Changeset 48
- Timestamp:
- Sep 3, 2008, 3:01:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/hadoop-0.16/tw/org/nchc/code/SnortBase.java
r47 r48 1 /**1 /** 2 2 * Program: LogParserGo.java 3 3 * Editor: Waue Chen … … 80 80 81 81 // String ttl, tos, id, iplen, dgmlen; 82 83 String srcport, dstport,tmp; 82 83 String srcport, dstport, tmp; 84 84 85 public Log(String data) { 85 86 … … 98 99 this.dstport = this.tmp; 99 100 this.type = arr[13]; 100 // this.ttl = arr[14]; 101 // this.tos = arr[15]; 102 // this.id = arr[16]; 103 // this.iplen = arr[17]; 104 // this.dgmlen = arr[18]; 105 106 } 101 102 } 103 107 104 long timestamp; 108 105 109 110 String getIP(String str){ 106 String getIP(String str) { 111 107 String res; 112 108 int n = str.indexOf(":"); … … 136 132 public static final String TABLE = "table.name"; 137 133 138 static String tableName = " flex";134 static String tableName = "NewTable2"; 139 135 140 136 static HTable table = null; … … 169 165 if (table == null) 170 166 table = new HTable(conf, new Text(tableName)); 171 167 // 實驗三 168 169 String property_name = "name=" + log.alert_name + ";priority=" 170 + log.priority + ";class=" + log.class_type + ";dst_port=" 171 + log.dstport + ";type=" + log.type; 172 172 long lockId = table.startUpdate(new Text(log.destination)); 173 table.put(lockId, new Text("id:gid"), log.gid.getBytes()); 174 table.put(lockId, new Text("id:sid"), log.sid.getBytes()); 175 table.put(lockId, new Text("id:version"), log.version.getBytes()); 176 table.put(lockId, new Text("name:name"), log.alert_name.getBytes()); 177 table 178 .put(lockId, new Text("name:class"), log.class_type 179 .getBytes()); 180 table.put(lockId, new Text("id:priority"), log.priority 181 .getBytes()); 182 table.put(lockId, new Text("direction:soure"), log.source.getBytes()); 183 table.put(lockId, new Text("direction:srcport"), log.srcport.getBytes()); 184 table.put(lockId, new Text("direction:dstport"), log.dstport.getBytes()); 185 table.put(lockId, new Text("payload:type"), log.type.getBytes()); 186 // table.put(lockId, new Text("payload:ttl"), log.ttl.getBytes()); 187 // table.put(lockId, new Text("payload:tos"), log.tos.getBytes()); 188 // table.put(lockId, new Text("payload:id"), log.id.getBytes()); 189 // table.put(lockId, new Text("payload:iplen"), log.iplen 173 table.put(lockId, new Text("SourceSID:" + log.source + "(" 174 + log.sid+")"), property_name.getBytes()); 175 // 實驗二 176 // long lockId = table.startUpdate(new 177 // Text(log.destination+":"+log.sid)); 178 // String property_name = 179 // "priority="+log.priority+ 180 // ";class="+log.class_type+ 181 // ";snort_id="+log.sid; 182 // String property_source = 183 // log.source+":"+log.srcport+" => " 184 // +log.destination+":"+log.dstport; 185 // String property_payload = log.type; 186 // table.put(lockId, new Text("name:"+log.alert_name), 187 // property_name.getBytes()); 188 // table.put(lockId, new Text("from:"+log.source), 189 // property_source.getBytes()); 190 // table.put(lockId, new Text("payload:"+log.type), 191 // property_payload.getBytes()); 192 // 實驗一 193 // table.put(lockId, new Text("property:gen_id"), 194 // log.gid.getBytes()); 195 // table.put(lockId, new Text("property:name"), log.sid.getBytes()); 196 // table.put(lockId, new Text("id:version"), 197 // log.version.getBytes()); 198 // table.put(lockId, new Text("name:name"), 199 // log.alert_name.getBytes()); 200 // table 201 // .put(lockId, new Text("name:class"), log.class_type 190 202 // .getBytes()); 191 // table.put(lockId, new Text(" payload:dgmlen"), log.dgmlen203 // table.put(lockId, new Text("id:priority"), log.priority 192 204 // .getBytes()); 205 // table.put(lockId, new Text("direction:soure"), 206 // log.source.getBytes()); 207 // table.put(lockId, new Text("direction:destination"), 208 // log.destination.getBytes()); 209 // table.put(lockId, new Text("direction:srcport"), 210 // log.srcport.getBytes()); 211 // table.put(lockId, new Text("direction:dstport"), 212 // log.dstport.getBytes()); 213 // table.put(lockId, new Text("payload:type"), log.type.getBytes()); 214 193 215 table.commit(lockId, log.timestamp); 194 216 … … 260 282 + " table creating ... please wait"); 261 283 HTableDescriptor tableDesc = new HTableDescriptor(table); 262 tableDesc.addFamily(new HColumnDescriptor("id:")); 263 tableDesc.addFamily(new HColumnDescriptor("name:")); 264 tableDesc.addFamily(new HColumnDescriptor("direction:")); 265 tableDesc.addFamily(new HColumnDescriptor("payload:")); 284 // 實驗三 285 tableDesc.addFamily(new HColumnDescriptor("SourceSID:")); 286 // 實驗二 287 // tableDesc.addFamily(new HColumnDescriptor("name:")); 288 // tableDesc.addFamily(new HColumnDescriptor("from:")); 289 // tableDesc.addFamily(new HColumnDescriptor("payload:")); 266 290 admin.createTable(tableDesc); 267 291 } else { … … 281 305 */ 282 306 creatTable(tableName); 283 307 Long start_time = (new Date()).getTime(); 284 308 runMapReduce(tableName, path); 285 309 Long end_time = (new Date()).getTime(); 310 System.out.println(end_time - start_time); 286 311 } 287 312
Note: See TracChangeset
for help on using the changeset viewer.