以上是,weekend110的yarn的job提交流程源码分析的复习总结

下面呢,来讲weekend110的hadoop中的序列化机制

1363157985066      13726230503  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157995052      13826544101  5C-0E-8B-C7-F1-E0:CMCC       120.197.40.4                      4       0       264  0       200

1363157991076      13926435656  20-10-7A-28-CC-0A:CMCC       120.196.100.99                          2       4       132  1512         200

1363154400022      13926251106  5C-0E-8B-8B-B1-50:CMCC       120.197.40.4                      4       0       240  0       200

1363157993044      18211575961  94-71-AC-CD-E6-18:CMCC-EASY     120.196.100.99        iface.qiyi.com  视频网站         15         12     1527         2106         200

1363157995074      84138413         5C-0E-8B-8C-E8-20:7DaysInn 120.197.40.4   122.72.52.12            20     16     4116         1432         200

1363157993055      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

1363157995033      15920133257  5C-0E-8B-C7-BA-20:CMCC      120.197.40.4   sug.so.360.cn  信息安全         20     20     3156         2936         200

1363157983019      13719199419  68-A1-B7-03-07-B1:CMCC-EASY      120.196.100.82                          4       0       240  0       200

1363157984041      13660577991  5C-0E-8B-92-5C-20:CMCC-EASY      120.197.40.4   s19.cnzz.com  站点统计         24     9         6960         690  200

1363157973098      15013685858  5C-0E-8B-C7-F7-90:CMCC       120.197.40.4   rank.ie.sogou.com  搜索引擎         28     27         3659         3538         200

1363157986029      15989002119  E8-99-C4-4E-93-E0:CMCC-EASY      120.196.100.99        www.umeng.com    站点统计         3         3       1938         180  200

1363157992093      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          15     9       918  4938         200

1363157986041      13480253104  5C-0E-8B-C7-FC-80:CMCC-EASY      120.197.40.4                      3       3       180  180  200

1363157984040      13602846565  5C-0E-8B-8B-B6-00:CMCC       120.197.40.4   2052.flash2-http.qq.com         综合门户         15     12     1938         2910         200

1363157995093      13922314466  00-FD-07-A2-EC-BA:CMCC      120.196.100.82        img.qfc.cn                  12     12     3008         3720         200

1363157982040      13502468823  5C-0A-5B-6A-0B-D4:CMCC-EASY    120.196.100.99        y0.ifengimg.com      综合门户         57     102  7335         110349     200

1363157986072      18320173382  84-25-DB-4F-10-1A:CMCC-EASY      120.196.100.99        input.shouji.sogou.com   搜索引擎         21     18     9531         2412         200

1363157990043      13925057413  00-1F-64-E1-E6-9A:CMCC        120.196.100.55        t3.baidu.com   搜索引擎         69     63         11058       48243       200

1363157988072      13760778710  00-FD-07-A4-7B-08:CMCC       120.196.100.82                          2       2       120  120  200

1363157985066      13726238888  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157993055      13560436666  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

手机号码                        时间戳                     Ip            网站      上行流量   下行流量   总的流量 

LongWritable的源码

/**

* Licensed to the Apache Software Foundation (ASF) under one

* or more contributor license agreements.  See the NOTICE file

* distributed with this work for additional information

* regarding copyright ownership.  The ASF licenses this file

* to you under the Apache License, Version 2.0 (the

* "License"); you may not use this file except in compliance

* with the License.  You may obtain a copy of the License at

*

*     http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package org.apache.hadoop.io;

import java.io.DataInput;

import java.io.DataOutput;

import java.io.IOException;

import org.apache.hadoop.classification.InterfaceAudience;

import org.apache.hadoop.classification.InterfaceStability;

/** A WritableComparable for longs. */

@InterfaceAudience.Public

@InterfaceStability.Stable

public class LongWritable implements WritableComparable<LongWritable> {

private long value;

public LongWritable() {}

public LongWritable(long value) { set(value); }

/** Set the value of this LongWritable. */

public void set(long value) { this.value = value; }

/** Return the value of this LongWritable. */

public long get() { return value; }

@Override

public void readFields(DataInput in) throws IOException {

value = in.readLong();

}

@Override

public void write(DataOutput out) throws IOException {

out.writeLong(value);

}

/** Returns true iff <code>o</code> is a LongWritable with the same value. */

@Override

public boolean equals(Object o) {

if (!(o instanceof LongWritable))

return false;

LongWritable other = (LongWritable)o;

return this.value == other.value;

}

@Override

public int hashCode() {

return (int)value;

}

/** Compares two LongWritables. */

@Override

public int compareTo(LongWritable o) {

long thisValue = this.value;

long thatValue = o.value;

return (thisValue<thatValue ? -1 : (thisValue==thatValue ? 0 : 1));

}

@Override

public String toString() {

return Long.toString(value);

}

/** A Comparator optimized for LongWritable. */

public static class Comparator extends WritableComparator {

public Comparator() {

super(LongWritable.class);

}

@Override

public int compare(byte[] b1, int s1, int l1,

byte[] b2, int s2, int l2) {

long thisValue = readLong(b1, s1);

long thatValue = readLong(b2, s2);

return (thisValue<thatValue ? -1 : (thisValue==thatValue ? 0 : 1));

}

}

/** A decreasing Comparator optimized for LongWritable. */

public static class DecreasingComparator extends Comparator {

@Override

public int compare(WritableComparable a, WritableComparable b) {

return -super.compare(a, b);

}

@Override

public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

return -super.compare(b1, s1, l1, b2, s2, l2);

}

}

static {                                       // register default comparator

WritableComparator.define(LongWritable.class, new Comparator());

}

}

WritableComparable的源码

/**

* Licensed to the Apache Software Foundation (ASF) under one

* or more contributor license agreements.  See the NOTICE file

* distributed with this work for additional information

* regarding copyright ownership.  The ASF licenses this file

* to you under the Apache License, Version 2.0 (the

* "License"); you may not use this file except in compliance

* with the License.  You may obtain a copy of the License at

*

*     http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package org.apache.hadoop.io;

import org.apache.hadoop.classification.InterfaceAudience;

import org.apache.hadoop.classification.InterfaceStability;

/**

* A {@link Writable} which is also {@link Comparable}.

*

* <p><code>WritableComparable</code>s can be compared to each other, typically

* via <code>Comparator</code>s. Any type which is to be used as a

* <code>key</code> in the Hadoop Map-Reduce framework should implement this

* interface.</p>

*

* <p>Note that <code>hashCode()</code> is frequently used in Hadoop to partition

* keys. It's important that your implementation of hashCode() returns the same

* result across different instances of the JVM. Note also that the default

* <code>hashCode()</code> implementation in <code>Object</code> does <b>not</b>

* satisfy this property.</p>

*

* <p>Example:</p>

* <p><blockquote><pre>

*     public class MyWritableComparable implements WritableComparable<MyWritableComparable> {

*       // Some data

*       private int counter;

*       private long timestamp;

*

*       public void write(DataOutput out) throws IOException {

*         out.writeInt(counter);

*         out.writeLong(timestamp);

*       }

*

*       public void readFields(DataInput in) throws IOException {

*         counter = in.readInt();

*         timestamp = in.readLong();

*       }

*

*       public int compareTo(MyWritableComparable o) {

*         int thisValue = this.value;

*         int thatValue = o.value;

*         return (thisValue &lt; thatValue ? -1 : (thisValue==thatValue ? 0 : 1));

*       }

*

*       public int hashCode() {

*         final int prime = 31;

*         int result = 1;

*         result = prime * result + counter;

*         result = prime * result + (int) (timestamp ^ (timestamp &gt;&gt;&gt; 32));

*         return result

*       }

*     }

* </pre></blockquote></p>

*/

@InterfaceAudience.Public

@InterfaceStability.Stable

public interface WritableComparable<T> extends Writable, Comparable<T> {

}

这样可以减少网络带宽,所以,为什么hadoop用到自己的序列化机制。

以上是weekend110的hadoop中的序列化机制

//将对象数据序列化到数据流中

@Override

public void write(DataOutput out) throws IOException {

// TODO Auto-generated method stub

}

序列化里,是要把数据写出去

//从数据流中反序列出对象数据

@Override

public void readFields(DataInput in) throws IOException {

// TODO Auto-generated method stub

}

反序列化,是要读入数据。

至此,FlowBean.java代码已经写完。

1363157985066      13726230503  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157995052      13826544101  5C-0E-8B-C7-F1-E0:CMCC       120.197.40.4                      4       0       264  0       200

1363157991076        20-10-7A-28-CC-0A:CMCC       120.196.100.99                          2       4       132  1512         200

1363154400022      13926251106  5C-0E-8B-8B-B1-50:CMCC       120.197.40.4                      4       0       240  0       200

1363157993044        94-71-AC-CD-E6-18:CMCC-EASY     120.196.100.99        iface.qiyi.com  视频网站         15         12     1527         2106         200

1363157995074      84138413         5C-0E-8B-8C-E8-20:7DaysInn 120.197.40.4   122.72.52.12            20     16     4116         1432         200

1363157993055        C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

1363157995033      15920133257  5C-0E-8B-C7-BA-20:CMCC      120.197.40.4   sug.so.360.cn  信息安全         20     20     3156         2936         200

1363157983019      13719199419  68-A1-B7-03-07-B1:CMCC-EASY      120.196.100.82                          4       0       240  0       200

1363157984041      13660577991  5C-0E-8B-92-5C-20:CMCC-EASY      120.197.40.4   s19.cnzz.com  站点统计         24     9         6960         690  200

1363157973098      15013685858  5C-0E-8B-C7-F7-90:CMCC       120.197.40.4   rank.ie.sogou.com  搜索引擎         28     27         3659         3538         200

1363157986029      15989002119  E8-99-C4-4E-93-E0:CMCC-EASY      120.196.100.99        www.umeng.com    站点统计         3         3       1938         180  200

1363157992093      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          15     9       918  4938         200

1363157986041      13480253104  5C-0E-8B-C7-FC-80:CMCC-EASY      120.197.40.4                      3       3       180  180  200

1363157984040        5C-0E-8B-8B-B6-00:CMCC       120.197.40.4   2052.flash2-http.qq.com         综合门户         15     12     1938         2910         200

1363157995093      13922314466  00-FD-07-A2-EC-BA:CMCC      120.196.100.82        img.qfc.cn                  12     12     3008         3720         200

1363157982040      13502468823  5C-0A-5B-6A-0B-D4:CMCC-EASY    120.196.100.99        y0.ifengimg.com      综合门户         57     102  7335         110349     200

1363157986072        84-25-DB-4F-10-1A:CMCC-EASY      120.196.100.99        input.shouji.sogou.com   搜索引擎         21     18     9531         2412         200

1363157990043        00-1F-64-E1-E6-9A:CMCC        120.196.100.55        t3.baidu.com   搜索引擎         69     63         11058       48243       200

1363157988072      13760778710  00-FD-07-A4-7B-08:CMCC       120.196.100.82                          2       2       120  120  200

1363157985066      13726238888  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157993055      13560436666  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

1363157985066      13726230503  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157995052      13826544101  5C-0E-8B-C7-F1-E0:CMCC       120.197.40.4                      4       0       264  0       200

1363157991076      13926435656  20-10-7A-28-CC-0A:CMCC       120.196.100.99                          2       4       132  1512         200

1363154400022      13926251106  5C-0E-8B-8B-B1-50:CMCC       120.197.40.4                      4       0       240  0       200

1363157993044      18211575961  94-71-AC-CD-E6-18:CMCC-EASY     120.196.100.99        iface.qiyi.com  视频网站         15         12     1527         2106         200

1363157995074      84138413         5C-0E-8B-8C-E8-20:7DaysInn 120.197.40.4   122.72.52.12            20     16     4116         1432         200

1363157993055      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

1363157995033      15920133257  5C-0E-8B-C7-BA-20:CMCC      120.197.40.4   sug.so.360.cn  信息安全         20     20     3156         2936         200

1363157983019      13719199419  68-A1-B7-03-07-B1:CMCC-EASY      120.196.100.82                          4       0       240  0       200

1363157984041      13660577991  5C-0E-8B-92-5C-20:CMCC-EASY      120.197.40.4   s19.cnzz.com  站点统计         24     9         6960         690  200

1363157973098      15013685858  5C-0E-8B-C7-F7-90:CMCC       120.197.40.4   rank.ie.sogou.com  搜索引擎         28     27         3659         3538         200

1363157986029      15989002119  E8-99-C4-4E-93-E0:CMCC-EASY      120.196.100.99        www.umeng.com    站点统计         3         3       1938         180  200

1363157992093      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          15     9       918  4938         200

1363157986041      13480253104  5C-0E-8B-C7-FC-80:CMCC-EASY      120.197.40.4                      3       3       180  180  200

1363157984040      13602846565  5C-0E-8B-8B-B6-00:CMCC       120.197.40.4   2052.flash2-http.qq.com         综合门户         15     12     1938         2910         200

1363157995093      13922314466  00-FD-07-A2-EC-BA:CMCC      120.196.100.82        img.qfc.cn                  12     12              3720         200

1363157982040      13502468823  5C-0A-5B-6A-0B-D4:CMCC-EASY    120.196.100.99        y0.ifengimg.com      综合门户         57     102  7335         110349     200

1363157986072      18320173382  84-25-DB-4F-10-1A:CMCC-EASY      120.196.100.99        input.shouji.sogou.com   搜索引擎         21     18     9531         2412         200

1363157990043      13925057413  00-1F-64-E1-E6-9A:CMCC        120.196.100.55        t3.baidu.com   搜索引擎         69     63         11058       48243       200

1363157988072      13760778710  00-FD-07-A4-7B-08:CMCC       120.196.100.82                          2       2       120  120  200

1363157985066      13726238888  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27              24681       200

1363157993055      13560436666  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

1363157985066      13726230503  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157995052      13826544101  5C-0E-8B-C7-F1-E0:CMCC       120.197.40.4                      4       0       264  0       200

1363157991076      13926435656  20-10-7A-28-CC-0A:CMCC       120.196.100.99                          2       4       132  1512         200

1363154400022      13926251106  5C-0E-8B-8B-B1-50:CMCC       120.197.40.4                      4       0       240         200

1363157993044      18211575961  94-71-AC-CD-E6-18:CMCC-EASY     120.196.100.99        iface.qiyi.com  视频网站         15         12     1527         2106         200

1363157995074      84138413         5C-0E-8B-8C-E8-20:7DaysInn 120.197.40.4   122.72.52.12            20     16     4116         1432         200

1363157993055      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116         954  200

1363157995033      15920133257  5C-0E-8B-C7-BA-20:CMCC      120.197.40.4   sug.so.360.cn  信息安全         20     20     3156         2936         200

1363157983019      13719199419  68-A1-B7-03-07-B1:CMCC-EASY      120.196.100.82                          4       0       240         200

1363157984041      13660577991  5C-0E-8B-92-5C-20:CMCC-EASY      120.197.40.4   s19.cnzz.com  站点统计         24     9         6960         690  200

1363157973098      15013685858  5C-0E-8B-C7-F7-90:CMCC       120.197.40.4   rank.ie.sogou.com  搜索引擎         28     27         3659         3538         200

1363157986029      15989002119  E8-99-C4-4E-93-E0:CMCC-EASY      120.196.100.99        www.umeng.com    站点统计         3         3       1938         180  200

1363157992093      13560439658  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          15     9       918  4938         200

1363157986041      13480253104  5C-0E-8B-C7-FC-80:CMCC-EASY      120.197.40.4                      3       3       180  180  200

1363157984040      13602846565  5C-0E-8B-8B-B6-00:CMCC       120.197.40.4   2052.flash2-http.qq.com         综合门户         15     12     1938         2910         200

1363157995093      13922314466  00-FD-07-A2-EC-BA:CMCC      120.196.100.82        img.qfc.cn                  12     12     3008         3720         200

1363157982040      13502468823  5C-0A-5B-6A-0B-D4:CMCC-EASY    120.196.100.99        y0.ifengimg.com      综合门户         57     102  7335         110349     200

1363157986072      18320173382  84-25-DB-4F-10-1A:CMCC-EASY      120.196.100.99        input.shouji.sogou.com   搜索引擎         21     18     9531         2412         200

1363157990043      13925057413  00-1F-64-E1-E6-9A:CMCC        120.196.100.55        t3.baidu.com   搜索引擎         69     63         11058       48243       200

1363157988072      13760778710  00-FD-07-A4-7B-08:CMCC       120.196.100.82                          2       2       120  120  200

1363157985066      13726238888  00-FD-07-A4-72-B8:CMCC       120.196.100.82        i02.c.aliimg.com                24     27     2481         24681       200

1363157993055      13560436666  C4-17-FE-BA-DE-D9:CMCC      120.196.100.99                          18     15     1116           200

[hadoop@weekend110 ~]$ /home/hadoop/app/hadoop-2.4.1/bin/hadoop jar flow.jar cn.itcast.hadoop.mr.flowsum.FlowSumRunner /flow/data /flow/output

以上是weekend110的流量求和mr程序开发

1 weekend110的复习 + hadoop中的序列化机制 + 流量求和mr程序开发的更多相关文章

  1. 一脸懵逼学习Hadoop中的序列化机制——流量求和统计MapReduce的程序开发案例——流量求和统计排序

    一:序列化概念 序列化(Serialization)是指把结构化对象转化为字节流.反序列化(Deserialization)是序列化的逆过程.即把字节流转回结构化对象.Java序列化(java.io. ...

  2. hadoop中的序列化与Writable接口

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-writable-interface.html,转载请注明源地址. 简介 序列化和反序列化就是结构化对象 ...

  3. hadoop中的序列化

    此文已由作者肖凡授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 最近在学习hadoop,发现hadoop的序列化过程和jdk的序列化有很大的区别,下面就来说说这两者的区别都有 ...

  4. hadoop中的序列化与Writable类

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-writable-class.html,转载请注明源地址. hadoop中自带的org.apache.h ...

  5. 基于HBase Hadoop 分布式集群环境下的MapReduce程序开发

    HBase分布式集群环境搭建成功后,连续4.5天实验客户端Map/Reduce程序开发,这方面的代码网上多得是,写个测试代码非常容易,可是真正运行起来可说是历经挫折.下面就是我最终调通并让程序在集群上 ...

  6. Hadoop中的RPC机制

    1.  RPC——远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议.RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据.在OSI ...

  7. 微信小程序中的bindTap事件(微信小程序开发QQ群:604788754)

    bindTap对应的绑定事件, 第一个:wx.navigateTo wx.navigateTo({ url:"../content/content" }) 第二个:wx.redir ...

  8. Python中的序列化以及pickle和json模块介绍

    Python中的序列化指的是在程序运行期间,变量都是在内存中保存着的,如果我们想保留一些运行中的变量值,就可以使用序列化操作把变量内容从内存保存到磁盘中,在Python中这个操作叫pickling,等 ...

  9. 3 weekend110的shuffle机制 + mr程序的组件全貌

    前面,讲到了hadoop的序列化机制,mr程序开发,自定义排序,自定义分组. 有多少个reduce的并发任务数可以控制,但有多少个map的并发任务数还没 缓存,分组,排序,转发,这些都是mr的shuf ...

随机推荐

  1. ubuntu 下的 ftp (gftp)

    功能和 windows 下的 ftp 一样 gftp安装方法apt-get install gftp启动方法:gfpt

  2. YII2数据库操作出现类似Database Exception – yii\db\Exception SQLSTATE

    yii2安装后,连接数据库,必须要安装pdo_mysql扩展

  3. CentOS系统安全配置

    http://down.51cto.com/data/318797 http://www.centos.bz/2011/07/centos-system-security-configure/ htt ...

  4. 网络编程TCP/IP实现客户端与客户端聊天

    一.TCP/IP协议 既然是网络编程,涉及几个系统之间的交互,那么首先要考虑的是如何准确的定位到网络上的一台或几台主机,另一个是如何进行可靠高效的数据传输.这里就要使用到TCP/IP协议. TCP/I ...

  5. 开源搜索引擎Sphinx 中启动多个搜索进程的方法

    http://blog.163.com/yang_jianli/blog/static/1619900062010316504471/ 要在同一机器上启动多个sphinx搜索进程searchd,必须为 ...

  6. vs15

    vs15 preview5 离线安装包 vs15 preview5 离线安装包   1.介绍 vs15是微软打造的新一代IDE,全新的安装方式.官网介绍如下(https://blogs.msdn.mi ...

  7. 传感器- 加速计 - CoreMotion

    /** *  CoreMotion * */ #import "ViewController.h" #import <CoreMotion/CoreMotion.h> ...

  8. Linux下实现定时器Timer的几种方法

    http://blog.csdn.net/lxmky/article/details/7669296 第六章 IO复用:select和poll函数 http://www.cnblogs.com/4ti ...

  9. 深入浅出 - Android系统移植与平台开发(十)- Android编译系统与定制Android平台系统(瘋耔修改篇二)

    第四章.Android编译系统与定制Android平台系统 4.1Android编译系统 Android的源码由几十万个文件构成,这些文件之间有的相互依赖,有的又相互独立,它们按功能或类型又被放到不同 ...

  10. nginx+gunicorn

    wsgi接口,使用gunicorn作为server,想在外层加nginx. 配置了 proxy_pass   http://127.0.0.1:9008; 访问报301. 参考gunicorn 官网配 ...