28 lines
857 B
Java
28 lines
857 B
Java
|
package com.guwan.backend.config;
|
||
|
|
||
|
import org.apache.hadoop.fs.FileSystem;
|
||
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
import org.springframework.context.annotation.Bean;
|
||
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
||
|
@Configuration
|
||
|
public class HadoopConfig {
|
||
|
|
||
|
@Value("${hadoop.fs.defaultFS}")
|
||
|
private String fsDefaultFS;
|
||
|
|
||
|
@Value("${hadoop.username}")
|
||
|
private String username;
|
||
|
|
||
|
@Bean
|
||
|
public FileSystem fileSystem() throws Exception {
|
||
|
org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
|
||
|
conf.set("fs.defaultFS", fsDefaultFS);
|
||
|
// 设置副本数
|
||
|
conf.set("dfs.replication", "3");
|
||
|
// 设置块大小,适合大文件存储
|
||
|
conf.set("dfs.blocksize", "128m");
|
||
|
|
||
|
return FileSystem.get(conf);
|
||
|
}
|
||
|
}
|