以上是,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. 系统重装后phpnow修复

    最近在捣鼓wordpress,主题写了一半然后就重装了win8,在新系统里面访问127.0.0.1的时候出现无法访问的情况.主题写了一半,又不想重装wordpress导数据库这些繁琐的过程,于是,尝试 ...

  2. linux命令之chown命令

    发布:JB01   来源:脚本学堂     [大 中 小] 本文介绍下,linux系统中用于文件与目录权限管理的命令 chown命令的用法,chown将指定文件的拥有者改为指定的用户或组.有需要的朋友 ...

  3. php不允许用户提交空表单(php空值判断)

    我们在设计提交空的评论时依然可以写入数据库,并在页面显示出来.这显然是不合理的,所以需要我们加入空值判断 可以修改代码,添加些判断: 复制代码代码如下:   if(empty($_POST['name ...

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

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

  5. whoosh使用笔记

    1. whoosh安装 pip install Whoosh 2. 添加索引 第一步:生成schema 第二步:根据schema生成index.index就是一个目录中的一堆文件  (针对某个目录,调 ...

  6. python从socket做个websocket的聊天室server

    下面的是server端:把IP改成自己的局域网IP: #coding:utf8 import socket,select import SocketServer import hashlib,base ...

  7. MOS管应用之放反接电路

    一.典型电路 1.电路1 说明: GND-IN 为电源接口的负极 GND 为内部电路的公共地 原理分析 正向接: VCC-IN通过R1.R2.MOS体二极管,最后回到GND-IN;然后GS电压升高,紧 ...

  8. OC中格式化输出符号

    定义 说明 %@ Objective-C object, printed as the string returned by descriptionWithLocale: if available, ...

  9. ms-on-input

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. 如何使用Github仓库创建网站

    官方文档:https://help.github.com/categories/github-pages-basics/ 1.创建一个仓库 2.额外建立一个gh-pages分支 3.添加CNAME文件 ...