abhishekbafna commented on code in PR #14844: URL: https://github.com/apache/pinot/pull/14844#discussion_r1983972436
########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotClusterConfigs.java: ########## @@ -168,4 +177,88 @@ public SuccessResponse deleteClusterConfig( throw new ControllerApplicationException(LOGGER, errStr, Response.Status.INTERNAL_SERVER_ERROR, e); } } + + @GET + @Path("/cluster/configs/groovy/staticAnalyzerConfig") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_GROOVY_STATIC_ANALYZER_CONFIG) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Get the configuration for Groovy Static analysis", + notes = "Get the configuration for Groovy static analysis") + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success"), + @ApiResponse(code = 500, message = "Internal server error") + }) + public String getGroovyStaticAnalysisConfig() + throws Exception { + HelixAdmin helixAdmin = _pinotHelixResourceManager.getHelixAdmin(); + HelixConfigScope configScope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER) + .forCluster(_pinotHelixResourceManager.getHelixClusterName()).build(); + Map<String, String> configs = helixAdmin.getConfig(configScope, GROOVY_STATIC_ANALYZER_CONFIG_LIST); + if (configs == null) { + return null; + } + + Map<String, GroovyStaticAnalyzerConfig> groovyStaticAnalyzerConfigMap = new HashMap<>(); + for (Map.Entry<String, String> entry : configs.entrySet()) { + groovyStaticAnalyzerConfigMap.put(entry.getKey(), GroovyStaticAnalyzerConfig.fromJson(entry.getValue())); + } + return JsonUtils.objectToString(groovyStaticAnalyzerConfigMap); + } + + @POST + @Path("/cluster/configs/groovy/staticAnalyzerConfig") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.UPDATE_GROOVY_STATIC_ANALYZER_CONFIG) + @Authenticate(AccessType.UPDATE) + @ApiOperation(value = "Update Groovy static analysis configuration") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success"), + @ApiResponse(code = 500, message = "Server error updating configuration") + }) + public SuccessResponse setGroovyStaticAnalysisConfig(String body) { + try { + JsonNode jsonNode = JsonUtils.stringToJsonNode(body); + Iterator<String> fieldNamesIterator = jsonNode.fieldNames(); + Map<String, String> properties = new TreeMap<>(); + while (fieldNamesIterator.hasNext()) { + String key = fieldNamesIterator.next(); + if (!GROOVY_STATIC_ANALYZER_CONFIG_LIST.contains(key)) { + throw new IOException(String.format("Invalid groovy static analysis config: %s. Valid configs are: %s", + key, GROOVY_STATIC_ANALYZER_CONFIG_LIST)); + } + JsonNode valueNode = jsonNode.get(key); Review Comment: Yes. It does work. Thank you. -- 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