Jackie-Jiang commented on a change in pull request #6124: URL: https://github.com/apache/incubator-pinot/pull/6124#discussion_r508092308
########## File path: pinot-common/src/main/java/org/apache/pinot/common/minion/MinionTaskMetadataUtils.java ########## @@ -0,0 +1,81 @@ +/** + * 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. + */ +package org.apache.pinot.common.minion; + +import javax.annotation.Nullable; +import org.I0Itec.zkclient.exception.ZkException; +import org.apache.helix.AccessOption; +import org.apache.helix.ZNRecord; +import org.apache.helix.store.HelixPropertyStore; +import org.apache.pinot.common.metadata.ZKMetadataProvider; +import org.apache.zookeeper.data.Stat; + + +/** + * Helper methods to fetch/persist ZNRecord for minion task metadata + */ +public final class MinionTaskMetadataUtils { + + private MinionTaskMetadataUtils() { + + } + + /** + * Fetches the ZNRecord for the given minion task and tableName, from MINION_TASK_METADATA/taskName/tableNameWthType + */ + @Nullable + public static ZNRecord fetchMinionTaskMetadataZNRecord(HelixPropertyStore<ZNRecord> propertyStore, String taskType, + String tableNameWithType) { + String path = ZKMetadataProvider.constructPropertyStorePathForMinionTaskMetadata(taskType, tableNameWithType); + Stat stat = new Stat(); + ZNRecord znRecord = propertyStore.get(path, stat, AccessOption.PERSISTENT); + if (znRecord != null) { + znRecord.setVersion(stat.getVersion()); + } + return znRecord; + } + + /** + * Fetches the ZNRecord for realtimeToOfflineSegmentsTask for given tableNameWithType from MINION_TASK_METADATA/realtimeToOfflineSegmentsTask/tableNameWthType + * and converts it to a {@link RealtimeToOfflineSegmentsTaskMetadata} object + */ + @Nullable + public static RealtimeToOfflineSegmentsTaskMetadata getRealtimeToOfflineSegmentsTaskMetadata( + HelixPropertyStore<ZNRecord> propertyStore, String taskType, String tableNameWithType) { + ZNRecord znRecord = fetchMinionTaskMetadataZNRecord(propertyStore, taskType, tableNameWithType); + return znRecord != null ? RealtimeToOfflineSegmentsTaskMetadata.fromZNRecord(znRecord) : null; + } + + /** + * Persists the provided {@link RealtimeToOfflineSegmentsTaskMetadata} to MINION_TASK_METADATA/realtimeToOfflineSegmentsTask/tableNameWthType. + * Will fail if expectedVersion does not match. + * Set expectedVersion -1 to override version check. + */ + public static void persistRealtimeToOfflineSegmentsTaskMetadata(HelixPropertyStore<ZNRecord> propertyStore, + String taskType, RealtimeToOfflineSegmentsTaskMetadata realtimeToOfflineSegmentsTaskMetadata, Review comment: Do we need to provide `taskType` here? It is always `realtimeToOfflineSegmentsTask` right? ########## File path: pinot-common/src/main/java/org/apache/pinot/common/minion/RealtimeToOfflineSegmentsTaskMetadata.java ########## @@ -0,0 +1,95 @@ +/** + * 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. + */ +package org.apache.pinot.common.minion; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.apache.helix.ZNRecord; +import org.apache.pinot.spi.utils.JsonUtils; Review comment: You can remove all the json-related stuff because this class does not need to be json compatible. It should always be constructed with `fromZNRecord()` ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/ClusterUpdater.java ########## @@ -0,0 +1,50 @@ +/** + * 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. + */ +package org.apache.pinot.controller.helix.core.minion; + +import org.apache.pinot.common.minion.MinionTaskMetadataUtils; +import org.apache.pinot.common.minion.RealtimeToOfflineSegmentsTaskMetadata; +import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; +import org.apache.pinot.controller.helix.core.minion.generator.PinotTaskGenerator; +import org.apache.pinot.core.common.MinionConstants; + + +/** + * An abstraction on top of {@link PinotHelixResourceManager}, created for the {@link PinotTaskGenerator}, + * with scope restricted to cluster updates. + * This also helps in separating read and update methods from the {@link ClusterInfoProvider} + */ +public class ClusterUpdater { Review comment: After some reconsideration, I feel it might be easier to manage if we merge provider and updater to `ClusterInfoAccessor` in case we need update the metadata based on the current value in the future. Sorry that I was suggesting separating it out in the previous review. ########## File path: pinot-minion/src/main/java/org/apache/pinot/minion/executor/BaseTaskExecutor.java ########## @@ -43,9 +44,20 @@ protected TableConfig getTableConfig(String tableNameWithType) { } protected Schema getSchema(String tableName) { - Schema schema = - ZKMetadataProvider.getTableSchema(MINION_CONTEXT.getHelixPropertyStore(), tableName); + Schema schema = ZKMetadataProvider.getTableSchema(MINION_CONTEXT.getHelixPropertyStore(), tableName); Preconditions.checkState(schema != null, "Failed to find schema for table: %s", tableName); return schema; } + + /** + * Pre processing operations to be done at the beginning of task execution + */ + protected void preProcess(PinotTaskConfig pinotTaskConfig) { Review comment: Move these 2 methods to the `BaseMultipleSegmentsConversionExecutor` where it is getting called. Usually we allow child class to override methods used in the parent class. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org