1996fanrui commented on code in PR #698: URL: https://github.com/apache/flink-kubernetes-operator/pull/698#discussion_r1377499265
########## flink-autoscaler/src/main/java/org/apache/flink/autoscaler/standalone/flinkcluster/FlinkClusterJobListFetcher.java: ########## @@ -0,0 +1,109 @@ +/* + * 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.standalone.flinkcluster; + +import org.apache.flink.api.common.JobID; +import org.apache.flink.autoscaler.JobAutoScalerContext; +import org.apache.flink.autoscaler.standalone.JobListFetcher; +import org.apache.flink.client.program.rest.RestClusterClient; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.metrics.MetricGroup; +import org.apache.flink.runtime.client.JobStatusMessage; +import org.apache.flink.runtime.highavailability.nonha.standalone.StandaloneClientHAServices; +import org.apache.flink.runtime.rest.messages.ConfigurationInfo; +import org.apache.flink.runtime.rest.messages.EmptyRequestBody; +import org.apache.flink.runtime.rest.messages.JobMessageParameters; +import org.apache.flink.runtime.rest.messages.job.JobManagerJobConfigurationHeaders; + +import java.time.Duration; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** Fetch JobAutoScalerContext based on flink cluster. */ +public class FlinkClusterJobListFetcher implements JobListFetcher<JobID> { + + private final String restServerAddress; + private final Duration restClientTimeout; + + public FlinkClusterJobListFetcher(String host, int port, Duration restClientTimeout) { + this.restServerAddress = String.format("http://%s:%s", host, port); + this.restClientTimeout = restClientTimeout; + } + + @Override + public List<JobAutoScalerContext<JobID>> fetch(MetricGroup metricGroup) throws Exception { Review Comment: Good catch! It can be simply, it can be passed to `FlinkClusterJobListFetcher` by the constructor directly. Also, I don't pass it in this PR, and `new UnregisteredMetricsGroup()` directly when creating the `JobAutoScalerContext`, because we don't support metric reporter for Standalone Autoscaler so far. -- 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]
