narendly commented on a change in pull request #1208: URL: https://github.com/apache/helix/pull/1208#discussion_r464768369
########## File path: helix-core/src/main/java/org/apache/helix/task/DynamicTaskConfig.java ########## @@ -0,0 +1,115 @@ +package org.apache.helix.task; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.helix.zookeeper.datamodel.ZNRecord; + +/** + * A wrapper class for ZNRecord, used to store configs for tasks that are to be dynamically loaded + */ +public class DynamicTaskConfig { + private final ZNRecord _taskConfig; + + /** + * Initialize task config with an existing ZNRecord + * @param taskConfig + */ + public DynamicTaskConfig(ZNRecord taskConfig) { + _taskConfig = taskConfig; + } + + /** + * Initialize task config with parameters + * @param id + * @param jarFilePath path of the JAR file containing the task + * @param taskVersion task version + * @param taskClassesFqns list of the {@link Task} classes fully qualified names + * @param taskFactoryFqn {@link TaskFactory} class fully qualified name + */ + public DynamicTaskConfig(String id, String jarFilePath, String taskVersion, List<String> taskClassesFqns, + String taskFactoryFqn) { + _taskConfig = new ZNRecord(id); + _taskConfig.setSimpleField(TaskConstants.TASK_JAR_FILE_KEY, jarFilePath); + _taskConfig.setSimpleField(TaskConstants.TASK_VERSION_KEY, taskVersion); + _taskConfig.setListField(TaskConstants.TASK_CLASSES_KEY, taskClassesFqns); + _taskConfig.setSimpleField(TaskConstants.TASK_FACTORY_KEY, taskFactoryFqn); + } + + /** + * Get the task config ZNRecord + * @return + */ + public ZNRecord getTaskConfig() { + return _taskConfig; + } + + /** + * Get the address of the JAR file containing the task + * @return + */ + public String getJarFilePath() { + return _taskConfig.getSimpleField(TaskConstants.TASK_JAR_FILE_KEY); + } + + /** + * Get the task version + * @return + */ + public String getTaskVersion() { + return _taskConfig.getSimpleField(TaskConstants.TASK_VERSION_KEY); + } + + /** + * Get the list of the {@link Task} classes fully qualified names + * @return + */ + public List<String> getTaskClassesFqns() { + return _taskConfig.getListField(TaskConstants.TASK_CLASSES_KEY); + } + + /** + * Get the {@link TaskFactory} class fully qualified name + * @return + */ + public String getTaskFactoryFqn() { + return _taskConfig.getSimpleField(TaskConstants.TASK_FACTORY_KEY); Review comment: Since we have a TaskFactory - Task Class mapping, do we want a map here instead of two separate lists? How do we match them up otherwise? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
