You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2020/04/14 10:14:12 UTC
[flink] 03/04: [FLINK-14504][runtime] Introduce
ClusterPartitionManager interface
This is an automated email from the ASF dual-hosted git repository.
chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit fbefc4a8f815533286704e0e8cd8ac593051d859
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Thu Apr 2 13:29:15 2020 +0200
[FLINK-14504][runtime] Introduce ClusterPartitionManager interface
---
.../network/partition/ClusterPartitionManager.java | 44 ++++++++++++++++++++++
.../runtime/resourcemanager/ResourceManager.java | 12 ++++++
.../resourcemanager/ResourceManagerGateway.java | 3 +-
.../utils/TestingResourceManagerGateway.java | 13 +++++++
4 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ClusterPartitionManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ClusterPartitionManager.java
new file mode 100644
index 0000000..6290b4f
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ClusterPartitionManager.java
@@ -0,0 +1,44 @@
+/*
+ * 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.io.network.partition;
+
+import org.apache.flink.runtime.jobgraph.IntermediateDataSetID;
+
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Interface for components that manage cluster partitions.
+ */
+public interface ClusterPartitionManager {
+
+ /**
+ * Returns all datasets for which partitions are being tracked.
+ *
+ * @return tracked datasets
+ */
+ CompletableFuture<Map<IntermediateDataSetID, DataSetMetaInfo>> listDataSets();
+
+ /**
+ * Releases all partitions associated with the given dataset.
+ *
+ * @param dataSetToRelease dataset for which all associated partitions should be released
+ * @return future that is completed once all partitions have been released
+ */
+ CompletableFuture<Void> releaseClusterPartitions(IntermediateDataSetID dataSetToRelease);
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
index 00f7c49..60a8540 100755
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
@@ -38,8 +38,10 @@ import org.apache.flink.runtime.heartbeat.HeartbeatTarget;
import org.apache.flink.runtime.heartbeat.NoOpHeartbeatManager;
import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
import org.apache.flink.runtime.instance.InstanceID;
+import org.apache.flink.runtime.io.network.partition.DataSetMetaInfo;
import org.apache.flink.runtime.io.network.partition.ResourceManagerPartitionTracker;
import org.apache.flink.runtime.io.network.partition.ResourceManagerPartitionTrackerFactory;
+import org.apache.flink.runtime.jobgraph.IntermediateDataSetID;
import org.apache.flink.runtime.jobmaster.JobMaster;
import org.apache.flink.runtime.jobmaster.JobMasterGateway;
import org.apache.flink.runtime.jobmaster.JobMasterId;
@@ -637,6 +639,16 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
}
}
+ @Override
+ public CompletableFuture<Void> releaseClusterPartitions(IntermediateDataSetID dataSetId) {
+ return clusterPartitionTracker.releaseClusterPartitions(dataSetId);
+ }
+
+ @Override
+ public CompletableFuture<Map<IntermediateDataSetID, DataSetMetaInfo>> listDataSets() {
+ return CompletableFuture.completedFuture(clusterPartitionTracker.listDataSets());
+ }
+
// ------------------------------------------------------------------------
// Internal methods
// ------------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
index 83db17b..f3af8cb 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
@@ -28,6 +28,7 @@ import org.apache.flink.runtime.clusterframework.types.AllocationID;
import org.apache.flink.runtime.clusterframework.types.ResourceID;
import org.apache.flink.runtime.clusterframework.types.SlotID;
import org.apache.flink.runtime.instance.InstanceID;
+import org.apache.flink.runtime.io.network.partition.ClusterPartitionManager;
import org.apache.flink.runtime.jobmaster.JobMaster;
import org.apache.flink.runtime.jobmaster.JobMasterId;
import org.apache.flink.runtime.messages.Acknowledge;
@@ -50,7 +51,7 @@ import java.util.concurrent.CompletableFuture;
/**
* The {@link ResourceManager}'s RPC gateway interface.
*/
-public interface ResourceManagerGateway extends FencedRpcGateway<ResourceManagerId> {
+public interface ResourceManagerGateway extends FencedRpcGateway<ResourceManagerId>, ClusterPartitionManager {
/**
* Register a {@link JobMaster} at the resource manager.
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
index ce5b1cd..da56fa4 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
@@ -31,6 +31,8 @@ import org.apache.flink.runtime.clusterframework.types.SlotID;
import org.apache.flink.runtime.concurrent.FutureUtils;
import org.apache.flink.runtime.entrypoint.ClusterInformation;
import org.apache.flink.runtime.instance.InstanceID;
+import org.apache.flink.runtime.io.network.partition.DataSetMetaInfo;
+import org.apache.flink.runtime.jobgraph.IntermediateDataSetID;
import org.apache.flink.runtime.jobmaster.JobMasterId;
import org.apache.flink.runtime.jobmaster.JobMasterRegistrationSuccess;
import org.apache.flink.runtime.messages.Acknowledge;
@@ -51,6 +53,7 @@ import org.apache.flink.util.Preconditions;
import java.util.Collection;
import java.util.Collections;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
@@ -358,4 +361,14 @@ public class TestingResourceManagerGateway implements ResourceManagerGateway {
public String getHostname() {
return hostname;
}
+
+ @Override
+ public CompletableFuture<Map<IntermediateDataSetID, DataSetMetaInfo>> listDataSets() {
+ return CompletableFuture.completedFuture(Collections.emptyMap());
+ }
+
+ @Override
+ public CompletableFuture<Void> releaseClusterPartitions(IntermediateDataSetID dataSetToRelease) {
+ return CompletableFuture.completedFuture(null);
+ }
}