Skip to content

Commit

Permalink
Remove recreate flag when create tisession (pingcap#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
guliangliangatpingcap authored Sep 23, 2019
1 parent 5b13cc3 commit 23b6c55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/org/apache/spark/sql/TiContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions tikv-client/src/main/java/com/pingcap/tikv/TiSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public class TiSession implements AutoCloseable {

private static final Map<String, TiSession> 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);
}

Expand All @@ -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());
Expand Down

0 comments on commit 23b6c55

Please sign in to comment.