This repository was archived by the owner on Jan 9, 2020. It is now read-only.
forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 117
Extract more of the shuffle management to a different class. #454
Merged
ash211
merged 8 commits into
branch-2.2-kubernetes
from
separate-external-shuffle-management
Sep 7, 2017
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
82bcee6
Extract more of the shuffle management to a different class.
mccheah dd7bb02
Fix scalastyle
mccheah 7a2c3bd
Add override annotation
mccheah b22f241
Fix Java style
mccheah b95f84b
Remove unused imports.
mccheah 7b5b13a
Move volume index to the beginning to satisfy index
mccheah e7a460e
Address PR comments.
mccheah 092053a
Merge remote-tracking branch 'origin/branch-2.2-kubernetes' into sepa…
mccheah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
77 changes: 77 additions & 0 deletions
77
...java/org/apache/spark/network/shuffle/kubernetes/KubernetesExternalShuffleClientImpl.java
This file contains hidden or 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,77 @@ | ||
| /* | ||
| * 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.spark.network.shuffle.kubernetes; | ||
|
|
||
| import org.apache.spark.network.client.RpcResponseCallback; | ||
| import org.apache.spark.network.client.TransportClient; | ||
| import org.apache.spark.network.sasl.SecretKeyHolder; | ||
| import org.apache.spark.network.shuffle.ExternalShuffleClient; | ||
| import org.apache.spark.network.shuffle.protocol.RegisterDriver; | ||
| import org.apache.spark.network.util.TransportConf; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.ByteBuffer; | ||
|
|
||
| /** | ||
| * A client for talking to the external shuffle service in Kubernetes cluster mode. | ||
| * | ||
| * This is used by the each Spark executor to register with a corresponding external | ||
| * shuffle service on the cluster. The purpose is for cleaning up shuffle files | ||
| * reliably if the application exits unexpectedly. | ||
| */ | ||
| public class KubernetesExternalShuffleClientImpl | ||
| extends ExternalShuffleClient implements KubernetesExternalShuffleClient { | ||
|
|
||
| private static final Logger logger = LoggerFactory | ||
| .getLogger(KubernetesExternalShuffleClientImpl.class); | ||
|
|
||
| /** | ||
| * Creates a Kubernetes external shuffle client that wraps the {@link ExternalShuffleClient}. | ||
| * Please refer to docs on {@link ExternalShuffleClient} for more information. | ||
| */ | ||
| public KubernetesExternalShuffleClientImpl( | ||
| TransportConf conf, | ||
| SecretKeyHolder secretKeyHolder, | ||
| boolean saslEnabled) { | ||
| super(conf, secretKeyHolder, saslEnabled); | ||
| } | ||
|
|
||
| @Override | ||
| public void registerDriverWithShuffleService(String host, int port) | ||
| throws IOException, InterruptedException { | ||
| checkInit(); | ||
| ByteBuffer registerDriver = new RegisterDriver(appId, 0).toByteBuffer(); | ||
| TransportClient client = clientFactory.createClient(host, port); | ||
| client.sendRpc(registerDriver, new RegisterDriverCallback()); | ||
| } | ||
|
|
||
| private class RegisterDriverCallback implements RpcResponseCallback { | ||
| @Override | ||
| public void onSuccess(ByteBuffer response) { | ||
| logger.info("Successfully registered app " + appId + " with external shuffle service."); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(Throwable e) { | ||
| logger.warn("Unable to register app " + appId + " with external shuffle service. " + | ||
| "Please manually remove shuffle data after driver exit. Error: " + e); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -26,7 +26,10 @@ import org.apache.spark.deploy.kubernetes.config._ | |
| import org.apache.spark.deploy.kubernetes.constants._ | ||
| import org.apache.spark.deploy.kubernetes.submit.{MountSecretsBootstrapImpl, MountSmallFilesBootstrapImpl} | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.network.netty.SparkTransportConf | ||
| import org.apache.spark.network.shuffle.kubernetes.KubernetesExternalShuffleClientImpl | ||
| import org.apache.spark.scheduler.{ExternalClusterManager, SchedulerBackend, TaskScheduler, TaskSchedulerImpl} | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| private[spark] class KubernetesClusterManager extends ExternalClusterManager with Logging { | ||
|
|
||
|
|
@@ -109,17 +112,31 @@ private[spark] class KubernetesClusterManager extends ExternalClusterManager wit | |
| sparkConf, | ||
| Some(new File(Config.KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH)), | ||
| Some(new File(Config.KUBERNETES_SERVICE_ACCOUNT_CA_CRT_PATH))) | ||
|
|
||
| val kubernetesShuffleManager = if (Utils.isDynamicAllocationEnabled(sparkConf)) { | ||
| val kubernetesExternalShuffleClient = new KubernetesExternalShuffleClientImpl( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this ensure that each executor gets a different instance of the shuffle client?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| SparkTransportConf.fromSparkConf(sparkConf, "shuffle"), | ||
| sc.env.securityManager, | ||
| sc.env.securityManager.isAuthenticationEnabled()) | ||
| Some(new KubernetesExternalShuffleManagerImpl( | ||
| sparkConf, | ||
| kubernetesClient, | ||
| kubernetesExternalShuffleClient)) | ||
| } else None | ||
|
|
||
| val executorPodFactory = new ExecutorPodFactoryImpl( | ||
| sparkConf, | ||
| NodeAffinityExecutorPodModifierImpl, | ||
| mountSecretBootstrap, | ||
| mountSmallFilesBootstrap, | ||
| executorInitContainerBootstrap, | ||
| executorInitContainerSecretVolumePlugin) | ||
| executorInitContainerSecretVolumePlugin, | ||
| kubernetesShuffleManager) | ||
| new KubernetesClusterSchedulerBackend( | ||
| sc.taskScheduler.asInstanceOf[TaskSchedulerImpl], | ||
| sc, | ||
| executorPodFactory, | ||
| kubernetesShuffleManager, | ||
| kubernetesClient) | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to what used to be
KubernetesExternalShuffleClient, with just a rename and an interface extraction. I suppose git doesn't present that in the most intuitive way here.