Skip to content

Commit

Permalink
[INLONG-11629][SDK] Adjust the Sender initialization logic (#11630)
Browse files Browse the repository at this point in the history
Co-authored-by: gosonzhang <gosonzhang@tencent.com>
  • Loading branch information
gosonzhang and gosonzhang authored Jan 2, 2025
1 parent a31b09a commit f0a79bc
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,28 @@ public Sender(ProxyClientConfig configure, ThreadFactory selfDefineFactory) thro
this.asyncCallbackMaxSize = configure.getTotalAsyncCallbackSize();
this.threadPool = Executors.newCachedThreadPool();
this.clientMgr = new ClientMgr(configure, this, selfDefineFactory);
this.scanThread = new TimeoutScanThread(this, configure);
if (configure.isEnableMetric()) {
metricWorker = new MetricWorkerThread(configure, this);
}
logger.info("Sender({}) instance initialized!", this.instanceId);
}

public void start() throws Exception {
if (!started.compareAndSet(false, true)) {
return;
}
this.clientMgr.start();
this.scanThread.start();
ProxyConfigEntry proxyConfigEntry;
try {
proxyConfigEntry = this.clientMgr.getGroupIdConfigure();
setClusterId(proxyConfigEntry.getClusterId());
} catch (Throwable e) {
} catch (Throwable ex) {
if (configure.isOnlyUseLocalProxyConfig()) {
throw new Exception("Get local proxy configure failure!", e.getCause());
throw new Exception("Get local proxy configure failure!", ex);
} else {
throw new Exception("Visit manager error!", e.getCause());
throw new Exception("Visit manager error!", ex);
}
}
if (!proxyConfigEntry.isInterVisit()) {
Expand All @@ -101,19 +114,6 @@ public Sender(ProxyClientConfig configure, ThreadFactory selfDefineFactory) thro
throw new Exception("In OutNetwork isNeedDataEncry must be true!");
}
}
scanThread = new TimeoutScanThread(this, configure);
if (configure.isEnableMetric()) {
metricWorker = new MetricWorkerThread(configure, this);
}
logger.info("Sender({}) instance initialized!", this.instanceId);
}

public void start() {
if (!started.compareAndSet(false, true)) {
return;
}
this.clientMgr.start();
this.scanThread.start();
if (this.configure.isEnableMetric()) {
this.metricWorker.start();
}
Expand Down

0 comments on commit f0a79bc

Please sign in to comment.