In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Import java.io.ByteArrayOutputStream
Import java.io.FileInputStream
Import java.io.FileOutputStream
Import java.io.InputStream
Import java.net.URL
Import org.apache.hadoop.conf.Configuration
Import org.apache.hadoop.fs.FSDataInputStream
Import org.apache.hadoop.fs.FSDataOutputStream
Import org.apache.hadoop.fs.FileStatus
Import org.apache.hadoop.fs.FileSystem
Import org.apache.hadoop.fs.FileUtil
Import org.apache.hadoop.fs.FsUrlStreamHandlerFactory
Import org.apache.hadoop.fs.Path
Import org.apache.hadoop.io.IOUtils
Import org.junit.Test
Public class modify_replication {
@ Test
Public void modirepli () throws Exception {
/ / create configuration objects, which have a default loading order, starting from core-default.xml, and then to files in the src directory, which
/ / We have given
Configuration conf = new Configuration ()
/ / modify the block size of the current file
Conf.set ("dfs.blocksize", "20480")
/ / get the object of the distributed file system from the configuration file
FileSystem fs = FileSystem.get (conf)
/ / modifying the replication factor actually means that the number of copies of the new file is specified in the process of uploading new data by creating a new stream.
/ / the original number of copies of the file has been really modified.
FSDataOutputStream out = fs.create (new Path ("/ user/hadoop/data2/kaola-copy2.jpg"), (short) 2)
IOUtils.copyBytes (new FileInputStream ("E:/zhaopian.jpg"), out, 1024)
Out.close ()
}
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.