hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r775407 - in /hadoop/core/trunk: ./ src/core/org/apache/hadoop/io/ src/hdfs/org/apache/hadoop/hdfs/ src/hdfs/org/apache/hadoop/hdfs/server/common/ src/hdfs/org/apache/hadoop/hdfs/server/datanode/ src/hdfs/org/apache/hadoop/hdfs/server/namen...
Date Sat, 16 May 2009 01:33:40 GMT
Author: rangadi
Date: Sat May 16 01:33:39 2009
New Revision: 775407

URL: http://svn.apache.org/viewvc?rev=775407&view=rev
Log:
HADOOP-5854. Fix a few "Inconsistent Synchronization" warnings in HDFS
(Raghu Angadi)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/UpgradeManager.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/UpgradeManagerNamenode.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Sat May 16 01:33:39 2009
@@ -358,6 +358,9 @@
 
     HADOOP-5838. Fix a few javac warnings in HDFS. (Raghu Angadi)
 
+    HADOOP-5854. Fix a few "Inconsistent Synchronization" warnings in HDFS.
+    (Raghu Angadi)
+
   OPTIMIZATIONS
 
     HADOOP-5595. NameNode does not need to run a replicator to choose a

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/io/SequenceFile.java Sat May 16 01:33:39
2009
@@ -2170,6 +2170,11 @@
       }
     }
 
+    /** disables sync. often invoked for tmp files */
+    synchronized void ignoreSync() {
+      sync = null;
+    }
+    
     /** Set the current byte position in the input file.
      *
      * <p>The position passed must be a position returned by {@link
@@ -3108,7 +3113,7 @@
                                      segmentLength, conf, false);
         
           //sometimes we ignore syncs especially for temp merge files
-          if (ignoreSync) reader.sync = null;
+          if (ignoreSync) reader.ignoreSync();
 
           if (reader.getKeyClass() != keyClass)
             throw new IOException("wrong key class: " + reader.getKeyClass() +

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java Sat May 16 01:33:39 2009
@@ -2087,7 +2087,8 @@
   ****************************************************************/
   class DFSOutputStream extends FSOutputSummer implements Syncable {
     private Socket s;
-    boolean closed = false;
+    // closed is accessed by different threads under different locks.
+    volatile boolean closed = false;
   
     private String src;
     private DataOutputStream blockStream;
@@ -2113,7 +2114,8 @@
     private volatile IOException lastException = null;
     private long artificialSlowdown = 0;
     private long lastFlushOffset = -1; // offset when flush was invoked
-    private boolean persistBlocks = false; // persist blocks on namenode
+    //volatile: written holding dataQueue and read holding DFSOutputStream 
+    private volatile boolean persistBlocks = false;//persist blocks on namenode
     private int recoveryErrorCount = 0; // number of times block recovery failed
     private int maxRecoveryErrorCount = 5; // try block recovery 5 times
     private volatile boolean appendChunk = false;   // appending to existing partial block

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/UpgradeManager.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/UpgradeManager.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/UpgradeManager.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/common/UpgradeManager.java Sat
May 16 01:33:39 2009
@@ -39,15 +39,15 @@
     return this.broadcastCommand;
   }
 
-  public boolean getUpgradeState() {
+  public synchronized boolean getUpgradeState() {
     return this.upgradeState;
   }
 
-  public int getUpgradeVersion(){
+  public synchronized int getUpgradeVersion(){
     return this.upgradeVersion;
   }
 
-  public void setUpgradeState(boolean uState, int uVersion) {
+  public synchronized void setUpgradeState(boolean uState, int uVersion) {
     this.upgradeState = uState;
     this.upgradeVersion = uVersion;
   }
@@ -57,13 +57,13 @@
                                             getUpgradeVersion(), getType());
   }
 
-  public short getUpgradeStatus() {
+  public synchronized short getUpgradeStatus() {
     if(currentUpgrades == null)
       return 100;
     return currentUpgrades.first().getUpgradeStatus();
   }
 
-  public boolean initializeUpgrade() throws IOException {
+  public synchronized boolean initializeUpgrade() throws IOException {
     currentUpgrades = getDistributedUpgrades();
     if(currentUpgrades == null) {
       // set new upgrade state
@@ -76,7 +76,7 @@
     return true;
   }
 
-  public boolean isUpgradeCompleted() {
+  public synchronized boolean isUpgradeCompleted() {
     if (currentUpgrades == null) {
       return true;
     }

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
(original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
Sat May 16 01:33:39 2009
@@ -509,23 +509,25 @@
    */
   private boolean assignInitialVerificationTimes() {
     int numBlocks = 1;
+    LogFileHandler log = null;
     synchronized (this) {
+      log = verificationLog;
       numBlocks = Math.max(blockMap.size(), 1);
     }
     
     //First udpates the last verification times from the log file.
     LogFileHandler.Reader logReader = null;
     try {
-      if (verificationLog != null) {
-        logReader = verificationLog.new Reader(false);
+      if (log != null) {
+        logReader = log.new Reader(false);
       }
     } catch (IOException e) {
       LOG.warn("Could not read previous verification times : " +
                StringUtils.stringifyException(e));
     }
     
-    if (verificationLog != null) {
-      verificationLog.updateCurNumLines();
+    if (log != null) {
+      log.updateCurNumLines();
     }
     
     try {

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java Sat
May 16 01:33:39 2009
@@ -47,7 +47,7 @@
 
   INodeDirectoryWithQuota rootDir;
   FSImage fsImage;  
-  private boolean ready = false;
+  private volatile boolean ready = false;
   // Metrics record
   private MetricsRecord directoryMetrics = null;
 

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Sat
May 16 01:33:39 2009
@@ -203,7 +203,7 @@
   // allow appending to hdfs files
   private boolean supportAppends = true;
 
-  private SafeModeInfo safeMode;  // safe mode information
+  private volatile SafeModeInfo safeMode;  // safe mode information
   private Host2NodesMap host2DataNodeMap = new Host2NodesMap();
     
   // datanode networktoplogy
@@ -3115,7 +3115,7 @@
     /**
      * Set manual safe mode.
      */
-    void setManual() {
+    synchronized void setManual() {
       extension = Integer.MAX_VALUE;
     }
 

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/UpgradeManagerNamenode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/UpgradeManagerNamenode.java?rev=775407&r1=775406&r2=775407&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/UpgradeManagerNamenode.java
(original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/UpgradeManagerNamenode.java
Sat May 16 01:33:39 2009
@@ -115,8 +115,8 @@
     namesystem.leaveSafeMode(false);
   }
 
-  UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action 
-                                                ) throws IOException {
+  synchronized UpgradeStatusReport distributedUpgradeProgress
+                                  (UpgradeAction action) throws IOException {
     boolean isFinalized = false;
     if(currentUpgrades == null) { // no upgrades are in progress
       FSImage fsimage = namesystem.getFSImage();



Mime
View raw message