Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove recreate flag when creating TiSession #1116

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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