forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For SPARK-1082, Use Curator for ZK interaction in standalone cluster
Author: Raymond Liu <raymond.liu@intel.com> Closes apache#611 from colorant/curator and squashes the following commits: 7556aa1 [Raymond Liu] Address review comments af92e1f [Raymond Liu] Fix coding style 964f3c2 [Raymond Liu] Ignore NodeExists exception 6df2966 [Raymond Liu] Rewrite zookeeper client code with curator
- Loading branch information
Showing
9 changed files
with
99 additions
and
300 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
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
53 changes: 53 additions & 0 deletions
53
core/src/main/scala/org/apache/spark/deploy/master/SparkCuratorUtil.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,53 @@ | ||
/* | ||
* 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.deploy.master | ||
|
||
import org.apache.spark.{SparkConf, Logging} | ||
import org.apache.curator.framework.{CuratorFramework, CuratorFrameworkFactory} | ||
import org.apache.curator.retry.ExponentialBackoffRetry | ||
import org.apache.zookeeper.KeeperException | ||
|
||
|
||
object SparkCuratorUtil extends Logging { | ||
|
||
val ZK_CONNECTION_TIMEOUT_MILLIS = 15000 | ||
val ZK_SESSION_TIMEOUT_MILLIS = 60000 | ||
val RETRY_WAIT_MILLIS = 5000 | ||
val MAX_RECONNECT_ATTEMPTS = 3 | ||
|
||
def newClient(conf: SparkConf): CuratorFramework = { | ||
val ZK_URL = conf.get("spark.deploy.zookeeper.url") | ||
val zk = CuratorFrameworkFactory.newClient(ZK_URL, | ||
ZK_SESSION_TIMEOUT_MILLIS, ZK_CONNECTION_TIMEOUT_MILLIS, | ||
new ExponentialBackoffRetry(RETRY_WAIT_MILLIS, MAX_RECONNECT_ATTEMPTS)) | ||
zk.start() | ||
zk | ||
} | ||
|
||
def mkdir(zk: CuratorFramework, path: String) { | ||
if (zk.checkExists().forPath(path) == null) { | ||
try { | ||
zk.create().creatingParentsIfNeeded().forPath(path) | ||
} catch { | ||
case nodeExist: KeeperException.NodeExistsException => | ||
// do nothing, ignore node existing exception. | ||
case e: Exception => throw e | ||
} | ||
} | ||
} | ||
} |
205 changes: 0 additions & 205 deletions
205
core/src/main/scala/org/apache/spark/deploy/master/SparkZooKeeperSession.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.