MapReduce 是一個分布式運算程序的編程框架,是用戶開發(fā)基于 Hadoop 的數(shù)據(jù)分析應(yīng)用的核心框架。
十載的新晃網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整新晃建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)建站從事“新晃網(wǎng)站設(shè)計”,“新晃網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。
MapReduce 核心功能是將用戶編寫的業(yè)務(wù)邏輯代碼和自帶默認(rèn)組件整合成一個完整的分布式運算程序,并發(fā)運行在一個Hadoop 集群上。
優(yōu)點:
MapReduce 易于編程
它簡單的實現(xiàn)一些接口,就可以完成一個分布式程序,這個分布式程序可以分布到大量廉價的 PC 機器上運行,也就是說寫一個分布式程序,跟寫一個簡單的串行程序是一模一樣的,就是因為這個特點使得 MapReduce 編程變得非常流行。
良好的擴(kuò)展性
當(dāng)計算資源不能得到滿足的時候,可以通過簡單的增加機器來擴(kuò)展它的計算能力。
高容錯性
MapReduce 設(shè)計的初衷就是使程序能夠部署在廉價的 PC 機器上,這就要求它具有很高的容錯性,比如其中一臺機器掛了,它可以把上面的計算任務(wù)轉(zhuǎn)移到另外一個節(jié)點上運行,不至于這個任務(wù)運行失敗,而且這個過程不需要人工參與,而完全是由 Hadoop 內(nèi)部完成的。
適合 PB 級以上海量數(shù)據(jù)的離線處理
可以實現(xiàn)上千臺服務(wù)器集群并發(fā)工作,提供數(shù)據(jù)處理能力。
缺點:
不擅長實時計算
MapReduce 無法像 MySQL 一樣,在毫秒或者秒級內(nèi)返回結(jié)果。
不擅長流式計算
流式計算的輸入數(shù)據(jù)是動態(tài)的,而 MapReduce 的輸入數(shù)據(jù)集是靜態(tài)的,不能動態(tài)變化。這是因為 MapReduce 自身的設(shè)計特點決定了數(shù)據(jù)源必須是靜態(tài)的。
不擅長DAG(有向圖)計算
多個應(yīng)用程序存在依賴關(guān)系,后一個應(yīng)用程序的輸入為前一個的輸出,在這種情況下,MapReduce 并不是不能做,而是使用后,每個 MapReduce 作業(yè)的輸出結(jié)果都會寫入到磁盤,會造成大量的磁盤 IO,導(dǎo)致性能非常的低下。
分布式的運算程序往往需要分成至少 2 個階段。
第一個階段的 MapTask 并發(fā)實例,完全并行運行,互不相干。
第二個階段的 ReduceTask 并發(fā)實例互不相干,但是他們的數(shù)據(jù)依賴于上一個階段的所有 MapTask 并發(fā)實例的輸出。
MapReduce 編程模型只能包含一個 Map 階段和一個 Reduce 階段,如果用戶的業(yè)務(wù)邏輯非常復(fù)雜,那就只能多個MapReduce 程序,串行運行。
一個完整的 MapReduce 程序在分布式運行時有三類實例進(jìn)程:
MrAppMaster 負(fù)責(zé)整個程序的過程調(diào)度及狀態(tài)協(xié)調(diào)
MapTask 負(fù)責(zé) Map 階段的整個數(shù)據(jù)處理流程。
ReduceTask 負(fù)責(zé) Reduce 階段的整個數(shù)據(jù)處理流程。
Java 類型 | Hadoop Writable 類型 |
---|---|
Boolean | BooleanWritable |
Byte | ByteWritable |
Int | IntWritable |
Float | FloatWritable |
Long | LongWritable |
Double | DoubleWritable |
String | Text |
Map | MapWritable |
Array | ArrayWritable |
用戶編寫的程序分成三個部分:
Mapper 階段
Reduce 階段
Driver 階段
導(dǎo)入依賴
<dependencies>
<dependency>
<groupid>junit</groupid>
<artifactid>junit</artifactid>
<version>RELEASE</version>
</dependency>
<dependency>
<groupid>org.apache.logging.log4j</groupid>
<artifactid>log4j-core</artifactid>
<version>2.8.2</version>
</dependency>
<dependency>
<groupid>org.apache.hadoop</groupid>
<artifactid>hadoop-common</artifactid>
<version>2.7.2</version>
</dependency>
<dependency>
<groupid>org.apache.hadoop</groupid>
<artifactid>hadoop-client</artifactid>
<version>2.7.2</version>
</dependency>
<dependency>
<groupid>org.apache.hadoop</groupid>
<artifactid>hadoop-hdfs</artifactid>
<version>2.7.2</version>
</dependency>
<dependency>
<groupid>jdk.tools</groupid>
<artifactid>jdk.tools</artifactid>
<version>1.8</version>
<scope>system</scope>
<systempath>${JAVA_HOME}/lib/tools.jar</systempath>
</dependency>
</dependencies>
log4j.properties
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=target/spring.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
WcMapper
package com.djm.mapreduce;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class WcMapper extends Mapper<longwritable, text,text, intwritable> {
private Text key = new Text();
private IntWritable one = new IntWritable(1);
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
String[] words = line.split(" ");
for (String word : words) {
this.key.set(word);
context.write(this.key, this.one);
}
}
}
WcReduce
package com.djm.mapreduce;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
public class WcReduce extends Reducer<text, intwritable, text, intwritable> {
private IntWritable total = new IntWritable();
@Override
protected void reduce(Text key, Iterable<intwritable> values, Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable count : values) {
sum += 1;
}
this.total.set(sum);
context.write(key, this.total);
}
}
WcDriver
package com.djm.mapreduce;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class WcDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
// 獲得任務(wù)
Job job = Job.getInstance(new Configuration());
// 設(shè)置Classpath
job.setJarByClass(WcDriver.class);
// 設(shè)置Mapper
job.setMapperClass(WcMapper.class);
// 設(shè)置Reducer
job.setReducerClass(WcReduce.class);
// 設(shè)置Mapper的輸出key和value的類型
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);
// 設(shè)置Reducer的輸出key和value的類型
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
// 設(shè)置輸入和輸出路徑
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
Serializable 是一個重量級的 Java 序列框架,一個對象被序列化后,會產(chǎn)生很多額外的信息(各種校驗信息,Header,繼承體系等),會產(chǎn)生大量的 IO,所以不適合在網(wǎng)絡(luò)中高效的傳輸,所以,Hadoop 自己開發(fā)了一個輕量級的序列化框架(Writable)。
Hadoop序列化特點:
1、緊湊:高效使用存儲空間。
2、快速:讀寫數(shù)據(jù)的額外開銷小
3、可擴(kuò)展:隨著通信協(xié)議的升級而可升級。
4、 互操作:支持多語言的交互。
在開發(fā)過程中往往提供的基本序列化類型不能滿足要求,一般情況都需要創(chuàng)建一個 Bean 實現(xiàn) Writable 接口。
具體實現(xiàn) bean 對象序列化步驟如下 7 步:
1、實現(xiàn) Writable 接口
2、反序列化時,需要反射調(diào)用空參構(gòu)造函數(shù),必須提供空參構(gòu)造
3、重寫序列化方法
4、重寫反序列方法
5、反序列化和序列化的順序必須完全一致
6、要想把結(jié)果顯示在文件中,需要重寫 toString()
7、如果需要將自定義的 bean 放在 key 中傳輸,則還需要實現(xiàn) Comparable 接口,因為 MapReduce 框中的 Shuffle 過程要求對 key 必須能排序
統(tǒng)計每一個手機號耗費的總上行流量、下行流量、總流量
輸入數(shù)據(jù)格式:id 手機號碼 網(wǎng)絡(luò)ip 上行流量 下行流量 網(wǎng)絡(luò)狀態(tài)碼
輸出數(shù)據(jù)格式:手機號碼 上行流量 下行流量 總流量
FlowBean
package com.djm.mapreduce.flow;
import org.apache.hadoop.io.Writable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class FlowBean implements Writable {
private long upFlow;
private long downFlow;
private long sumFlow;
public FlowBean() {
}
public void set(long upFlow, long downFlow) {
this.upFlow = upFlow;
this.downFlow = downFlow;
this.sumFlow = this.upFlow + this.downFlow;
}
public long getUpFlow() {
return upFlow;
}
public void setUpFlow(long upFlow) {
this.upFlow = upFlow;
}
public long getDownFlow() {
return downFlow;
}
public void setDownFlow(long downFlow) {
this.downFlow = downFlow;
}
public long getSumFlow() {
return sumFlow;
}
public void setSumFlow(long sumFlow) {
this.sumFlow = sumFlow;
}
@Override
public String toString() {
return upFlow + "\t" + downFlow + "\t" + sumFlow;
}
public void write(DataOutput out) throws IOException {
out.writeLong(upFlow);
out.writeLong(downFlow);
out.writeLong(sumFlow);
}
public void readFields(DataInput in) throws IOException {
this.upFlow = in.readLong();
this.downFlow = in.readLong();
this.sumFlow = in.readLong();
}
}
FlowMapper
package com.djm.mapreduce.flow;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class FlowMapper extends Mapper<longwritable, text, flowbean> {
private FlowBean flowBean = new FlowBean();
private Text phone = new Text();
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
String[] words = line.split("\t");
phone.set(words[1]);
long upFlow = Long.parseLong(words[words.length - 3]);
long downFlow = Long.parseLong(words[words.length - 2]);
flowBean.set(upFlow, downFlow);
context.write(phone, flowBean);
}
}
FlowReduce
package com.djm.mapreduce.flow;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
public class FlowReduce extends Reducer<text, flowbean, text, flowbean> {
private FlowBean totalFlow = new FlowBean();
@Override
protected void reduce(Text key, Iterable<flowbean> values, Context context) throws IOException, InterruptedException {
long sumUpFlow = 0;
long sumDownFlow = 0;
for (FlowBean value : values) {
long upFlow = value.getUpFlow();
long downFlow = value.getDownFlow();
sumUpFlow += upFlow;
sumDownFlow += downFlow;
}
totalFlow.set(sumUpFlow, sumDownFlow);
context.write(key, totalFlow);
}
}
FlowDriver
package com.djm.mapreduce.flow;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class FlowDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(FlowDriver.class);
job.setMapperClass(FlowMapper.class);
job.setReducerClass(FlowReduce.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(FlowBean.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(FlowBean.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
一個 Job 的 Map 階段并行度由客戶端在提交 Job 時的切片數(shù)決定
每一個Split切片分配一個MapTask并行實例處理
默認(rèn)情況下,切片大小=BlockSize
切片時不考慮數(shù)據(jù)集整體,而是逐個針對每一個文件單獨切片
切片機制:
源碼中如何計算切片大小的?
如何自定義切片大???
CombineTextInputFormat 用于小文件過多的場景,它可以將多個小文件從邏輯上規(guī)劃到一個切片中,這樣,多個小文件就可以交給一個 MapTask 處理。
TextInputFormat:
TextInputForma 是默認(rèn)的 FileInputFormat 實現(xiàn)類,按行讀取每條記錄,鍵是存儲該行在整個文件中的起始字節(jié)偏移量,LongWritable 類型,值是這行的內(nèi)容,不包括任何行終止符(換行符和回車符),Text類型。
KeyValueTextInputFormat:
每一行均為一條記錄,被分隔符分割為 key,value,可以通過在驅(qū)動類中設(shè)置conf.set(KeyValueLineRecordReader.KEY_VALUE_SEPERATOR, "\t"); 來設(shè)定分隔符,默認(rèn)分隔符是 tab。
NLineInputFormat:
如果使用 NlineInputFormat,代表每個 map 進(jìn)程處理的 InputSplit 不再按 Block 塊去劃分,而是按 NlineInputFormat 指定的行數(shù)N來劃分,即輸入文件的總行數(shù) /N = 切片數(shù),如果不整除,切片數(shù) = 商 + 1。
無論 HDFS 還是 MapReduce,在處理小文件時效率都非常低,但又難免面臨處理大量小文件的場景,此時,就需要有相應(yīng)解決方案。可以自定義 InputFormat 實現(xiàn)小文件的合并。
程序?qū)崿F(xiàn):
WholeFileInputformat
package com.djm.mapreduce.inputformat;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import java.io.IOException;
public class WholeFileInputformat extends FileInputFormat<text, byteswritable> {
@Override
protected boolean isSplitable(JobContext context, Path filename) {
return false;
}
public RecordReader<text, byteswritable> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
return new WholeRecordReader();
}
}
WholeRecordReader
package com.djm.mapreduce.inputformat;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import java.io.IOException;
public class WholeRecordReader extends RecordReader<text, byteswritable> {
private boolean notRead = true;
private Text key = new Text();
private BytesWritable value = new BytesWritable();
private FSDataInputStream fis;
private FileSplit fs;
/**
* 初始化方法,框架會在開始的時候調(diào)用一次
* @param split
* @param context
* @throws IOException
* @throws InterruptedException
*/
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
// 轉(zhuǎn)換切換類型為文件切片
fs = (FileSplit) split;
// 通過切片獲取文件路徑
Path path = fs.getPath();
// 通過路徑獲取文件系統(tǒng)
FileSystem fileSystem = path.getFileSystem(context.getConfiguration());
// 開流
fis = fileSystem.open(path);
}
/**
* 讀取下一組KV
* @return
* @throws IOException
* @throws InterruptedException
*/
public boolean nextKeyValue() throws IOException, InterruptedException {
if (notRead) {
// 讀K
key.set(fs.getPath().toString());
// 讀V
byte[] buf = new byte[(int) fs.getLength()];
fis.read(buf);
value.set(buf, 0, buf.length);
notRead = false;
return true;
} else {
return false;
}
}
/**
* 獲取當(dāng)前讀到的key
* @return
* @throws IOException
* @throws InterruptedException
*/
public Text getCurrentKey() throws IOException, InterruptedException {
return this.key;
}
/**
* 獲取當(dāng)前讀到的value
* @return
* @throws IOException
* @throws InterruptedException
*/
public BytesWritable getCurrentValue() throws IOException, InterruptedException {
return this.value;
}
/**
* 當(dāng)前數(shù)據(jù)讀取的進(jìn)度
* @return
* @throws IOException
* @throws InterruptedException
*/
public float getProgress() throws IOException, InterruptedException {
return notRead ? 0 : 1;
}
/**
* 關(guān)閉資源
* @throws IOException
*/
public void close() throws IOException {
if (fis != null) {
fis.close();
}
}
}
WholeFileDriver
package com.djm.mapreduce.inputformat;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import java.io.IOException;
public class WholeFileDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(WholeFileDriver.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(BytesWritable.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(BytesWritable.class);
job.setInputFormatClass(WholeFileInputformat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean b = job.waitForCompletion(true);
System.exit(b ? 0 : 1);
}
}
上面的流程是整個 MapReduce 最全工作流程,但是 Shuffle 過程只是從第 7 步開始到第 16 步結(jié)束,具體 Shuffle 過程詳解,如下:
1)MapTask 收集我們的 map() 方法輸出的 KV 對,放到內(nèi)存緩沖區(qū)中
2)從內(nèi)存緩沖區(qū)不斷溢出本地磁盤文件,可能會溢出多個文件
3)多個溢出文件會被合并成大的溢出文件
4)在溢出過程及合并的過程中,都要調(diào)用 Partitioner 進(jìn)行分區(qū)和針對 key 進(jìn)行排序
5)ReduceTask 根據(jù)自己的分區(qū)號,去各個 MapTask 機器上取相應(yīng)的結(jié)果分區(qū)數(shù)據(jù)
6)ReduceTask 會取到同一個分區(qū)的來自不同 MapTask 的結(jié)果文件,ReduceTask 會將這些文件再進(jìn)行合并(歸并排序)
7)合并成大文件后,Shuffle 的過程也就結(jié)束了,后面進(jìn)入 ReduceTask 的邏輯運算過程(從文件中取出一個一個的鍵值對 Group,調(diào)用用戶自定義的 reduce() 方法)
分區(qū)可以將統(tǒng)計結(jié)果按照條件輸出到不同的文件中
默認(rèn) Partition 分區(qū):
public class HashPartitioner<k, v> extends Partitioner<k, v> {
public int getPartition(K key, V value, int numReduceTasks) {
return (key.hashCode() & Integer.MAX_VALUE) % numReduceTasks;
}
}
默認(rèn)分區(qū)是根據(jù) key 的 hashCode 對 ReduceTasks 個數(shù)取模決定的。
自定義 Partition 步驟:
public class CustomPartitioner extends Partitioner<text, flowbean> {
@Override
public int getPartition(Text key, FlowBean value, int numPartitions) {
// 控制分區(qū)代碼邏輯
return partition;
}
}
注意:
需求分析:
代碼實現(xiàn):
# ProvincePartitioner
package com.djm.mapreduce.partitioner;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;
public class ProvincePartitioner extends Partitioner<flowbean, text> {
@Override
public int getPartition(FlowBean flowBean, Text text, int numPartitions) {
switch (text.toString().substring(0, 3)) {
case "136":
return 0;
case "137":
return 1;
case "138":
return 2;
case "139":
return 3;
default:
return 4;
}
}
}
# PartitionerFlowDriver
package com.djm.mapreduce.partitioner;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class PartitionerFlowDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(PartitionerFlowDriver.class);
job.setMapperClass(SortMapper.class);
job.setReducerClass(SortReduce.class);
job.setMapOutputKeyClass(FlowBean.class);
job.setMapOutputValueClass(Text.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(FlowBean.class);
job.setPartitionerClass(ProvincePartitioner.class);
job.setNumReduceTasks(5);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
排序是 MapReduce 框架中最重要的操作之一,MapTask 和 ReduceTask 均會對數(shù)據(jù)按照 key 進(jìn)行排序,該操作屬于Hadoop 的默認(rèn)行為,任何應(yīng)用程序中的數(shù)據(jù)均會被排序,而不管邏輯上是否需要。
默認(rèn)排序是按照字典順序排序,且實現(xiàn)該排序的方法是快速排序:
對于 MapTask,它會將處理的結(jié)果暫時放到環(huán)形緩沖區(qū)中,當(dāng)環(huán)形緩沖區(qū)使用率達(dá)到一定閾值后,再對緩沖區(qū)中的數(shù)據(jù)進(jìn)行一次快速排序,并將這些有序數(shù)據(jù)溢寫到磁盤上,而當(dāng)數(shù)據(jù)處理完畢后,它會對磁盤上所有文件進(jìn)行歸并排序。
對于 ReduceTask,它從每個 MapTask 上遠(yuǎn)程拷貝相應(yīng)的數(shù)據(jù)文件,如果文件大小超過一定閾值,則溢寫磁盤上,否則存儲在內(nèi)存中,如果磁盤上文件數(shù)目達(dá)到一定閾值,則進(jìn)行一次歸并排序以生成一個更大文件,如果內(nèi)存中文件大小或者數(shù)目超過一定閾值,則進(jìn)行一次合并后將數(shù)據(jù)溢寫到磁盤上,當(dāng)所有數(shù)據(jù)拷貝完畢后,ReduceTask 統(tǒng)一對內(nèi)存和磁盤上的所有數(shù)據(jù)進(jìn)行一次歸并排序。
排序分類:
需求分析:
代碼實現(xiàn):
package com.djm.mapreduce.partitioner;
import org.apache.hadoop.io.WritableComparable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@Data
public class FlowBean implements WritableComparable<flowbean> {
private long upFlow;
private long downFlow;
private long sumFlow;
public void set(long upFlow, long downFlow) {
this.upFlow = upFlow;
this.downFlow = downFlow;
this.sumFlow = this.upFlow + this.downFlow;
}
public void write(DataOutput out) throws IOException {
out.writeLong(upFlow);
out.writeLong(downFlow);
out.writeLong(sumFlow);
}
public void readFields(DataInput in) throws IOException {
this.upFlow = in.readLong();
this.downFlow = in.readLong();
this.sumFlow = in.readLong();
}
@Override
public int compareTo(FlowBean o) {
return this.sumFlow > o.sumFlow ? -1:1;
}
}
對 Reduce 階段的數(shù)據(jù)根據(jù)某一個或幾個字段進(jìn)行分組。
分組排序步驟:
自定義類繼承WritableComparator
重寫compare()方法
創(chuàng)建一個構(gòu)造將比較對象的類傳給父類
protected OrderGroupingComparator() {
super(OrderBean.class, true);
}
需求分析:
代碼實現(xiàn):
# OrderBean
package com.djm.mapreduce.order;
import org.apache.hadoop.io.WritableComparable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@Data
public class OrderBean implements WritableComparable<orderbean> {
private String orderId;
private String productId;
private double price;
@Override
public int compareTo(OrderBean o) {
int compare = this.orderId.compareTo(o.orderId);
if (compare == 0) {
return Double.compare(o.price, this.price);
} else {
return compare;
}
}
@Override
public void write(DataOutput out) throws IOException {
out.writeUTF(orderId);
out.writeUTF(productId);
out.writeDouble(price);
}
@Override
public void readFields(DataInput in) throws IOException {
this.orderId = in.readUTF();
this.productId = in.readUTF();
this.price = in.readDouble();
}
}
# OrderSortGroupingComparator
package com.djm.mapreduce.order;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
public class OrderSortGroupingComparator extends WritableComparator {
public OrderSortGroupingComparator() {
super(OrderBean.class, true);
}
@Override
public int compare(WritableComparable a, WritableComparable b) {
OrderBean oa = (OrderBean) a;
OrderBean ob = (OrderBean) b;
return oa.getOrderId().compareTo(ob.getOrderId());
}
}
# OrderSortDriver
package com.djm.mapreduce.order;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class OrderSortDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(OrderSortDriver.class);
job.setMapperClass(OrderSortMapper.class);
job.setReducerClass(OrderSortReduce.class);
job.setMapOutputKeyClass(OrderBean.class);
job.setMapOutputValueClass(NullWritable.class);
job.setGroupingComparatorClass(OrderSortGroupingComparator.class);
job.setOutputKeyClass(OrderBean.class);
job.setOutputValueClass(NullWritable.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
1)Read 階段:MapTask 通過用戶編寫的 RecordReader,從輸入 InputSplit 中解析出一個個 key/value。
2)Map階段:該節(jié)點主要是將解析出的 key/value 交給用戶編寫 map() 函數(shù)處理,并產(chǎn)生一系列新的 key/value。
3)Collect 收集階段:在用戶編寫 map() 函數(shù)中,當(dāng)數(shù)據(jù)處理完成后,一般會調(diào)用 OutputCollector.collect() 輸出結(jié)果,在該函數(shù)內(nèi)部,它會將生成的 key/value 分區(qū)(調(diào)用Partitioner),并寫入一個環(huán)形內(nèi)存緩沖區(qū)中。
4)Spill 階段:即溢寫,當(dāng)環(huán)形緩沖區(qū)滿后,MapReduce 會將數(shù)據(jù)寫到本地磁盤上,生成一個臨時文件,需要注意的是,將數(shù)據(jù)寫入本地磁盤之前,先要對數(shù)據(jù)進(jìn)行一次本地排序,并在必要時對數(shù)據(jù)進(jìn)行合并、壓縮等操作。
5)Combine 階段:當(dāng)所有數(shù)據(jù)處理完成后,MapTask 對所有臨時文件進(jìn)行一次合并,以確保最終只會生成一個數(shù)據(jù)文件。
6)當(dāng)所有數(shù)據(jù)處理完后,MapTask 會將所有臨時文件合并成一個大文件,并保存到文件 output/file.out 中,同時生成相應(yīng)的索引文件 output/file.out.index。
7)在進(jìn)行文件合并過程中,MapTask 以分區(qū)為單位進(jìn)行合并,對于某個分區(qū),它將采用多輪遞歸合并的方式,每輪合并io.sort.factor(默認(rèn)10)個文件,并將產(chǎn)生的文件重新加入待合并列表中,對文件排序后,重復(fù)以上過程,直到最終得到一個大文件。
8)讓每個 MapTask 最終只生成一個數(shù)據(jù)文件,可避免同時打開大量文件和同時讀取大量小文件產(chǎn)生的隨機讀取帶來的開銷。
1)Copy 階段:ReduceTask 從各個 MapTask 上遠(yuǎn)程拷貝一片數(shù)據(jù),并針對某一片數(shù)據(jù),如果其大小超過一定閾值,則寫到磁盤上,否則直接放到內(nèi)存中。
2)Merge 階段:在遠(yuǎn)程拷貝數(shù)據(jù)的同時,ReduceTask 啟動了兩個后臺線程對內(nèi)存和磁盤上的文件進(jìn)行合并,以防止內(nèi)存使用過多或磁盤上文件過多。
3)Sort 階段:按照 MapReduce 語義,用戶編寫 reduce() 函數(shù)輸入數(shù)據(jù)是按 key 進(jìn)行聚集的一組數(shù)據(jù),為了將 key 相同的數(shù)據(jù)聚在一起,Hadoop 采用了基于排序的策略,由于各個 MapTask 已經(jīng)實現(xiàn)對自己的處理結(jié)果進(jìn)行了局部排序,因此,ReduceTask 只需對所有數(shù)據(jù)進(jìn)行一次歸并排序即可。
4)Reduce 階段:reduce() 函數(shù)將計算結(jié)果寫到 HDFS 上。
ReduceTask 的并行度同樣影響整個 Job 的執(zhí)行并發(fā)度和執(zhí)行效率,但與 MapTask 的并發(fā)數(shù)由切片數(shù)決定不同,ReduceTask 數(shù)量的決定是可以直接手動設(shè)置:
job.setNumReduceTasks(4);
注意事項:
需求分析:
代碼實現(xiàn):
# FilterOutputFormat
package com.djm.mapreduce.outputformat;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class FilterOutputFormat extends FileOutputFormat<text, nullwritable> {
@Override
public RecordWriter<text, nullwritable> getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException {
return new FilterRecordWriter(job);
}
}
# FilterRecordWriter
package com.djm.mapreduce.outputformat;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import java.io.IOException;
public class FilterRecordWriter extends RecordWriter<text, nullwritable> {
private FSDataOutputStream atguiguOut = null;
private FSDataOutputStream otherOut = null;
public FilterRecordWriter() {
}
public FilterRecordWriter(TaskAttemptContext job) {
FileSystem fs;
try {
fs = FileSystem.get(job.getConfiguration());
Path atguigu = new Path("C:\\Application\\Apache\\hadoop-2.7.2\\djm.log");
Path other = new Path("C:\\Application\\Apache\\hadoop-2.7.2\\other.log");
atguiguOut = fs.create(atguigu);
otherOut = fs.create(other);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void write(Text key, NullWritable value) throws IOException, InterruptedException {
if (key.toString().contains("atguigu")) {
atguiguOut.write(key.toString().getBytes());
} else {
otherOut.write(key.toString().getBytes());
}
}
@Override
public void close(TaskAttemptContext context) throws IOException, InterruptedException {
IOUtils.closeStream(atguiguOut);
IOUtils.closeStream(otherOut);
}
}
# FilterDriver
package com.djm.mapreduce.outputformat;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class FilterDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(FilterDriver.class);
job.setMapperClass(FilterMapper.class);
job.setReducerClass(FilterReduce.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(NullWritable.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
job.setOutputFormatClass(FilterOutputFormat.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
工作原理:
Map 端
為來自不同表或文件的 key/value 對,打標(biāo)簽以區(qū)別不同來源的記錄,然后用連接字段作為 key,其余部分和新加的標(biāo)志作為 value,最后進(jìn)行輸出。
Reduce端
在 Reduce 端以連接字段作為 key 的分組已經(jīng)完成,我們只需要在每一個分組當(dāng)中將那些來源于不同文件的記錄分開,最后進(jìn)行合并。
需求分析:
代碼實現(xiàn):
# TableBean
package com.djm.mapreduce.table;
import org.apache.hadoop.io.Writable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@Data
public class TableBean implements Writable {
private String orderId;
private String productId;
private int amount;
private String pname;
private String flag;
@Override
public void write(DataOutput out) throws IOException {
out.writeUTF(orderId);
out.writeUTF(productId);
out.writeInt(amount);
out.writeUTF(pname);
out.writeUTF(flag);
}
@Override
public void readFields(DataInput in) throws IOException {
this.orderId = in.readUTF();
this.productId = in.readUTF();
this.amount = in.readInt();
this.pname = in.readUTF();
this.flag = in.readUTF();
}
}
# TableMapper
package com.djm.mapreduce.table;
import java.io.IOException;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
public class TableMapper extends Mapper<longwritable, text, tablebean>{
String name;
TableBean bean = new TableBean();
Text k = new Text();
@Override
protected void setup(Context context) throws IOException, InterruptedException {
FileSplit split = (FileSplit) context.getInputSplit();
name = split.getPath().getName();
}
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
if (name.startsWith("order")) {// 訂單表處理
String[] fields = line.split("\t");
bean.setOrder_id(fields[0]);
bean.setP_id(fields[1]);
bean.setAmount(Integer.parseInt(fields[2]));
bean.setPname("");
bean.setFlag("order");
k.set(fields[1]);
}else {
String[] fields = line.split("\t");
bean.setP_id(fields[0]);
bean.setPname(fields[1]);
bean.setFlag("pd");
bean.setAmount(0);
bean.setOrder_id("");
k.set(fields[0]);
}
context.write(k, bean);
}
}
# TableReducer
package com.djm.mapreduce.table;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
public class TableReducer extends Reducer<text, tablebean, nullwritable> {
@Override
protected void reduce(Text key, Iterable<tablebean> values, Context context) throws IOException, InterruptedException {
ArrayList<tablebean> orderBeans = new ArrayList<>();
TableBean pdBean = new TableBean();
for (TableBean bean : values) {
if ("order".equals(bean.getFlag())) {
TableBean orderBean = new TableBean();
try {
BeanUtils.copyProperties(orderBean, bean);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
orderBeans.add(orderBean);
}
else {
try {
BeanUtils.copyProperties(pdBean, bean);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
}
for (TableBean bean :orderBeans) {
bean.setPname (pdBean.getPname());
context.write(bean, NullWritable.get());
}
}
}
package com.djm.mapreduce.table;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class TableDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException, URISyntaxException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(TableDriver.class);
job.setMapperClass(TableMapper.class);
job.setReducerClass(TableReducer.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(TableBean.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.addCacheFile(new URI("file:///C:/Application/Apache/hadoop-2.7.2/input/pd.txt"));
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
Map Join 適用于一張表十分小、一張表很大的場景。
優(yōu)點:
在 Map 端緩存多張表,提前處理業(yè)務(wù)邏輯,這樣增加 Map 端業(yè)務(wù),減少 Reduce 端數(shù)據(jù)的壓力,就可以盡可能的減少數(shù)據(jù)傾斜。
需求分析:
代碼實現(xiàn):
# TableMapper
package com.djm.mapreduce.table;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class TableMapper extends Mapper<longwritable, text, nullwritable> {
private Text k = new Text();
private Map<string, string> pdMap = new HashMap<>();
@Override
protected void setup(Context context) throws IOException, InterruptedException {
URI[] cacheFiles = context.getCacheFiles();
String path = cacheFiles[0].getPath();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8));
String line;
while(StringUtils.isNotEmpty(line = reader.readLine())){
String[] fields = line.split("\t");
pdMap.put(fields[0], fields[1]);
}
reader.close();
}
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String[] fields = value.toString().split("\t");
String pId = fields[1];
String pdName = pdMap.get(pId);
k.set(fields[0] + "\t"+ pdName + "\t" + fields[2]);
context.write(k, NullWritable.get());
}
}
# TableDriver
package com.djm.mapreduce.table;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class TableDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException, URISyntaxException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(TableDriver.class);
job.setMapperClass(TableMapper.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.addCacheFile(new URI("file:///C:/Application/Apache/hadoop-2.7.2/input/pd.txt"));
job.setNumReduceTasks(0);
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
在運行核心業(yè)務(wù) MapReduce 程序之前,往往要先對數(shù)據(jù)進(jìn)行清洗,清理掉不符合用戶要求的數(shù)據(jù)。清理的過程往往只需要運行 Mapper 程序,不需要運行 Reduce 程序。
需求分析:
需要在 Map 階段對輸入的數(shù)據(jù)根據(jù)規(guī)則進(jìn)行過濾清洗。
代碼實現(xiàn):
# LogBean
package com.djm.mapreduce.etl;
@Data
public class LogBean {
private String remoteAddr;
private String remoteUser;
private String timeLocal;
private String request;
private String status;
private String bodyBytesSent;
private String httpReferer;
private String httpUserAgent;
private boolean valid = true;
}
# LogMapper
package com.djm.mapreduce.etl;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class LogMapper extends Mapper<longwritable, text, nullwritable> {
private Text k = new Text();
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
LogBean bean = parseLog(line);
if (!bean.isValid()) {
return;
}
k.set(bean.toString());
context.write(k, NullWritable.get());
}
private LogBean parseLog(String line) {
LogBean logBean = new LogBean();
String[] fields = line.split(" ");
if (fields.length > 11) {
logBean.setRemoteAddr(fields[0]);
logBean.setRemoteUser(fields[1]);
logBean.setTimeLocal(fields[3].substring(1));
logBean.setRequest(fields[6]);
logBean.setStatus(fields[8]);
logBean.setBodyBytesSent(fields[9]);
logBean.setHttpReferer(fields[10]);
if (fields.length > 12) {
logBean.setHttpUserAgent(fields[11] + " " + fields[12]);
} else {
logBean.setHttpUserAgent(fields[11]);
}
if (Integer.parseInt(logBean.getStatus()) >= 400) {
logBean.setValid(false);
}
} else {
logBean.setValid(false);
}
return logBean;
}
}
# LogDriver
package com.djm.mapreduce.etl;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
public class LogDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Job job = Job.getInstance(new Configuration());
job.setJarByClass(LogDriver.class);
job.setMapperClass(LogMapper.class);
job.setNumReduceTasks(0);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.waitForCompletion(true);
}
}
在編寫 MapReduce 程序時,需要考慮如下幾個方面:
Mapper
Partitioner分區(qū)
有默認(rèn)實現(xiàn) HashPartitioner,邏輯是根據(jù) key 的哈希值和 numReduces 來返回一個分區(qū)號
key.hashCode()&Integer.MAXVALUE % numReduces
Comparable
Combiner
GroupingComparator
Reducer
OutputFormat
網(wǎng)站標(biāo)題:Hadoop之MapReduce
URL分享:http://jinyejixie.com/article16/igopdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、虛擬主機、商城網(wǎng)站、網(wǎng)站營銷、網(wǎng)站策劃、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)