Jackie-Jiang commented on code in PR #11782:
URL: https://github.com/apache/pinot/pull/11782#discussion_r1359763830


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -1795,8 +1790,17 @@ public void updateTableConfig(TableConfig tableConfig)
    */
   public void setExistingTableConfig(TableConfig tableConfig)
       throws IOException {
+    setExistingTableConfig(tableConfig, -1);
+  }
+
+  /**
+   * Sets the given table config into zookeeper with the expected version, 
which is the previous tableConfig znRecord
+   * version. If the expected version is -1, the version check is ignored.
+   */
+  public void setExistingTableConfig(TableConfig tableConfig, int 
expectedVersion)
+      throws IOException {
     String tableNameWithType = tableConfig.getTableName();
-    ZKMetadataProvider.setTableConfig(_propertyStore, tableNameWithType, 
TableConfigUtils.toZNRecord(tableConfig));
+    ZKMetadataProvider.setTableConfig(_propertyStore, tableConfig, 
expectedVersion);

Review Comment:
   We should check the return value here and throw exception if it returns 
false.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -1819,35 +1823,41 @@ public void setExistingTableConfig(TableConfig 
tableConfig)
   public void updateMetadataConfigFor(String tableName, TableType type, 
TableCustomConfig newConfigs)
       throws Exception {
     String tableNameWithType = 
TableNameBuilder.forType(type).tableNameWithType(tableName);
-    TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType);
-    if (tableConfig == null) {
+    ImmutablePair<TableConfig, Integer> tableConfigWithVersion =
+        ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, 
tableNameWithType);
+    if (tableConfigWithVersion == null) {
       throw new RuntimeException("Table: " + tableName + " of type: " + type + 
" does not exist");
     }
+    TableConfig tableConfig = tableConfigWithVersion.getLeft();
     tableConfig.setCustomConfig(newConfigs);
-    setExistingTableConfig(tableConfig);
+    setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight());

Review Comment:
   Check return value and throw exception if it returns false



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -1819,35 +1823,41 @@ public void setExistingTableConfig(TableConfig 
tableConfig)
   public void updateMetadataConfigFor(String tableName, TableType type, 
TableCustomConfig newConfigs)
       throws Exception {
     String tableNameWithType = 
TableNameBuilder.forType(type).tableNameWithType(tableName);
-    TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType);
-    if (tableConfig == null) {
+    ImmutablePair<TableConfig, Integer> tableConfigWithVersion =
+        ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, 
tableNameWithType);
+    if (tableConfigWithVersion == null) {
       throw new RuntimeException("Table: " + tableName + " of type: " + type + 
" does not exist");
     }
+    TableConfig tableConfig = tableConfigWithVersion.getLeft();
     tableConfig.setCustomConfig(newConfigs);
-    setExistingTableConfig(tableConfig);
+    setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight());
   }
 
   public void updateSegmentsValidationAndRetentionConfigFor(String tableName, 
TableType type,
       SegmentsValidationAndRetentionConfig newConfigs)
       throws Exception {
     String tableNameWithType = 
TableNameBuilder.forType(type).tableNameWithType(tableName);
-    TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType);
-    if (tableConfig == null) {
+    ImmutablePair<TableConfig, Integer> tableConfigWithVersion =
+        ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, 
tableNameWithType);
+    if (tableConfigWithVersion == null) {
       throw new RuntimeException("Table: " + tableName + " of type: " + type + 
" does not exist");
     }
+    TableConfig tableConfig = tableConfigWithVersion.getLeft();
     tableConfig.setValidationConfig(newConfigs);
-    setExistingTableConfig(tableConfig);
+    setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight());
   }
 
   public void updateIndexingConfigFor(String tableName, TableType type, 
IndexingConfig newConfigs)
       throws Exception {
     String tableNameWithType = 
TableNameBuilder.forType(type).tableNameWithType(tableName);
-    TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType);
-    if (tableConfig == null) {
+    ImmutablePair<TableConfig, Integer> tableConfigWithVersion =
+        ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, 
tableNameWithType);
+    if (tableConfigWithVersion == null) {
       throw new RuntimeException("Table: " + tableName + " of type: " + type + 
" does not exist");
     }
+    TableConfig tableConfig = tableConfigWithVersion.getLeft();
     tableConfig.setIndexingConfig(newConfigs);
-    setExistingTableConfig(tableConfig);
+    setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight());

Review Comment:
   Check return value and throw exception if it returns false



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -1819,35 +1823,41 @@ public void setExistingTableConfig(TableConfig 
tableConfig)
   public void updateMetadataConfigFor(String tableName, TableType type, 
TableCustomConfig newConfigs)
       throws Exception {
     String tableNameWithType = 
TableNameBuilder.forType(type).tableNameWithType(tableName);
-    TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType);
-    if (tableConfig == null) {
+    ImmutablePair<TableConfig, Integer> tableConfigWithVersion =
+        ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, 
tableNameWithType);
+    if (tableConfigWithVersion == null) {
       throw new RuntimeException("Table: " + tableName + " of type: " + type + 
" does not exist");
     }
+    TableConfig tableConfig = tableConfigWithVersion.getLeft();
     tableConfig.setCustomConfig(newConfigs);
-    setExistingTableConfig(tableConfig);
+    setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight());
   }
 
   public void updateSegmentsValidationAndRetentionConfigFor(String tableName, 
TableType type,
       SegmentsValidationAndRetentionConfig newConfigs)
       throws Exception {
     String tableNameWithType = 
TableNameBuilder.forType(type).tableNameWithType(tableName);
-    TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType);
-    if (tableConfig == null) {
+    ImmutablePair<TableConfig, Integer> tableConfigWithVersion =
+        ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, 
tableNameWithType);
+    if (tableConfigWithVersion == null) {
       throw new RuntimeException("Table: " + tableName + " of type: " + type + 
" does not exist");
     }
+    TableConfig tableConfig = tableConfigWithVersion.getLeft();
     tableConfig.setValidationConfig(newConfigs);
-    setExistingTableConfig(tableConfig);
+    setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight());

Review Comment:
   Check return value and throw exception if it returns false



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to