StefanRRichter commented on code in PR #24023: URL: https://github.com/apache/flink/pull/24023#discussion_r1440607428
########## flink-runtime/src/main/java/org/apache/flink/runtime/state/KeyedStateBackendParametersImpl.java: ########## @@ -0,0 +1,151 @@ +/* + * 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.runtime.state; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.JobID; +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.core.fs.CloseableRegistry; +import org.apache.flink.metrics.MetricGroup; +import org.apache.flink.runtime.execution.Environment; +import org.apache.flink.runtime.query.TaskKvStateRegistry; +import org.apache.flink.runtime.state.StateBackend.CustomInitializationMetrics; +import org.apache.flink.runtime.state.StateBackend.KeyedStateBackendParameters; +import org.apache.flink.runtime.state.ttl.TtlTimeProvider; + +import javax.annotation.Nonnull; + +import java.util.Collection; + +/** + * Internal POJO implementing {@link KeyedStateBackendParameters} + * + * @param <K> + */ +@Internal +public class KeyedStateBackendParametersImpl<K> implements KeyedStateBackendParameters<K> { Review Comment: What's the reason to have an interface for this class? It looks like a simple POJO that gives more meaning to a bunch of parameters. And there is only one impl. ########## flink-runtime/src/main/java/org/apache/flink/runtime/state/StateBackend.java: ########## @@ -201,4 +278,75 @@ default boolean supportsNoClaimRestoreMode() { default boolean supportsSavepointFormat(SavepointFormatType formatType) { return formatType == SavepointFormatType.CANONICAL; } + + /** + * Parameters passed to {@link + * StateBackend#createKeyedStateBackend(KeyedStateBackendParameters)}. + * + * @param <K> The type of the keys by which the state is organized. + */ + @PublicEvolving + interface KeyedStateBackendParameters<K> { + /** @return The runtime environment of the executing task. */ + Environment getEnv(); + + JobID getJobID(); + + String getOperatorIdentifier(); + + TypeSerializer<K> getKeySerializer(); + + int getNumberOfKeyGroups(); + + /** @return Range of key-groups for which the to-be-created backend is responsible. */ + KeyGroupRange getKeyGroupRange(); + + TaskKvStateRegistry getKvStateRegistry(); + + /** @return Provider for TTL logic to judge about state expiration. */ + TtlTimeProvider getTtlTimeProvider(); + + MetricGroup getMetricGroup(); + + @Nonnull + Collection<KeyedStateHandle> getStateHandles(); + + /** + * @return The registry to which created closeable objects will be * registered during + * restore. + */ + CloseableRegistry getCancelStreamRegistry(); + + double getManagedMemoryFraction(); + + CustomInitializationMetrics getCustomInitializationMetrics(); + } + + /** + * Parameters passed to {@link + * StateBackend#createOperatorStateBackend(OperatorStateBackendParameters)}. + */ + @PublicEvolving + interface OperatorStateBackendParameters { + /** @return The runtime environment of the executing task. */ + Environment getEnv(); Review Comment: As said in a previous comment, not a fan of the extra interfaces, I'd simple turn them into classes. And then they could have a common superclass of env, operator id, etc. -- 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]
