From 374e7e7d073c5a7cedb7ba4aa9a0179eabeb65ce Mon Sep 17 00:00:00 2001 From: guliangliangatpingcap Date: Mon, 23 Sep 2019 10:40:10 +0800 Subject: [PATCH] remove recreate flag when create tisession --- .../main/scala/org/apache/spark/sql/TiContext.scala | 2 +- .../src/main/java/com/pingcap/tikv/TiSession.java | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/sql/TiContext.scala b/core/src/main/scala/org/apache/spark/sql/TiContext.scala index b45bf8d540..4be81bb05e 100644 --- a/core/src/main/scala/org/apache/spark/sql/TiContext.scala +++ b/core/src/main/scala/org/apache/spark/sql/TiContext.scala @@ -43,7 +43,7 @@ class TiContext(val sparkSession: SparkSession, options: Option[TiDBOptions] = N lazy val sqlContext: SQLContext = sparkSession.sqlContext val conf: SparkConf = mergeWithDataSourceConfig(sparkSession.sparkContext.conf, options) val tiConf: TiConfiguration = TiUtil.sparkConfToTiConf(conf) - val tiSession: TiSession = TiSession.getInstance(tiConf, true) + val tiSession: TiSession = TiSession.getInstance(tiConf) val meta: MetaManager = new MetaManager(tiSession.getCatalog) StatisticsManager.initStatisticsManager(tiSession) diff --git a/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java b/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java index 678eff07b3..2efa1a80f3 100644 --- a/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java +++ b/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java @@ -45,10 +45,10 @@ public class TiSession implements AutoCloseable { private static final Map sessionCachedMap = new HashMap<>(); - public static TiSession getInstance(TiConfiguration conf, boolean recreate) { + public static TiSession getInstance(TiConfiguration conf) { synchronized (sessionCachedMap) { String key = conf.getPdAddrsString(); - if (sessionCachedMap.containsKey(key) && !recreate) { + if (sessionCachedMap.containsKey(key)) { return sessionCachedMap.get(key); } @@ -58,12 +58,6 @@ public static TiSession getInstance(TiConfiguration conf, boolean recreate) { } } - // Since we create session as singleton now, configuration change will not - // reflect change - public static TiSession getInstance(TiConfiguration conf) { - return getInstance(conf, false); - } - private TiSession(TiConfiguration conf) { this.conf = conf; this.channelFactory = new ChannelFactory(conf.getMaxFrameSize());