Sxnan commented on code in PR #138:
URL: https://github.com/apache/flink-agents/pull/138#discussion_r2354802286
##########
runtime/src/main/java/org/apache/flink/agents/runtime/operator/ActionExecutionOperator.java:
##########
@@ -392,6 +447,71 @@ public void close() throws Exception {
super.close();
}
+ @Override
+ public void initializeState(StateInitializationContext context) throws
Exception {
+ super.initializeState(context);
+
+ if (actionStateStore != null) {
+ Object recoveryMarker = null;
+ ListState<Object> recoveryMarkerOpState =
+ getOperatorStateBackend()
+ .getListState(
+ new ListStateDescriptor<>(
+ "recoveryMarker",
TypeInformation.of(Object.class)));
+ Iterable<Object> recoveryMarkers = recoveryMarkerOpState.get();
+ if (recoveryMarkers != null) {
+ for (Object marker : recoveryMarkers) {
+ // there should be only one recovery marker
+ recoveryMarker = marker;
+ break;
+ }
+ }
+ actionStateStore.rebuildState(recoveryMarker);
+ }
+ ListState<Long> msgSequenceNumberOpState =
Review Comment:
I think we should use the keyed value state for the sequence number for each
key
##########
runtime/src/main/java/org/apache/flink/agents/runtime/actionstate/ActionStateUtil.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.flink.agents.runtime.actionstate;
+
+import org.apache.flink.agents.api.Event;
+import org.apache.flink.agents.plan.Action;
+
+import java.nio.charset.StandardCharsets;
+import java.util.UUID;
+
+/** Utility class for action state related operations. */
+public class ActionStateUtil {
+
+ public static String generateKey(Object key, Action action, Event event) {
+ return key
+ + "-"
+ + UUID.nameUUIDFromBytes(
Review Comment:
Since one action can depend on the state produced by a previous action, if
the input event arrived in a different order after recovery, we have to drop
the action state for that key. I think this is missing in the PR.
One possible implementation is that if we cannot find an action state for a
key `k` and sequence number `n`, we clear the action state for key `k` whose
sequence number is greater than `n`.
##########
runtime/src/main/java/org/apache/flink/agents/runtime/actionstate/ActionStateStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.flink.agents.runtime.actionstate;
+
+import org.apache.flink.agents.api.Event;
+import org.apache.flink.agents.plan.Action;
+
+import java.io.IOException;
+
+/** Interface for storing and retrieving the state of actions performed by
agents. */
+public interface ActionStateStore {
+ enum BackendType {
+ INMEMORY("inmemory"),
Review Comment:
We can remove this
--
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]