sandynz commented on code in PR #20159: URL: https://github.com/apache/shardingsphere/pull/20159#discussion_r945228097
########## shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/PipelineJobWorker.java: ########## @@ -0,0 +1,55 @@ +/* + * 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.shardingsphere.data.pipeline.scenario.rulealtered; + +import java.util.concurrent.atomic.AtomicBoolean; +import lombok.extern.slf4j.Slf4j; +import org.apache.shardingsphere.data.pipeline.core.context.PipelineContext; +import org.apache.shardingsphere.data.pipeline.core.execute.FinishedCheckJobExecutor; +import org.apache.shardingsphere.data.pipeline.core.execute.PipelineJobExecutor; + +/** + * Pipeline job worker. + */ +@Slf4j +public final class PipelineJobWorker { + + private static final PipelineJobWorker INSTANCE = new PipelineJobWorker(); + + private static final AtomicBoolean WORKER_INITIALIZED = new AtomicBoolean(false); + + /** + * Initialize job worker if necessary. + */ + public static void initWorkerIfNecessary() { + if (WORKER_INITIALIZED.get()) { + return; + } + synchronized (WORKER_INITIALIZED) { + if (WORKER_INITIALIZED.get()) { + return; + } + log.info("start worker initialization"); + PipelineContext.getContextManager().getInstanceContext().getEventBusContext().register(INSTANCE); Review Comment: About `PipelineContext.getContextManager().getInstanceContext().getEventBusContext().register(INSTANCE);`, it still need to register RuleAlteredJobWorker instance, since the `@Subscribe` still in RuleAlteredJobWorker. This is why CI ran failed. ``` PipelineContext.getContextManager().getInstanceContext().getEventBusContext().register(RuleAlteredJobWorker.getInstance()); ``` RuleAlteredJobWorker will be refactor later. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
