以上是,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. [Leveldb源码剖析疑问]-block_builder.cc之Add函数

    Add函数是给一个Data block中添加对应的key和value,函数源码如下,其中有一处不理解: L30~L34是更新last_key_的,不理解这里干嘛不直接last_key_ = key.T ...

  2. (jQuery 插件)封装容器的表单为json对象

    下面代码可以把一个页面容器中的表单元素封装成一个json对象. (function($){ $.fn.serializeObject=function(){ var inputs=$(this).fi ...

  3. 【转】Oracle job procedure 存储过程定时任务

    原文:Oracle job procedure 存储过程定时任务 oracle job有定时执行的功能,可以在指定的时间点或每天的某个时间点自行执行任务. 一.查询系统中的job,可以查询视图 --相 ...

  4. rownum

    rownum是一个伪列,oracle数据库会对查找到的数据 从1 开始递增指定每行的rownum值, 当查询条件里有 rownum时(比如 where rownum>2),数据库会依次从数据集里 ...

  5. MySql 在大数量的统计中具体的使用技巧

    一.CASE WHEN THEN ELSE END 使用用法. 在用sql语句统计某字段的某种状态的出现的次数,可以考虑用到 CASE WHEN THEN ELSE END 使用用法.当数据量过于庞大 ...

  6. 服务器端启动soket多线程

    方法一: Socket socket=null try{ ServerSocket serversocket=nwe ServerSocket(8080) while(true){ socket=se ...

  7. MySQL字符串中数字排序的问题

    1.select * from table where 1   order by id*1 desc; 2.select * from table where 1 order by id+0 desc ...

  8. 基于ARM-LINUX的温度传感器驱动(DS18B20) .

    DS18B20数字温度传感器接线方便,封装成后可应用于多种场合,如管道式,螺纹式,磁铁吸附式,不锈钢封装式,型号多种多样,有LTM8877,LTM8874等等.主要根据应用场合的不同而改变其外观.封装 ...

  9. LeetCode【第217题】Contains Duplicate

    题目: ''' Given an array of integers, find if the array contains any duplicates. Your function should ...

  10. Python冒泡排序

    冒泡排序,顾名思义,按照一定的规则,把数据一直排下去 直接上代码 import random def bubblesort(data): for i in range(len(data)-1,1,-1 ...