Forráskód Böngészése

YARN-9874.Remove unnecessary LevelDb write call in LeveldbConfigurationStore#confirmMutation (#4487)

Co-authored-by: Ashutosh Gupta <ashugpt@amazon.com>
Ashutosh Gupta 2 éve
szülő
commit
734b6f19ad

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/LeveldbConfigurationStore.java

@@ -204,8 +204,8 @@ public class LeveldbConfigurationStore extends YarnConfigurationStore {
   @Override
   @Override
   public void confirmMutation(LogMutation pendingMutation,
   public void confirmMutation(LogMutation pendingMutation,
       boolean isValid) {
       boolean isValid) {
-    WriteBatch updateBatch = db.createWriteBatch();
     if (isValid) {
     if (isValid) {
+      WriteBatch updateBatch = db.createWriteBatch();
       for (Map.Entry<String, String> changes :
       for (Map.Entry<String, String> changes :
           pendingMutation.getUpdates().entrySet()) {
           pendingMutation.getUpdates().entrySet()) {
         if (changes.getValue() == null || changes.getValue().isEmpty()) {
         if (changes.getValue() == null || changes.getValue().isEmpty()) {
@@ -215,8 +215,8 @@ public class LeveldbConfigurationStore extends YarnConfigurationStore {
         }
         }
       }
       }
       increaseConfigVersion();
       increaseConfigVersion();
+      db.write(updateBatch);
     }
     }
-    db.write(updateBatch);
   }
   }
 
 
   private byte[] serLogMutations(LinkedList<LogMutation> mutations) throws
   private byte[] serLogMutations(LinkedList<LogMutation> mutations) throws