shounakmk219 commented on code in PR #13544:
URL: https://github.com/apache/pinot/pull/13544#discussion_r1697953415


##########
pinot-common/src/main/java/org/apache/pinot/common/metadata/ZKMetadataProvider.java:
##########
@@ -73,6 +79,87 @@ public static void 
setUserConfig(ZkHelixPropertyStore<ZNRecord> propertyStore, S
     propertyStore.set(constructPropertyStorePathForUserConfig(username), 
znRecord, AccessOption.PERSISTENT);
   }
 
+  /**
+   * Create database config, fail if exists.
+   *
+   * @return true if creation is successful.
+   */
+  public static boolean createDatabaseConfig(
+      ZkHelixPropertyStore<ZNRecord> propertyStore, DatabaseConfig 
databaseConfig) {
+    String databaseName = databaseConfig.getDatabaseName();
+    String databaseConfigPath = 
constructPropertyStorePathForDatabaseConfig(databaseName);
+    ZNRecord databaseConfigZNRecord;
+    try {
+      databaseConfigZNRecord = toZNRecord(databaseConfig);
+    } catch (Exception e) {
+      LOGGER.error("Caught exception constructing ZNRecord from database 
config for database: {}", databaseName, e);
+      return false;
+    }
+    return propertyStore.create(databaseConfigPath, databaseConfigZNRecord, 
AccessOption.PERSISTENT);
+  }
+
+  /**
+   * Update database config.
+   *
+   * @return true if update is successful.
+   */
+  public static boolean setDatabaseConfig(ZkHelixPropertyStore<ZNRecord> 
propertyStore, DatabaseConfig databaseConfig) {
+    String databaseName = databaseConfig.getDatabaseName();
+    ZNRecord databaseConfigZNRecord;
+    try {
+      databaseConfigZNRecord = toZNRecord(databaseConfig);
+    } catch (Exception e) {
+      LOGGER.error("Caught exception constructing ZNRecord from database 
config for database : {}", databaseName, e);
+      return false;
+    }
+    return 
propertyStore.set(constructPropertyStorePathForDatabaseConfig(databaseName), 
databaseConfigZNRecord,
+        -1, AccessOption.PERSISTENT);
+  }
+
+  /**
+   * Remove database config.
+   */
+  @VisibleForTesting
+  public static void removeDatabaseConfig(ZkHelixPropertyStore<ZNRecord> 
propertyStore, String databaseName) {
+    
propertyStore.remove(constructPropertyStorePathForDatabaseConfig(databaseName), 
AccessOption.PERSISTENT);
+  }
+
+  private static ZNRecord toZNRecord(DatabaseConfig databaseConfig) {

Review Comment:
   You are right, will remove it. 



-- 
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