rabashizade commented on a change in pull request #1208:
URL: https://github.com/apache/helix/pull/1208#discussion_r464574185



##########
File path: helix-core/src/main/java/org/apache/helix/task/DynamicTaskConfig.java
##########
@@ -0,0 +1,155 @@
+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 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 jarFile address of the JAR file containing the task
+   * @param taskVersion task version
+   * @param taskClasses list of the {@link Task} classes names
+   * @param taskFactory {@link TaskFactory} class name
+   */
+  public DynamicTaskConfig(String id, String jarFile, String taskVersion, 
List<String> taskClasses,
+      String taskFactory) {
+    _taskConfig = new ZNRecord(id);
+    _taskConfig.setSimpleField(TaskConstants.TASK_JAR_FILE_KEY, jarFile);
+    _taskConfig.setSimpleField(TaskConstants.TASK_VERSION_KEY, taskVersion);
+    _taskConfig.setListField(TaskConstants.TASK_CLASSES_KEY, taskClasses);
+    _taskConfig.setSimpleField(TaskConstants.TASK_FACTORY_KEY, taskFactory);
+  }
+
+  /**
+   * Get the task config ZNRecord
+   * @return
+   */
+  public ZNRecord getTaskConfig() {
+    return _taskConfig;
+  }
+
+  /**
+   * Set the task config ZNRecord
+   * @param taskConfig
+   */
+  public void setTaskConfig(ZNRecord taskConfig) {
+    _taskConfig = taskConfig;
+  }

Review comment:
       The setter should be removed due to making `_taskConfig` `final`. But 
the getter is needed to be passed to `create()` in `BaseDataAccessor` when 
first writing the ZNRecord to ZK.




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

Reply via email to