Skip to content

Commit

Permalink
访问耗时统计,自定义传输对象,只能最后一个字段是字符串
Browse files Browse the repository at this point in the history
  • Loading branch information
lkfs committed Sep 28, 2020
1 parent c3752ce commit fd303a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/venusoft/duration/AccessDurationDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AccessDurationDriver {
public static class AccessDurationMapper extends Mapper<LongWritable, Text, Text, AccessInfoBean>{
private Map<String, AccessInfoBean> map = new HashMap<>();
private Pattern requestPattern = Pattern.compile("(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3})\\s*\\[(\\d*)\\].*path:\\[(.+?)\\],request :");
private Pattern responsePattern = Pattern.compile("(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3})\\s*\\[(\\d*)\\].*path:\\[(.+?)\\] took time:\\[(\\d)*ms\\],response :");
private Pattern responsePattern = Pattern.compile("(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3})\\s*\\[(\\d*)\\].*path:\\[(.+?)\\] took time:\\[(\\d*)ms\\],response :");

@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
Expand Down Expand Up @@ -85,7 +85,7 @@ protected void reduce(Text key, Iterable<AccessInfoBean> values, Context context
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

String inputPath = "hdfs://hadoop01:9000/input/";
String outputPath = "hdfs://hadoop01:9000/output1_1";
String outputPath = "hdfs://hadoop01:9000/output1_2";

Configuration conf = new Configuration();
Job job = Job.getInstance(conf);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/venusoft/duration/AccessResultBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public AccessResultBean(int count, int sum, double avg) {
this.avg = avg;
}

@Override
public String toString() {
return count + "\t" + sum + "\t" + avg;
}

@Override
public void write(DataOutput out) throws IOException {
Expand Down

0 comments on commit fd303a5

Please sign in to comment.