You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "dybyte (via GitHub)" <gi...@apache.org> on 2026/04/23 17:08:06 UTC

[PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

dybyte opened a new pull request, #10812:
URL: https://github.com/apache/seatunnel/pull/10812

   Related: https://github.com/apache/seatunnel/issues/10804
   ### Purpose of this pull request
   
   ```mermaid
   graph TD
   
       C["SeaTunnelEngineContext"] --> E["EngineStateStores"]
   
       E --> A["AuthoritativeStateStores"]
       E --> X["AuxiliaryStateStores"]
   
       A --> R1["RuntimeStateStore"]
       A --> C1["CounterStateStore"]
       A --> R2["RuntimeStateStore<br/>for running job info / timestamps / owned slots"]
   
       X --> M["MetricsSnapshotStateStore"]
       X --> H["HistoricalStateStore"]
       X --> OH["ObservableHistoricalStateStore"]
   
       E --> HE["HazelcastEngineStateStores"]
       E --> CE["CompositeEngineStateStores"]
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   ### How was this patch tested?
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4362987260

   Excellent job!
   A small suggestion: Can you add unit tests for merge, remove and removePipeline methods in HazelcastMetricsSnapshotStateStore? using either embedded Hazelcast or mocked IMap. The disabled put operation of HistoricalStateStore should also be covered by assertThrows verification.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on code in PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#discussion_r3176149965


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/common/statestore/EngineStateStoreNames.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.seatunnel.engine.server.common.statestore;
+
+import lombok.Getter;
+
+/**
+ * Bundle of map names required to build a Hazelcast-based {@link EngineStateStores} implementation.
+ */
+@Getter
+public class EngineStateStoreNames {
+    private EngineStateStoreNames() {}
+
+    public static final String RUNNING_JOB_INFO = "engine_runningJobInfo";
+    public static final String RUNNING_JOB_STATE = "engine_runningJobState";
+    public static final String FINISHED_JOB_STATE = "engine_finishedJobState";
+    public static final String FINISHED_JOB_METRICS = "engine_finishedJobMetrics";
+    public static final String FINISHED_JOB_VERTEX_INFO = "engine_finishedJobVertexInfo";
+    public static final String STATE_TIMESTAMPS = "engine_stateTimestamps";
+    public static final String OWNED_SLOT_PROFILES = "engine_ownedSlotProfilesIMap";
+    public static final String CHECKPOINT_ID = "engine_checkpoint-id-map";
+    public static final String RUNNING_JOB_METRICS = "engine_runningJobMetrics";
+    public static final String PENDING_PIPELINE_CLEANUP = "engine_pendingPipelineCleanup";
+    public static final String CHECKPOINT_MONITOR = "engine_checkpoint_monitor";
+    public static final String CONNECTOR_JAR_REF_COUNTERS = "engine_connectorJarRefCounters";

Review Comment:
   Thanks for catching this, I missed it. I’ll fix it.



-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4762306141

   Thanks. There is still no new code after Daniel's latest full review on head 9b007dfe10735b144c998fd3df232d3d17eec28c, so I am not starting another end-to-end re-review in this round. My source-level conclusion on the current head is unchanged.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4321077733

   Thanks for the update. I re-reviewed the latest head locally, and the main thing I wanted to confirm after the previous round was whether the abstraction was now wired into a real runtime path. It is.
   
   The current runtime chain is:
   ```text
   Engine bootstrap
     -> SeaTunnelServer.init() [147-151]
         -> new HazelcastEngineStateStores(...)
         -> SeaTunnelEngineContext.builder(stateStores).build()
   
   Metrics hot path
     -> SeaTunnelServer.updateMetrics(...) [360-364]
         -> engineContext.getStateStores().auxiliary().metricsSnapshotStore()
         -> merge(localMap)
   
   Metrics cleanup path
     -> SeaTunnelServer.removeMetrics(...) [366-369]
         -> engineContext.getStateStores().auxiliary().metricsSnapshotStore()
         -> removePipeline(pipelineLocation)
   ```
   
   So this is no longer just dormant abstraction code. The metrics snapshot path is a real runtime path, and it now goes through the new state-store abstraction.
   
   I also checked the broader engine tree and there are still many direct `IMap` usages in coordinator/checkpoint/DAG paths, so I view this as the first stage of the decoupling rather than the final stage. That is fine with me for this PR, as long as we are explicit about the scope.
   
   I did not find a blocking correctness issue in the current implementation. Compatibility is preserved. My only remaining caution is that Build is still queued on the current head, so I would still glance at the final CI result before merging. From a code-review standpoint, though, this looks mergeable.
   


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4407243753

   Thanks for calling that out. I rechecked the current head against the old `SeaTunnelServer.removeMetrics(...)` path, and you are right that the pre-scan/remove-later behavior already existed before this PR. In other words, the current `HazelcastMetricsSnapshotStateStore.removePipeline(...)` is carrying forward an inherited cleanup semantic rather than newly introducing that race by itself.
   
   So I am not going to keep this PR blocked on that point alone. There is still no new commit after Daniel's latest review, so I am treating this as a reply-only follow-up rather than a fresh full re-review. From Daniel's side, the useful next step is to get the current head back to a stable green `Build`. If you want to harden the cleanup semantics later, I agree that a separate follow-up issue/PR is the cleaner place to do it.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4327020370

   > Do you think I should add a small product-code usage in this PR, or keep it as an abstraction-only PR and migrate usages in follow-up PRs? @davidzollo @DanielLeens
   
   I don't understand what product-code usage means.  an usage doc?


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on code in PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#discussion_r3176149825


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/common/statestore/hazelcast/HazelcastEngineStateStores.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.seatunnel.engine.server.common.statestore.hazelcast;
+
+import org.apache.seatunnel.api.common.metrics.JobMetrics;
+import org.apache.seatunnel.engine.core.job.JobDAGInfo;
+import org.apache.seatunnel.engine.core.job.JobInfo;
+import org.apache.seatunnel.engine.server.common.statestore.AuthoritativeStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.AuxiliaryStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.DefaultAuthoritativeStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.DefaultAuxiliaryStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.EngineStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.checkpoint.CheckpointOverviewStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.checkpoint.hazelcast.HazelcastCheckpointOverviewStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.cleanup.PendingPipelineCleanupStore;
+import org.apache.seatunnel.engine.server.common.statestore.cleanup.hazelcast.HazelcastPendingPipelineCleanupStore;
+import org.apache.seatunnel.engine.server.common.statestore.counter.CounterStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.counter.hazelcast.HazelcastCounterStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.history.HistoricalStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.history.ObservableHistoricalStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.history.hazelcast.HazelcastHistoricalStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.metrics.MetricsSnapshotStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.metrics.hazelcast.HazelcastMetricsSnapshotStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.runtime.RuntimeStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.runtime.hazelcast.HazelcastRuntimeStateStore;
+import org.apache.seatunnel.engine.server.dag.physical.PipelineLocation;
+import org.apache.seatunnel.engine.server.execution.TaskGroupLocation;
+import org.apache.seatunnel.engine.server.master.JobHistoryService;
+import org.apache.seatunnel.engine.server.resourcemanager.resource.SlotProfile;
+
+import com.hazelcast.spi.impl.NodeEngine;
+
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.CHECKPOINT_ID;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.CHECKPOINT_MONITOR;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.FINISHED_JOB_METRICS;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.FINISHED_JOB_STATE;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.FINISHED_JOB_VERTEX_INFO;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.OWNED_SLOT_PROFILES;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.PENDING_PIPELINE_CLEANUP;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.RUNNING_JOB_INFO;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.RUNNING_JOB_METRICS;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.RUNNING_JOB_STATE;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.STATE_TIMESTAMPS;
+
+/**
+ * {@link EngineStateStores} implementation backed by Hazelcast.
+ *
+ * <p>Engine code is not expected to reference this implementation directly. It is intended to be
+ * created only during bootstrap and injected through interfaces.
+ */
+public class HazelcastEngineStateStores implements EngineStateStores {
+
+    private final NodeEngine nodeEngine;
+    private final int metricsPartitionCount;
+    private AuthoritativeStateStores authoritativeStateStores;
+    private AuxiliaryStateStores auxiliaryStateStores;
+

Review Comment:
   Thanks for catching this, I missed it. I’ll fix it.



-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on code in PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#discussion_r3176123643


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/common/statestore/hazelcast/HazelcastEngineStateStores.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.seatunnel.engine.server.common.statestore.hazelcast;
+
+import org.apache.seatunnel.api.common.metrics.JobMetrics;
+import org.apache.seatunnel.engine.core.job.JobDAGInfo;
+import org.apache.seatunnel.engine.core.job.JobInfo;
+import org.apache.seatunnel.engine.server.common.statestore.AuthoritativeStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.AuxiliaryStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.DefaultAuthoritativeStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.DefaultAuxiliaryStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.EngineStateStores;
+import org.apache.seatunnel.engine.server.common.statestore.checkpoint.CheckpointOverviewStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.checkpoint.hazelcast.HazelcastCheckpointOverviewStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.cleanup.PendingPipelineCleanupStore;
+import org.apache.seatunnel.engine.server.common.statestore.cleanup.hazelcast.HazelcastPendingPipelineCleanupStore;
+import org.apache.seatunnel.engine.server.common.statestore.counter.CounterStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.counter.hazelcast.HazelcastCounterStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.history.HistoricalStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.history.ObservableHistoricalStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.history.hazelcast.HazelcastHistoricalStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.metrics.MetricsSnapshotStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.metrics.hazelcast.HazelcastMetricsSnapshotStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.runtime.RuntimeStateStore;
+import org.apache.seatunnel.engine.server.common.statestore.runtime.hazelcast.HazelcastRuntimeStateStore;
+import org.apache.seatunnel.engine.server.dag.physical.PipelineLocation;
+import org.apache.seatunnel.engine.server.execution.TaskGroupLocation;
+import org.apache.seatunnel.engine.server.master.JobHistoryService;
+import org.apache.seatunnel.engine.server.resourcemanager.resource.SlotProfile;
+
+import com.hazelcast.spi.impl.NodeEngine;
+
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.CHECKPOINT_ID;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.CHECKPOINT_MONITOR;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.FINISHED_JOB_METRICS;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.FINISHED_JOB_STATE;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.FINISHED_JOB_VERTEX_INFO;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.OWNED_SLOT_PROFILES;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.PENDING_PIPELINE_CLEANUP;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.RUNNING_JOB_INFO;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.RUNNING_JOB_METRICS;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.RUNNING_JOB_STATE;
+import static org.apache.seatunnel.engine.server.common.statestore.EngineStateStoreNames.STATE_TIMESTAMPS;
+
+/**
+ * {@link EngineStateStores} implementation backed by Hazelcast.
+ *
+ * <p>Engine code is not expected to reference this implementation directly. It is intended to be
+ * created only during bootstrap and injected through interfaces.
+ */
+public class HazelcastEngineStateStores implements EngineStateStores {
+
+    private final NodeEngine nodeEngine;
+    private final int metricsPartitionCount;
+    private AuthoritativeStateStores authoritativeStateStores;
+    private AuxiliaryStateStores auxiliaryStateStores;
+

Review Comment:
   The two fields authoritativeStateStores and auxiliaryStateStores are not declared volatile, and the Double-Checked Locking  pattern is used in ensureInitialized(). The standard implementation of DCL requires singleton fields to be declared volatile. 



-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4321043967

   @DanielLeens Updated


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4331873194

   Thanks for addressing the lifecycle gap from the previous round. I re-reviewed the latest head locally from seatunnel-review-10812 against upstream/dev.
   
   ## What this PR solves
   - User pain: engine services still depend directly on Hazelcast state primitives, which keeps storage concerns coupled to runtime logic.
   - Fix approach: introduce EngineStateStores / SeaTunnelEngineContext, inject that context into the checkpoint monitor path, and close it during server shutdown.
   - One-line value: this is a good step toward decoupling the engine from Hazelcast-specific state access.
   
   ## Runtime path
   ```text
   SeaTunnelServer.init()
     -> new HazelcastEngineStateStores(...) [SeaTunnelServer.java:147-150]
     -> SeaTunnelEngineContext.builder(stateStores).build() [SeaTunnelServer.java:151]
     -> startMaster()
        -> new CheckpointMonitorService(engineContext, 32) [SeaTunnelServer.java:195-200]
   
   SeaTunnelServer.shutdown()
     -> MetadataProviderManager.closeProviders() [SeaTunnelServer.java:247]
     -> engineContext.close() [SeaTunnelServer.java:248]
        -> stateStores.close() [SeaTunnelEngineContext.java:52-55]
   ```
   
   ## Review findings
   I did not find a blocking code issue in the latest head.
   
   - The previous blocker around lifecycle symmetry is fixed now.
   - SeaTunnelServer.shutdown() now calls engineContext.close().
   - SeaTunnelEngineContext.close() closes the underlying state stores.
   - The normal master startup path also uses the new abstraction when constructing CheckpointMonitorService.
   
   ## Merge conclusion
   **Conclusion: Merge after fixes**
   
   Blocking items:
   - CI is still red. The current failing job is Run / kafka-connector-it (8, ubuntu-latest) in fork run 25004536978 / job 73252480060.
   
   Non-blocking suggestions:
   - Adding a focused lifecycle regression test for SeaTunnelServer.shutdown() -> engineContext.close() would make this change safer.
   
   CI status:
   - Apache-side Build is failing; the code review itself is clear on the latest head.
   


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4328305411

   @DanielLeens Updated


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on code in PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#discussion_r3176171693


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/common/statestore/metrics/hazelcast/HazelcastMetricsSnapshotStateStore.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.seatunnel.engine.server.common.statestore.metrics.hazelcast;
+
+import org.apache.seatunnel.engine.server.common.statestore.metrics.MetricsSnapshotStateStore;
+import org.apache.seatunnel.engine.server.dag.physical.PipelineLocation;
+import org.apache.seatunnel.engine.server.execution.TaskLocation;
+import org.apache.seatunnel.engine.server.metrics.SeaTunnelMetricsContext;
+
+import com.hazelcast.map.IMap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** Implementation backed by a partitioned Hazelcast metrics {@link IMap}. */
+public class HazelcastMetricsSnapshotStateStore implements MetricsSnapshotStateStore {
+
+    private final IMap<Long, Map<TaskLocation, SeaTunnelMetricsContext>> metricsImap;
+    private final int partitionCount;
+
+    public HazelcastMetricsSnapshotStateStore(
+            IMap<Long, Map<TaskLocation, SeaTunnelMetricsContext>> metricsImap,
+            int partitionCount) {
+        this.metricsImap = metricsImap;
+        this.partitionCount = partitionCount;
+    }
+
+    @Override
+    public void merge(Map<TaskLocation, SeaTunnelMetricsContext> snapshot) {
+        if (snapshot == null || snapshot.isEmpty()) {
+            return;
+        }
+
+        Map<Long, Map<TaskLocation, SeaTunnelMetricsContext>> partitioned = new HashMap<>();
+        snapshot.forEach(
+                (key, value) -> {
+                    long partition = partition(key);
+                    partitioned.computeIfAbsent(partition, k -> new HashMap<>()).put(key, value);
+                });
+
+        partitioned
+                .entrySet()
+                .parallelStream()
+                .forEach(
+                        entry -> {
+                            metricsImap.compute(
+                                    entry.getKey(),
+                                    (k, oldVal) -> {
+                                        if (oldVal == null) oldVal = new HashMap<>();
+                                        oldVal.putAll(entry.getValue());
+                                        return oldVal;
+                                    });
+                        });
+    }
+
+    @Override
+    public SeaTunnelMetricsContext get(TaskLocation taskLocation) {
+        Map<TaskLocation, SeaTunnelMetricsContext> partitionMap =
+                metricsImap.get(partition(taskLocation));
+        return partitionMap == null ? null : partitionMap.get(taskLocation);
+    }
+
+    @Override
+    public void remove(final TaskLocation taskLocation) {
+        metricsImap.compute(
+                partition(taskLocation),
+                (ignored, current) -> {
+                    if (current == null) {
+                        return null;
+                    }
+                    Map<TaskLocation, SeaTunnelMetricsContext> updated = new HashMap<>(current);
+                    updated.remove(taskLocation);
+                    return updated.isEmpty() ? null : updated;
+                });
+    }
+
+    @Override
+    public void removePipeline(final PipelineLocation pipelineLocation) {
+        for (long partition = 0; partition < partitionCount; partition++) {
+            // Clean each metrics bucket in one compute to avoid full-map scans and removal races.
+            metricsImap.compute(
+                    partition,
+                    (k, oldVal) -> {
+                        if (oldVal == null || oldVal.isEmpty()) {
+                            return oldVal;
+                        }
+                        oldVal.entrySet()
+                                .removeIf(
+                                        entry ->
+                                                pipelineLocation.equals(
+                                                        entry.getKey()
+                                                                .getTaskGroupLocation()
+                                                                .getPipelineLocation()));
+                        return oldVal.isEmpty() ? null : oldVal;
+                    });
+        }

Review Comment:
   Good point. This currently follows the approach from #10757 , which calls compute for all configured metric buckets.
   
   I’ll change it in this PR to iterate over existing metric bucket entries instead, so we only process buckets that actually exist. We can consider further optimization later, such as tracking partition keys each pipeline uses during the merge process.



-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4363615495

   Thanks for the follow-up. I saw the new review threads and your replies.
   
   There is still no new commit after Daniel's latest full review on this PR, so I am not starting another full re-review in this round. Since the latest activity is your note that you plan to address the new review comments in code, the next useful step is to push that follow-up commit first.
   
   Once the code update is on the branch, I am happy to re-review the latest head end to end.
   


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4309654967

   # What This PR Fixes
   - User pain point: engine state access is still heavily coupled to Hazelcast `IMap`, which makes future backend decoupling much harder.
   - Fix approach: this PR adds `SeaTunnelEngineContext`, `EngineStateStores`, and a new `StateStore` abstraction layer plus Hazelcast-backed wrappers.
   - One-line summary: the direction is reasonable, but the current head mostly adds abstraction definitions without wiring any existing engine hot path to them yet.
   
   ## Local Review Basis
   I reviewed the full diff locally against `upstream/dev` on `seatunnel-review-10812` at `b7e336f8d81f`. I also checked the current engine call sites and did not run local Maven in this batch.
   
   ## Current Runtime Chain
   ```text
   Current real engine path
     -> CoordinatorService.initCoordinatorService()
         -> nodeEngine.getHazelcastInstance().getMap(...)
     -> JobHistoryService constructor
         -> receives IMap directly and registers listeners on it
     -> SeaTunnelServer.taskIsEnded() / updateMetrics() / removeMetrics()
         -> continues to call getMap(...) / IMap.compute(...)
   
   New abstraction added by this PR
     -> SeaTunnelEngineContext
     -> EngineStateStores / HazelcastEngineStateStores / *StateStore wrappers
   
   Current status
     -> these two paths are still not connected
   ```
   
   ## Findings
   1. The latest head adds the abstraction files, but `git grep` on the PR head shows `SeaTunnelEngineContext` / `EngineStateStores` are only referenced inside the newly added definitions themselves.
   2. The existing engine paths still directly use Hazelcast state access in places like:
      - `CoordinatorService.java:404-429`
      - `JobHistoryService.java:108-126`
      - `SeaTunnelServer.java:315-382`
   3. That means the normal runtime path still does not hit the new abstraction yet, so the PR has not actually completed the “decouple Hazelcast IMap” step it claims in the title.
   4. The current `Build` check is also red (`72742556130`), with failures reported in multiple integration suites.
   
   ## Conclusion: can merge after fixes
   Blocking items:
   1. Please wire at least one real engine call path through `EngineStateStores` before merging. Right now this is still dormant abstraction code rather than a completed decoupling step.
   2. Please rerun and recover the latest `Build` result after a real call-site migration is in place.
   
   Suggested non-blocking improvement:
   - I would strongly recommend landing the first real call-site migration together with a focused behavior test. That would make this abstraction much easier to trust and maintain.
   
   Thank you for driving this cleanup direction. I do think it is the right direction; the current blocker is that the real engine path has not been moved over yet, so the abstraction is not proving its value in production code today.
   


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4351176186

   @DanielLeens CI has passed


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4661489712

   One blocking issue from my side: `MetricsSnapshotStateStore` currently inherits `StateStore<TaskLocation, SeaTunnelMetricsContext>`, but `HazelcastMetricsSnapshotStateStore.size()` returns the number of outer metric buckets rather than the number of task snapshots.
   
   That means the new abstraction is still leaking Hazelcast partition-layout semantics into a generic `StateStore` contract, which makes the API misleading for future backends and callers.
   
   I would suggest either:
   1. narrowing the metrics store API so it does not inherit the generic `StateStore` surface, or
   2. making `size()` return the total snapshot count across all inner maps and updating the related tests accordingly.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4642313255

   @zhangshenghang @DanielLeens 
   Based on the feedback about keeping this incremental, I narrowed the scope of this change to the metrics snapshot store and checkpoint overview store only.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4633098153

   @zhangshenghang Thanks for the detailed review. I agree that the current intermediate state needs to be safer.
   
   One concern I have is that if we remove all store abstractions that are not yet wired into production code, this PR may only show a small part of the intended StateStore design and make the abstraction look incomplete.
   
   However, I also agree that wiring all raw IMap consumers in this PR would touch many runtime paths, make the PR much harder to review, and likely cause more merge conflicts.
   
   So I think it is better to keep this PR as the first production wiring step, make EngineStateStoreNames/metrics partitioning transition-safe, and introduce the remaining stores together with each actual migration in follow-up PRs.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4630622211

   Thanks @zhangshenghang for writing this up so clearly. I rechecked your points against the current head.
   
   I agree that point 1 is a real scope concern: on the current branch only the metrics snapshot path and the checkpoint overview path are actually migrated, while the rest of the new store surface is still unused. My earlier approval was only for the narrower claim that this PR had finally moved real engine runtime code onto the abstraction, not for a completed full-engine decoupling.
   
   I also agree that point 2 is worth fixing in code rather than leaving two parallel sources of truth for the same map names. Point 3 is related as well: if the abstraction is meant to own metrics state access, the partitioning/read path should live in one place instead of being split between `HazelcastMetricsSnapshotStateStore` and `SeaTunnelServer` / `TaskExecutionContext`.
   
   There is still no new commit after Daniel's latest review on this PR, so I am treating this as a reply-only follow-up instead of starting another full re-review on the same head. From Daniel's side the next useful step is a code update that either narrows the PR to the stores that are already wired into production paths, or pushes the migration further so the duplicated constants / split access pattern are resolved in the implementation. Once that update is on the branch, I am happy to re-review the latest head end to end.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang merged PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4312673047

   Do you think I should add a small product-code usage in this PR, or keep it as an abstraction-only PR and migrate usages in follow-up PRs?  @davidzollo @DanielLeens 


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4762305801

   Thanks. There is still no new code after Daniel's latest full review on head \, so I am not starting another end-to-end re-review in this round. My source-level conclusion on the current head is unchanged.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4629603490

     Thanks for the effort on this — the direction is valuable. However, in its current form I have some concerns that I think need to be
     addressed before merge. I verified the points below against the full seatunnel-engine-server module.
   
     1. The decoupling is incomplete — most of the new abstraction has zero callers 
   
     HazelcastEngineStateStores.ensureInitialized() constructs 12 stores, but only 2 are actually consumed anywhere:
     - MetricsSnapshotStateStore (via SeaTunnelServer#updateMetrics/removeMetrics)
     - CheckpointOverviewStateStore (via CheckpointMonitorService)
   
     The other ~10 — runningJobInfoStore, runningJobStateStore, runningJobStateTimestampsStore, ownedSlotProfilesStore, finishedJob*Store, checkpointCounterStore, pendingPipelineCleanupStore, connectorJarReferenceStateStore —
     have no callers. Meanwhile the real consumers of that state still access raw IMap directly and are untouched by this PR:
   
     - CoordinatorService
     - IMapCheckpointIDCounter
     - SharedConnectorJarStorageStrategy
     - JobMaster
     - TaskExecutionContext
     - JobInfoService / BaseService / GetOverviewOperation / PhysicalVertex
   
     Net result: the coupling the PR aims to remove is still fully present, and we've added ~2,000 lines of parallel, unreferenced code on top. I'd suggest one of:
     - Narrow the scope: keep only the two stores that are actually wired in (metrics + checkpoint overview), drop the rest, and migrate the remaining consumers in follow-up PRs; or
     - Complete the migration in this PR by switching the corresponding consumers (CoordinatorService → runtime/cleanup stores, IMapCheckpointIDCounter → counter store, etc.) to the new abstraction.
   
     The current "add the new layer but keep the old one" intermediate state is the hardest to maintain.
   
     2. Map-name constants are duplicated → silent split-brain risk 
   
     EngineStateStoreNames re-declares all 12 names with values identical to engine.common.Constant.IMAP_* (e.g. both define "engine_runningJobMetrics", "engine_checkpoint_monitor", …). Because the new stores and the legacy
     direct-IMap consumers must always point to the same map, having two sources of truth means a future edit to one set of constants would silently make half the components read/write a different map — surfacing as
     "metrics/checkpoint overview mysteriously empty" and very hard to debug.
   
     Please reference Constant.IMAP_* directly instead of copying the literals.
   
     3. Metrics partition logic is duplicated, so the map isn't really encapsulated 
   
     HazelcastMetricsSnapshotStateStore#partition() and SeaTunnelServer#getMetricsImapPartition() (still used by TaskExecutionContext) implement the same partitioning. Writes now go through the store, but reads
     (TaskExecutionContext#getOrCreateMetricsContext) still bypass it and compute the partition via the static method against the raw IMap. They agree today (0x7FFFFFFF == Integer.MAX_VALUE), but this is exactly the coupling the
     abstraction should remove — any change to one side breaks read/write consistency. Consider routing the read through MetricsSnapshotStateStore#get(taskLocation) and keeping the partition logic in one place.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on code in PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#discussion_r3176133836


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/common/statestore/EngineStateStoreNames.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.seatunnel.engine.server.common.statestore;
+
+import lombok.Getter;
+
+/**
+ * Bundle of map names required to build a Hazelcast-based {@link EngineStateStores} implementation.
+ */
+@Getter
+public class EngineStateStoreNames {
+    private EngineStateStoreNames() {}
+
+    public static final String RUNNING_JOB_INFO = "engine_runningJobInfo";
+    public static final String RUNNING_JOB_STATE = "engine_runningJobState";
+    public static final String FINISHED_JOB_STATE = "engine_finishedJobState";
+    public static final String FINISHED_JOB_METRICS = "engine_finishedJobMetrics";
+    public static final String FINISHED_JOB_VERTEX_INFO = "engine_finishedJobVertexInfo";
+    public static final String STATE_TIMESTAMPS = "engine_stateTimestamps";
+    public static final String OWNED_SLOT_PROFILES = "engine_ownedSlotProfilesIMap";
+    public static final String CHECKPOINT_ID = "engine_checkpoint-id-map";
+    public static final String RUNNING_JOB_METRICS = "engine_runningJobMetrics";
+    public static final String PENDING_PIPELINE_CLEANUP = "engine_pendingPipelineCleanup";
+    public static final String CHECKPOINT_MONITOR = "engine_checkpoint_monitor";
+    public static final String CONNECTOR_JAR_REF_COUNTERS = "engine_connectorJarRefCounters";

Review Comment:
   Is the variable `CONNECTOR_JAR_REF_COUNTERS` actually used?



-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4405125731

   @DanielLeens Good point. The pre-scan based `removePipeline()` logic may indeed have a race window with concurrent `merge()`.
   
   However, I checked the previous implementation, and this pre-scan based removal was already present before this PR. This PR only moves the current metrics state access behind the StateStore abstraction, so I think we should avoid changing the cleanup semantics here and handle this as a separate follow-up issue.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4362821694

   > > > Do you think I should add a small product-code usage in this PR, or keep it as an abstraction-only PR and migrate usages in follow-up PRs? @davidzollo @DanielLeens
   > > 
   > > 
   > > I don't understand what product-code usage means. an usage doc?
   > 
   > I meant using the new abstraction in real engine runtime code, not a usage document.
   > 
   > For example, I updated `SeaTunnelServer.updateMetrics()` and `removeMetrics()` to access the metrics snapshot state through `EngineStateStores` instead of directly using Hazelcast `IMap`.
   > 
   > So this PR now introduces the abstraction layer and also includes the first small product-code migration.
   
   Thanks a lot for the detailed explanation! I get it now.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4636777433

   I agree with the safety goal you called out, but I would still avoid merging a broad abstraction surface that is only partially wired. The safer line here is: either keep only the runtime paths that are already exercised today, or wire the remaining stores into real engine call sites before merge. That keeps the abstraction honest and prevents us from carrying a large API surface whose behavior is still only hypothetical. There is still no new commit after the latest Daniel follow-up on this PR, so I am keeping this as a reply-only round for now. Once you push the next revision, I will re-review the full current head.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on code in PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#discussion_r3176132490


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/common/statestore/metrics/hazelcast/HazelcastMetricsSnapshotStateStore.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.seatunnel.engine.server.common.statestore.metrics.hazelcast;
+
+import org.apache.seatunnel.engine.server.common.statestore.metrics.MetricsSnapshotStateStore;
+import org.apache.seatunnel.engine.server.dag.physical.PipelineLocation;
+import org.apache.seatunnel.engine.server.execution.TaskLocation;
+import org.apache.seatunnel.engine.server.metrics.SeaTunnelMetricsContext;
+
+import com.hazelcast.map.IMap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** Implementation backed by a partitioned Hazelcast metrics {@link IMap}. */
+public class HazelcastMetricsSnapshotStateStore implements MetricsSnapshotStateStore {
+
+    private final IMap<Long, Map<TaskLocation, SeaTunnelMetricsContext>> metricsImap;
+    private final int partitionCount;
+
+    public HazelcastMetricsSnapshotStateStore(
+            IMap<Long, Map<TaskLocation, SeaTunnelMetricsContext>> metricsImap,
+            int partitionCount) {
+        this.metricsImap = metricsImap;
+        this.partitionCount = partitionCount;
+    }
+
+    @Override
+    public void merge(Map<TaskLocation, SeaTunnelMetricsContext> snapshot) {
+        if (snapshot == null || snapshot.isEmpty()) {
+            return;
+        }
+
+        Map<Long, Map<TaskLocation, SeaTunnelMetricsContext>> partitioned = new HashMap<>();
+        snapshot.forEach(
+                (key, value) -> {
+                    long partition = partition(key);
+                    partitioned.computeIfAbsent(partition, k -> new HashMap<>()).put(key, value);
+                });
+
+        partitioned
+                .entrySet()
+                .parallelStream()
+                .forEach(
+                        entry -> {
+                            metricsImap.compute(
+                                    entry.getKey(),
+                                    (k, oldVal) -> {
+                                        if (oldVal == null) oldVal = new HashMap<>();
+                                        oldVal.putAll(entry.getValue());
+                                        return oldVal;
+                                    });
+                        });
+    }
+
+    @Override
+    public SeaTunnelMetricsContext get(TaskLocation taskLocation) {
+        Map<TaskLocation, SeaTunnelMetricsContext> partitionMap =
+                metricsImap.get(partition(taskLocation));
+        return partitionMap == null ? null : partitionMap.get(taskLocation);
+    }
+
+    @Override
+    public void remove(final TaskLocation taskLocation) {
+        metricsImap.compute(
+                partition(taskLocation),
+                (ignored, current) -> {
+                    if (current == null) {
+                        return null;
+                    }
+                    Map<TaskLocation, SeaTunnelMetricsContext> updated = new HashMap<>(current);
+                    updated.remove(taskLocation);
+                    return updated.isEmpty() ? null : updated;
+                });
+    }
+
+    @Override
+    public void removePipeline(final PipelineLocation pipelineLocation) {
+        for (long partition = 0; partition < partitionCount; partition++) {
+            // Clean each metrics bucket in one compute to avoid full-map scans and removal races.
+            metricsImap.compute(
+                    partition,
+                    (k, oldVal) -> {
+                        if (oldVal == null || oldVal.isEmpty()) {
+                            return oldVal;
+                        }
+                        oldVal.entrySet()
+                                .removeIf(
+                                        entry ->
+                                                pipelineLocation.equals(
+                                                        entry.getKey()
+                                                                .getTaskGroupLocation()
+                                                                .getPipelineLocation()));
+                        return oldVal.isEmpty() ? null : oldVal;
+                    });
+        }

Review Comment:
   In this method, `removePipeline` initiates a remote call to `metricsImap.compute()` for every bucket ranging from 0 to partitionCount-1. In contrast, the original implementation is realized by traversing the entry set of IMap and applying filtering. Although both approaches perform full-scan processing, the problem with the current implementation is that it triggers `partitionCount` (defaulting to 32 or higher) independent Hazelcast `compute()` operations, each of which is a cross-node distributed invocation.
   
   This will generate a large number of distributed compute requests and may temporarily increase the network pressure on the Master node.
   
   Improvement suggestions: 
   Only traverse the actually existing bucket keys in IMap, or record which partition keys each pipeline uses during the merge process, so that `removePipeline` only cleans up the associated partitions.



-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4327286183

   > > Do you think I should add a small product-code usage in this PR, or keep it as an abstraction-only PR and migrate usages in follow-up PRs? @davidzollo @DanielLeens
   > 
   > I don't understand what product-code usage means. an usage doc?
   
   I meant using the new abstraction in real engine runtime code, not a usage document.
   
   For example, I updated `SeaTunnelServer.updateMetrics()` and `removeMetrics()` to access the metrics snapshot state through `EngineStateStores` instead of directly using Hazelcast `IMap`.
   
   So this PR now introduces the abstraction layer and also includes the first small product-code migration.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4317466075

   Hi @dybyte, I rechecked the latest head locally, including your question about whether this PR should stay abstraction-only.
   
   # Short answer to your question
   I would strongly recommend adding at least one small real product-code migration in this PR.
   
   # Why
   - The new abstraction layer is cleaner now, but the normal engine hot paths still do not go through it.
   - I rechecked current call sites and they are still direct Hazelcast/IMap usage, for example:
     - `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:317-389`
     - `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobHistoryService.java:108-126`
   - I also verified with a grep on the PR head that, outside the newly added abstraction definitions themselves, there is still no real product-code usage of `SeaTunnelEngineContext` / `EngineStateStores`.
   
   # Runtime view I rechecked
   ~~~text
   Current real engine path
     -> SeaTunnelServer.taskIsEnded()
         -> nodeEngine.getHazelcastInstance().getMap(Constant.IMAP_RUNNING_JOB_STATE)
     -> SeaTunnelServer.updateMetrics() / removeMetrics()
         -> getMap(Constant.IMAP_RUNNING_JOB_METRICS)
     -> JobHistoryService constructor
         -> still receives IMap directly
   
   New abstraction added by this PR
     -> SeaTunnelEngineContext
     -> EngineStateStores / StateStore interfaces / Hazelcast wrappers
   
   Current status
     -> abstraction exists
     -> real engine hot path is still not wired to it
   ~~~
   
   # Merge conclusion
   ### Conclusion: merge after fixes
   
   Blocking item:
   - Please migrate at least one real engine call path in this PR, or narrow the PR title/scope so it clearly describes this as a foundation-only change rather than a completed decoupling step.
   
   Suggested direction:
   - A small migration in `SeaTunnelServer.updateMetrics()/removeMetrics()` or one of the pending-cleanup paths would already make this PR much easier to trust.
   
   The direction is absolutely the right one. The remaining blocker is just that the current head has not yet proved the abstraction on a real production path.
   


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4661735393

   Thanks for flagging this, @davidzollo. I rechecked the current head on this specific point, and I agree it is still a real blocker. `MetricsSnapshotStateStore` exposes `StateStore<TaskLocation, SeaTunnelMetricsContext>` semantics, but `HazelcastMetricsSnapshotStateStore.size()` still returns the size of the outer Hazelcast bucket map rather than the total number of task snapshots. That leaks backend partition layout into a generic store contract and makes the API misleading for future backends and callers.
   
   Since there is still no new commit after Daniel's latest full review on this PR, I am not starting another full re-review in this round. Please fix this in code first, then I will re-review the next head from scratch.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Zeta] Decouple Hazelcast IMap via StateStore Abstraction [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10812:
URL: https://github.com/apache/seatunnel/pull/10812#issuecomment-4761679371

   Thanks for the follow-up review. I rechecked the activity on the current head `9b007dfe10735b144c998fd3df232d3d17eec28c`.
   
   There is still no new commit after Daniel's latest full review, so I am not starting another end-to-end re-review in this round. Daniel's current conclusion stays the same: I do not have a new source-level blocker on this head.
   
   If the branch changes again, I'm happy to re-review the next head from scratch.


-- 
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-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org