|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
1 | 18 | package org.apache.flink.autoscaler; |
2 | 19 |
|
3 | 20 | import org.apache.flink.autoscaler.config.AutoScalerOptions; |
@@ -34,23 +51,16 @@ public static <KEY, Context extends JobAutoScalerContext<KEY>> int adjust( |
34 | 51 | context.getConfiguration() |
35 | 52 | .get(AutoScalerOptions.SCALING_KEY_GROUP_PARTITIONS_ADJUST_MODE); |
36 | 53 |
|
37 | | - var upperBoundForAlignment = |
38 | | - Math.min( |
39 | | - // Optimize the case where newParallelism <= maxParallelism / 2 |
40 | | - newParallelism > numKeyGroupsOrPartitions / 2 |
41 | | - ? numKeyGroupsOrPartitions |
42 | | - : numKeyGroupsOrPartitions / 2 + numKeyGroupsOrPartitions % 2, |
43 | | - upperBound); |
| 54 | + var upperBoundForAlignment = Math.min(numKeyGroupsOrPartitions, upperBound); |
44 | 55 |
|
45 | 56 | // When the shuffle type of vertex inputs contains keyBy or vertex is a source, |
46 | 57 | // we try to adjust the parallelism such that it divides |
47 | 58 | // the numKeyGroupsOrPartitions without a remainder => data is evenly spread across subtasks |
48 | 59 | for (int p = newParallelism; p <= upperBoundForAlignment; p++) { |
49 | 60 | if (numKeyGroupsOrPartitions % p == 0 |
50 | 61 | || |
51 | | - // When MAXIMIZE_UTILISATION is enabled, Try to find the smallest parallelism |
52 | | - // that |
53 | | - // can satisfy the current consumption rate. |
| 62 | + // When Mode is MAXIMIZE_UTILISATION , Try to find the smallest parallelism |
| 63 | + // that can satisfy the current consumption rate. |
54 | 64 | (mode == Mode.MAXIMIZE_UTILISATION |
55 | 65 | && numKeyGroupsOrPartitions / p |
56 | 66 | < numKeyGroupsOrPartitions / newParallelism)) { |
|
0 commit comments