forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-17075][coordination] Reconcile deployed Executions
- Loading branch information
Showing
34 changed files
with
1,360 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...me/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionDeploymentListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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:https://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.executiongraph; | ||
|
||
import org.apache.flink.runtime.clusterframework.types.ResourceID; | ||
|
||
/** | ||
* A listener that is called when an execution has been deployed. | ||
*/ | ||
public interface ExecutionDeploymentListener { | ||
void onCompletedDeployment(ExecutionAttemptID execution, ResourceID host); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...e/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionStateUpdateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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:https://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.executiongraph; | ||
|
||
import org.apache.flink.runtime.execution.ExecutionState; | ||
|
||
/** | ||
* A listener that is called when an execution switched to a new state. | ||
*/ | ||
public interface ExecutionStateUpdateListener { | ||
void onStateUpdate(ExecutionAttemptID execution, ExecutionState newState); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...rc/main/java/org/apache/flink/runtime/jobmaster/DefaultExecutionDeploymentReconciler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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:https://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.jobmaster; | ||
|
||
import org.apache.flink.runtime.clusterframework.types.ResourceID; | ||
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID; | ||
import org.apache.flink.runtime.taskexecutor.ExecutionDeploymentReport; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Default {@link ExecutionDeploymentReconciler} implementation. Detects missing/unknown deployments, and defers | ||
* to a provided {@link ExecutionDeploymentReconciliationHandler} to resolve them. | ||
*/ | ||
public class DefaultExecutionDeploymentReconciler implements ExecutionDeploymentReconciler { | ||
|
||
private final ExecutionDeploymentReconciliationHandler handler; | ||
|
||
public DefaultExecutionDeploymentReconciler(ExecutionDeploymentReconciliationHandler handler) { | ||
this.handler = handler; | ||
} | ||
|
||
@Override | ||
public void reconcileExecutionDeployments(ResourceID taskExecutorHost, ExecutionDeploymentReport executionDeploymentReport, Set<ExecutionAttemptID> expectedDeployedExecutions) { | ||
final Set<ExecutionAttemptID> unknownExecutions = new HashSet<>(); | ||
final Set<ExecutionAttemptID> expectedExecutions = new HashSet<>(expectedDeployedExecutions); | ||
|
||
for (ExecutionAttemptID executionAttemptID : executionDeploymentReport.getExecutions()) { | ||
boolean isTracked = expectedExecutions.remove(executionAttemptID); | ||
if (!isTracked) { | ||
unknownExecutions.add(executionAttemptID); | ||
} | ||
} | ||
if (!unknownExecutions.isEmpty()) { | ||
handler.onUnknownDeploymentsOf(unknownExecutions, taskExecutorHost); | ||
} | ||
if (!expectedExecutions.isEmpty()) { | ||
handler.onMissingDeploymentsOf(expectedExecutions, taskExecutorHost); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...e/src/main/java/org/apache/flink/runtime/jobmaster/DefaultExecutionDeploymentTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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:https://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.jobmaster; | ||
|
||
import org.apache.flink.runtime.clusterframework.types.ResourceID; | ||
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* Default {@link ExecutionDeploymentTracker} implementation. | ||
*/ | ||
public class DefaultExecutionDeploymentTracker implements ExecutionDeploymentTracker { | ||
|
||
private final Map<ResourceID, Set<ExecutionAttemptID>> executionsByHost = new HashMap<>(); | ||
private final Map<ExecutionAttemptID, ResourceID> hostByExecution = new HashMap<>(); | ||
|
||
@Override | ||
public void startTrackingDeploymentOf(ExecutionAttemptID executionAttemptId, ResourceID host) { | ||
hostByExecution.put(executionAttemptId, host); | ||
executionsByHost.computeIfAbsent(host, ignored -> new HashSet<>()).add(executionAttemptId); | ||
} | ||
|
||
@Override | ||
public void stopTrackingDeploymentOf(ExecutionAttemptID executionAttemptId) { | ||
ResourceID host = hostByExecution.remove(executionAttemptId); | ||
if (host != null) { | ||
executionsByHost.computeIfPresent(host, (resourceID, executionAttemptIds) -> { | ||
executionAttemptIds.remove(executionAttemptId); | ||
|
||
return executionAttemptIds.isEmpty() | ||
? null | ||
: executionAttemptIds; | ||
}); | ||
} | ||
} | ||
|
||
@Override | ||
public Set<ExecutionAttemptID> getExecutionsOn(ResourceID host) { | ||
return executionsByHost.getOrDefault(host, Collections.emptySet()); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ntime/src/main/java/org/apache/flink/runtime/jobmaster/ExecutionDeploymentReconciler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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:https://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.jobmaster; | ||
|
||
import org.apache.flink.runtime.clusterframework.types.ResourceID; | ||
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID; | ||
import org.apache.flink.runtime.taskexecutor.ExecutionDeploymentReport; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Component for reconciling the deployment state of executions. | ||
*/ | ||
public interface ExecutionDeploymentReconciler { | ||
|
||
/** | ||
* Factory for {@link ExecutionDeploymentReconciler}. | ||
*/ | ||
interface Factory { | ||
ExecutionDeploymentReconciler create(ExecutionDeploymentReconciliationHandler reconciliationHandler); | ||
} | ||
|
||
/** | ||
* Reconciles the deployment states between all reported/expected executions for the given task executor. | ||
* | ||
* @param taskExecutorHost hosting task executor | ||
* @param executionDeploymentReport task executor report for deployed executions | ||
* @param expectedDeployedExecutionIds set of expected deployed executions | ||
*/ | ||
void reconcileExecutionDeployments(ResourceID taskExecutorHost, ExecutionDeploymentReport executionDeploymentReport, Set<ExecutionAttemptID> expectedDeployedExecutionIds); | ||
|
||
} |
Oops, something went wrong.