-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial refactoring to move ConnectionManager to use the BlockTransfe…
…rService.
- Loading branch information
Showing
33 changed files
with
784 additions
and
859 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
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
37 changes: 37 additions & 0 deletions
37
core/src/main/scala/org/apache/spark/network/BlockFetchingListener.scala
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,37 @@ | ||
/* | ||
* 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 | ||
|
||
import java.util.EventListener | ||
|
||
|
||
/** | ||
* Listener callback interface for [[BlockTransferService.fetchBlocks]]. | ||
*/ | ||
trait BlockFetchingListener extends EventListener { | ||
|
||
/** | ||
* Called once per successfully fetched block. | ||
*/ | ||
def onBlockFetchSuccess(blockId: String, data: ManagedBuffer): Unit | ||
|
||
/** | ||
* Called upon failures. | ||
*/ | ||
def onBlockFetchFailure(exception: Exception): Unit | ||
} |
81 changes: 81 additions & 0 deletions
81
core/src/main/scala/org/apache/spark/network/BlockTransferService.scala
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,81 @@ | ||
/* | ||
* 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 | ||
|
||
import org.apache.spark.storage.StorageLevel | ||
|
||
|
||
abstract class BlockTransferService { | ||
|
||
/** | ||
* Initialize the transfer service by giving it the BlockDataManager that can be used to fetch | ||
* local blocks or put local blocks. | ||
*/ | ||
def init(blockDataManager: BlockDataManager) | ||
|
||
/** | ||
* Tear down the transfer service. | ||
*/ | ||
def stop(): Unit | ||
|
||
/** | ||
* Port number the service is listening on, available only after [[init]] is invoked. | ||
*/ | ||
def port: Int | ||
|
||
/** | ||
* Host name the service is listening on, available only after [[init]] is invoked. | ||
*/ | ||
def hostName: String | ||
|
||
/** | ||
* Fetch a sequence of blocks from a remote node, available only after [[init]] is invoked. | ||
* | ||
* This takes a sequence so the implementation can batch requests. | ||
*/ | ||
def fetchBlocks( | ||
hostName: String, | ||
port: Int, | ||
blockIds: Seq[String], | ||
listener: BlockFetchingListener): Unit | ||
|
||
/** | ||
* Fetch a single block from a remote node, available only after [[init]] is invoked. | ||
* | ||
* This is functionally equivalent to | ||
* {{{ | ||
* fetchBlocks(hostName, port, Seq(blockId)).iterator().next()._2 | ||
* }}} | ||
*/ | ||
def fetchBlock(hostName: String, port: Int, blockId: String): ManagedBuffer = { | ||
//fetchBlocks(hostName, port, Seq(blockId)).iterator().next()._2 | ||
null | ||
} | ||
|
||
/** | ||
* Upload a single block to a remote node, available only after [[init]] is invoked. | ||
* | ||
* This call blocks until the upload completes, or throws an exception upon failures. | ||
*/ | ||
def uploadBlock( | ||
hostname: String, | ||
port: Int, | ||
blockId: String, | ||
blockData: ManagedBuffer, | ||
level: StorageLevel): Unit | ||
} |
103 changes: 0 additions & 103 deletions
103
core/src/main/scala/org/apache/spark/network/ConnectionManagerTest.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.