You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "mxm (via GitHub)" <gi...@apache.org> on 2024/01/11 14:01:48 UTC

Re: [PR] [FLINK-33450][autoscaler] Support the JDBCAutoScalerStateStore [flink-kubernetes-operator]

mxm commented on code in PR #741:
URL: https://github.com/apache/flink-kubernetes-operator/pull/741#discussion_r1448905911


##########
flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/config/AutoscalerStandaloneOptions.java:
##########
@@ -59,4 +64,47 @@ private static ConfigOptions.OptionBuilder autoscalerStandaloneConfig(String key
                     .withDeprecatedKeys("flinkClusterPort")
                     .withDescription(
                             "The port of flink cluster when the flink-cluster fetcher is used.");
+
+    public static final ConfigOption<StateStoreType> STATE_STORE_TYPE =
+            autoscalerStandaloneConfig("state-store.type")
+                    .enumType(StateStoreType.class)
+                    .defaultValue(StateStoreType.MEMORY)
+                    .withDescription("The autoscaler state store type.");

Review Comment:
   We should list the options here.



##########
flink-autoscaler-plugin-jdbc/src/main/java/org/apache/flink/autoscaler/jdbc/state/JobStateView.java:
##########
@@ -0,0 +1,262 @@
+/*
+ * 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.autoscaler.jdbc.state;
+
+import org.apache.flink.annotation.VisibleForTesting;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.NotThreadSafe;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+
+import static org.apache.flink.autoscaler.jdbc.state.JobStateView.State.NEEDS_CREATE;
+import static org.apache.flink.autoscaler.jdbc.state.JobStateView.State.NEEDS_DELETE;
+import static org.apache.flink.autoscaler.jdbc.state.JobStateView.State.NEEDS_UPDATE;
+import static org.apache.flink.autoscaler.jdbc.state.JobStateView.State.NOT_NEEDED;
+import static org.apache.flink.autoscaler.jdbc.state.JobStateView.State.UP_TO_DATE;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/** The view of job state. */
+@NotThreadSafe
+public class JobStateView {
+
+    /**
+     * The state of state type about the cache and database.
+     *
+     * <p>Note: {@link #inLocally} and {@link #inDatabase} are only for understand, we don't use
+     * them.
+     */
+    @SuppressWarnings("unused")
+    enum State {
+
+        /** State doesn't exist at database, and it's not used so far, so it's not needed. */
+        NOT_NEEDED(false, false, false),
+        /** State is only stored locally, not created in JDBC database yet. */
+        NEEDS_CREATE(true, false, true),
+        /** State exists in JDBC database but there are newer local changes. */
+        NEEDS_UPDATE(true, true, true),
+        /** State is stored locally and in database, and they are same. */
+        UP_TO_DATE(true, true, false),
+        /** State is stored in database, but it's deleted in local. */
+        NEEDS_DELETE(false, true, true);

Review Comment:
   This looks conceptually very similar to `ConfigMapView`. I wonder if we could have shared some of that logic.



-- 
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: issues-unsubscribe@flink.apache.org

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