@@ -360,19 +360,28 @@ private long getStartOffset(String walGroupId) {
360
360
}
361
361
}
362
362
363
+ protected final ReplicationSourceShipper createNewShipper (String walGroupId ) {
364
+ ReplicationSourceWALReader walReader =
365
+ createNewWALReader (walGroupId , getStartOffset (walGroupId ));
366
+ ReplicationSourceShipper worker = createNewShipper (walGroupId , walReader );
367
+ Threads .setDaemonThreadRunning (walReader , Thread .currentThread ().getName ()
368
+ + ".replicationSource.wal-reader." + walGroupId + "," + queueId , this ::retryRefreshing );
369
+ return worker ;
370
+ }
371
+
372
+ protected final void startShipper (ReplicationSourceShipper worker ) {
373
+ worker .startup (this ::retryRefreshing );
374
+ }
375
+
363
376
private void tryStartNewShipper (String walGroupId ) {
364
377
workerThreads .compute (walGroupId , (key , value ) -> {
365
378
if (value != null ) {
366
379
LOG .debug ("{} preempted start of shipping worker walGroupId={}" , logPeerId (), walGroupId );
367
380
return value ;
368
381
} else {
369
382
LOG .debug ("{} starting shipping worker for walGroupId={}" , logPeerId (), walGroupId );
370
- ReplicationSourceWALReader walReader =
371
- createNewWALReader (walGroupId , getStartOffset (walGroupId ));
372
- ReplicationSourceShipper worker = createNewShipper (walGroupId , walReader );
373
- Threads .setDaemonThreadRunning (walReader , Thread .currentThread ().getName ()
374
- + ".replicationSource.wal-reader." + walGroupId + "," + queueId , this ::retryRefreshing );
375
- worker .startup (this ::retryRefreshing );
383
+ ReplicationSourceShipper worker = createNewShipper (walGroupId );
384
+ startShipper (worker );
376
385
return worker ;
377
386
}
378
387
});
@@ -522,7 +531,7 @@ private long getCurrentBandwidth() {
522
531
* @param sleepMultiplier by how many times the default sleeping time is augmented
523
532
* @return True if <code>sleepMultiplier</code> is < <code>maxRetriesMultiplier</code>
524
533
*/
525
- protected boolean sleepForRetries (String msg , int sleepMultiplier ) {
534
+ private boolean sleepForRetries (String msg , int sleepMultiplier ) {
526
535
try {
527
536
if (LOG .isTraceEnabled ()) {
528
537
LOG .trace ("{} {}, sleeping {} times {}" , logPeerId (), msg , sleepForRetries ,
@@ -605,10 +614,14 @@ private void initialize() {
605
614
queueId , logQueue .getNumQueues (), clusterId , peerClusterId );
606
615
initializeWALEntryFilter (peerClusterId );
607
616
// Start workers
617
+ startShippers ();
618
+ setSourceStartupStatus (false );
619
+ }
620
+
621
+ protected void startShippers () {
608
622
for (String walGroupId : logQueue .getQueues ().keySet ()) {
609
623
tryStartNewShipper (walGroupId );
610
624
}
611
- setSourceStartupStatus (false );
612
625
}
613
626
614
627
private synchronized void setSourceStartupStatus (boolean initializing ) {
0 commit comments