hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sra...@apache.org
Subject svn commit: r1043117 - in /hadoop/common/trunk: CHANGES.txt src/test/core/org/apache/hadoop/fs/loadGenerator/DataGenerator.java src/test/core/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
Date Tue, 07 Dec 2010 16:32:18 GMT
Author: sradia
Date: Tue Dec  7 16:32:17 2010
New Revision: 1043117

URL: http://svn.apache.org/viewvc?rev=1043117&view=rev
Log:
HADOOP-7054 Change NN LoadGenerator to use FileContext APIs (Sanjay Radia)

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/DataGenerator.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1043117&r1=1043116&r2=1043117&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Tue Dec  7 16:32:17 2010
@@ -23,6 +23,9 @@ Trunk (unreleased changes)
     HADOOP-7049. TestReconfiguration should be junit v4.
     (Patrick Kling via eli)
 
+    HADOOP-7054 Change NN LoadGenerator to use FileContext APIs
+	(Sanjay Radia)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/DataGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/DataGenerator.java?rev=1043117&r1=1043116&r2=1043117&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/DataGenerator.java
(original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/DataGenerator.java
Tue Dec  7 16:32:17 2010
@@ -22,12 +22,15 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.util.EnumSet;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.CreateFlag;
 import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.Options.CreateOpts;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 
@@ -48,7 +51,7 @@ import org.apache.hadoop.util.ToolRunner
 public class DataGenerator extends Configured implements Tool {
   private File inDir = StructureGenerator.DEFAULT_STRUCTURE_DIRECTORY;
   private Path root = DEFAULT_ROOT;
-  private FileSystem fs;
+  private FileContext fc;
   final static private long BLOCK_SIZE = 10;
   final static private String USAGE = "java DataGenerator " +
   		"-inDir <inDir> " +
@@ -78,7 +81,7 @@ public class DataGenerator extends Confi
   /** Parse the command line arguments and initialize the data */
   private int init(String[] args) {
     try { // initialize file system handle
-      fs = FileSystem.get(getConf());
+      fc = FileContext.getFileContext(getConf());
     } catch (IOException ioe) {
       System.err.println("Can not initialize the file system: " + 
           ioe.getLocalizedMessage());
@@ -109,7 +112,7 @@ public class DataGenerator extends Confi
             StructureGenerator.DIR_STRUCTURE_FILE_NAME)));
     String line;
     while ((line=in.readLine()) != null) {
-      fs.mkdirs(new Path(root+line));
+      fc.mkdir(new Path(root+line), FileContext.DEFAULT_PERM, true);
     }
   }
 
@@ -137,10 +140,9 @@ public class DataGenerator extends Confi
    * a length of <code>fileSize</code>. The file is filled with character 'a'.
    */
   private void genFile(Path file, long fileSize) throws IOException {
-    FSDataOutputStream out = fs.create(file, true, 
-        getConf().getInt("io.file.buffer.size", 4096),
-        (short)getConf().getInt("dfs.replication", 3),
-        fs.getDefaultBlockSize());
+    FSDataOutputStream out = fc.create(file, EnumSet.of(CreateFlag.OVERWRITE),
+        CreateOpts.createParent(), CreateOpts.bufferSize(4096),
+        CreateOpts.repFac((short) 3));
     for(long i=0; i<fileSize; i++) {
       out.writeByte('a');
     }

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java?rev=1043117&r1=1043116&r2=1043117&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
(original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
Tue Dec  7 16:32:17 2010
@@ -26,16 +26,19 @@ import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.EnumSet;
 import java.util.Random;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.CreateFlag;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.Options.CreateOpts;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 
@@ -110,7 +113,7 @@ public class LoadGenerator extends Confi
   
   private volatile boolean shouldRun = true;
   private Path root = DataGenerator.DEFAULT_ROOT;
-  private FileSystem fs;
+  private FileContext fc;
   private int maxDelayBetweenOps = 0;
   private int numOfThreads = 200;
   private long [] durations = {0};
@@ -230,7 +233,7 @@ public class LoadGenerator extends Confi
     private void read() throws IOException {
       String fileName = files.get(r.nextInt(files.size()));
       long startTime = System.currentTimeMillis();
-      InputStream in = fs.open(new Path(fileName));
+      InputStream in = fc.open(new Path(fileName));
       executionTime[OPEN] += (System.currentTimeMillis()-startTime);
       totalNumOfOps[OPEN]++;
       while (in.read(buffer) != -1) {}
@@ -252,7 +255,7 @@ public class LoadGenerator extends Confi
       while ((fileSize = r.nextGaussian()+2)<=0) {}
       genFile(file, (long)(fileSize*BLOCK_SIZE));
       long startTime = System.currentTimeMillis();
-      fs.delete(file, true);
+      fc.delete(file, true);
       executionTime[DELETE] += (System.currentTimeMillis()-startTime);
       totalNumOfOps[DELETE]++;
     }
@@ -263,7 +266,7 @@ public class LoadGenerator extends Confi
     private void list() throws IOException {
       String dirName = dirs.get(r.nextInt(dirs.size()));
       long startTime = System.currentTimeMillis();
-      fs.listStatus(new Path(dirName));
+      fc.listStatus(new Path(dirName));
       executionTime[LIST] += (System.currentTimeMillis()-startTime);
       totalNumOfOps[LIST]++;
     }
@@ -352,7 +355,7 @@ public class LoadGenerator extends Confi
   /** Parse the command line arguments and initialize the data */
   private int init(String[] args) throws IOException {
     try {
-      fs = FileSystem.get(getConf());
+      fc = FileContext.getFileContext(getConf());
     } catch (IOException ioe) {
       System.err.println("Can not initialize the file system: " + 
           ioe.getLocalizedMessage());
@@ -546,7 +549,7 @@ public class LoadGenerator extends Confi
    * whose name starts with "_file_".
    */
   private void initFileDirTables(Path path) throws IOException {
-    FileStatus[] stats = fs.listStatus(path);
+    FileStatus[] stats = fc.util().listStatus(path);
 
     for (FileStatus stat : stats) {
       if (stat.isDirectory()) {
@@ -581,10 +584,9 @@ public class LoadGenerator extends Confi
    */
   private void genFile(Path file, long fileSize) throws IOException {
     long startTime = System.currentTimeMillis();
-    FSDataOutputStream out = fs.create(file, true, 
-        getConf().getInt("io.file.buffer.size", 4096),
-        (short)getConf().getInt("dfs.replication", 3),
-        fs.getDefaultBlockSize());
+    FSDataOutputStream out = fc.create(file, EnumSet.of(CreateFlag.OVERWRITE),
+        CreateOpts.createParent(), CreateOpts.bufferSize(4096),
+        CreateOpts.repFac((short) 3));
     executionTime[CREATE] += (System.currentTimeMillis()-startTime);
     totalNumOfOps[CREATE]++;
 



Mime
View raw message