org.apache.flink.runtime.healthmanager.plugins.resolvers.PlanResumeResolver Maven / Gradle / Ivy
/*
* 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.healthmanager.plugins.resolvers;
import org.apache.flink.runtime.healthmanager.HealthMonitor;
import org.apache.flink.runtime.healthmanager.RestServerClient;
import org.apache.flink.runtime.healthmanager.plugins.Resolver;
import org.apache.flink.runtime.healthmanager.plugins.Symptom;
import org.apache.flink.runtime.healthmanager.plugins.actions.AdjustJobConfig;
import org.apache.flink.runtime.healthmanager.plugins.symptoms.PlanChanged;
import org.apache.flink.runtime.jobgraph.JobVertexID;
import java.util.List;
import java.util.Map;
/**
* Plan resume resolver.
*/
public class PlanResumeResolver implements Resolver {
private HealthMonitor monitor;
@Override
public void open(HealthMonitor monitor) {
this.monitor = monitor;
}
@Override
public void close() {
}
@Override
public AdjustJobConfig resolve(List symptomList) {
PlanChanged signal = null;
for (Symptom symptom : symptomList) {
if (symptom instanceof PlanChanged) {
signal = (PlanChanged) symptom;
break;
}
}
if (signal != null) {
AdjustJobConfig adjustJobConfig = new AdjustJobConfig(monitor.getJobID(), -1);
for (Map.Entry entry : monitor.getJobConfig().getVertexConfigs().entrySet()) {
RestServerClient.VertexConfig targetConfig = signal.getTargetConfig().getVertexConfigs().get(entry.getKey());
adjustJobConfig.addVertex(
entry.getKey(), entry.getValue().getParallelism(), targetConfig.getParallelism(), entry.getValue().getResourceSpec(), targetConfig.getResourceSpec());
}
return adjustJobConfig;
}
return null;
}
}