kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject kudu git commit: [spark] Remove syncCache in KuduConnection
Date Tue, 21 Nov 2017 21:08:31 GMT
Repository: kudu
Updated Branches:
  refs/heads/master f0d52ab64 -> 48eab213c


[spark] Remove syncCache in KuduConnection

This patch removes syncCache in KuduConnection and uses the same
AsyncKyduClient instance for both syncClient and asyncClient in
KuduContext to avoid misuse.

Change-Id: Ica8745d8503a35e17a632d0a0cde5738915f00fb
Reviewed-on: http://gerrit.cloudera.org:8080/8551
Reviewed-by: Dan Burkert <danburkert@apache.org>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/48eab213
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/48eab213
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/48eab213

Branch: refs/heads/master
Commit: 48eab213ca9014f445e41ee7d9d8b5b43aff8f42
Parents: f0d52ab
Author: hahao <hao.hao@cloudera.com>
Authored: Tue Nov 21 11:52:58 2017 -0800
Committer: Dan Burkert <danburkert@apache.org>
Committed: Tue Nov 21 21:08:18 2017 +0000

----------------------------------------------------------------------
 .../apache/kudu/spark/kudu/KuduContext.scala    | 22 +-------------------
 .../kudu/spark/kudu/KuduContextTest.scala       |  1 -
 2 files changed, 1 insertion(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/48eab213/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
index 71eb6e8..6961430 100644
--- a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
+++ b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
@@ -55,13 +55,7 @@ class KuduContext(val kuduMaster: String,
     this(kuduMaster, new SparkContext())
   }
 
-  @transient lazy val syncClient: KuduClient = {
-    val c = KuduConnection.getSyncClient(kuduMaster)
-    if (authnCredentials != null) {
-      c.importAuthenticationCredentials(authnCredentials)
-    }
-    c
-  }
+  @transient lazy val syncClient: KuduClient = asyncClient.syncClient()
 
   @transient lazy val asyncClient: AsyncKuduClient = {
     val c = KuduConnection.getAsyncClient(kuduMaster)
@@ -308,7 +302,6 @@ private object KuduContext {
 }
 
 private object KuduConnection {
-  private[kudu] val syncCache = new mutable.HashMap[String, KuduClient]()
   private[kudu] val asyncCache = new mutable.HashMap[String, AsyncKuduClient]()
 
   /**
@@ -320,19 +313,6 @@ private object KuduConnection {
     */
   private val ShutdownHookPriority = 100
 
-  def getSyncClient(kuduMaster: String): KuduClient = {
-    syncCache.synchronized {
-      if (!syncCache.contains(kuduMaster)) {
-        val syncClient = new KuduClient.KuduClientBuilder(kuduMaster).build()
-        ShutdownHookManager.get().addShutdownHook(new Runnable {
-          override def run(): Unit = syncClient.close()
-        }, ShutdownHookPriority)
-        syncCache.put(kuduMaster, syncClient)
-      }
-      return syncCache(kuduMaster)
-    }
-  }
-
   def getAsyncClient(kuduMaster: String): AsyncKuduClient = {
     asyncCache.synchronized {
       if (!asyncCache.contains(kuduMaster)) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/48eab213/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
b/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
index 620cf3f..8156365 100644
--- a/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
+++ b/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
@@ -50,7 +50,6 @@ class KuduContextTest extends FunSuite with TestContext with Matchers {
 
   test("Test KuduContext serialization") {
     val serialized = serialize(kuduContext)
-    KuduConnection.syncCache.clear()
     KuduConnection.asyncCache.clear()
     val deserialized = deserialize(serialized).asInstanceOf[KuduContext]
     assert(deserialized.authnCredentials != null)


Mime
View raw message