tillrohrmann commented on a change in pull request #6876: [FLINK-10251] Handle oversized response messages in AkkaRpcActor URL: https://github.com/apache/flink/pull/6876#discussion_r246339486
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceConfiguration.java ########## @@ -0,0 +1,71 @@ +/* + * 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.rpc.akka; + +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.configuration.AkkaOptions; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.runtime.akka.AkkaUtils; +import scala.concurrent.duration.FiniteDuration; + +/** + * Configuration object for {@link AkkaRpcService}. + */ +public class AkkaRpcServiceConfiguration { + + private static final String SIMPLE_AKKA_CONFIG_TEMPLATE = + "akka {remote {netty.tcp {maximum-frame-size = %s}}}"; + + private static final String MAXIMUM_FRAME_SIZE_PATH = + "akka.remote.netty.tcp.maximum-frame-size"; + + private final Time timeout; + private final long maximumFramesize; + + public AkkaRpcServiceConfiguration(Time timeout, long maximumFramesize) { + this.timeout = timeout; + this.maximumFramesize = maximumFramesize; + } + + public Time getTimeout() { + return timeout; + } + + public long getMaximumFramesize() { + return maximumFramesize; + } + + public static AkkaRpcServiceConfiguration fromConfiguration(Configuration configuration) { + FiniteDuration duration = AkkaUtils.getTimeout(configuration); + Time timeout = Time.of(duration.length(), duration.unit()); + + String maxFrameSizeStr = configuration.getString(AkkaOptions.FRAMESIZE); + String akkaConfigStr = String.format(SIMPLE_AKKA_CONFIG_TEMPLATE, maxFrameSizeStr); + Config akkaConfig = ConfigFactory.parseString(akkaConfigStr); + long maximumFramesize = akkaConfig.getBytes(MAXIMUM_FRAME_SIZE_PATH); Review comment: Alright, we do this because of the size specifier. I think we should add a method to `AkkaRpcServiceUtils` which does the extraction because we also use it in the `AkkaRpcService`. That way we can reduce a bit of code deduplication. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
