Skip to content

Commit

Permalink
Cleanup ReplicationEngine:createThreadPool to avoid hardcoding Vcr
Browse files Browse the repository at this point in the history
  • Loading branch information
parassud committed Mar 6, 2021
1 parent c64e875 commit 44069a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.github.ambry.store.StoreKeyConverterFactory;
import com.github.ambry.store.StoreKeyFactory;
import com.github.ambry.utils.SystemTime;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -271,6 +272,11 @@ public long getRemoteReplicaLagFromLocalInBytes(PartitionId partitionId, String
return -1;
}

@Override
protected String getReplicaThreadName(String datacenterToReplicateFrom, int threadIndexWithinPool) {
return "Vcr" + super.getReplicaThreadName(datacenterToReplicateFrom, threadIndexWithinPool);
}

/**
* Check if replication is allowed from given datacenter.
* @param datacenterName datacenter name to check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ private List<ReplicaThread> createThreadPool(String datacenter, int numberOfThre
ResponseHandler responseHandler = new ResponseHandler(clusterMap);
for (int i = 0; i < numberOfThreads; i++) {
boolean replicatingOverSsl = sslEnabledDatacenters.contains(datacenter);
String threadIdentity =
(startThread ? "Vcr" : "") + "ReplicaThread-" + (dataNodeId.getDatacenterName().equals(datacenter) ? "Intra-"
: "Inter-") + i + "-" + datacenter;
String threadIdentity = getReplicaThreadName(datacenter, i);
try {
StoreKeyConverter threadSpecificKeyConverter = storeKeyConverterFactory.getStoreKeyConverter();
Transformer threadSpecificTransformer =
Expand All @@ -370,6 +368,17 @@ private List<ReplicaThread> createThreadPool(String datacenter, int numberOfThre
return replicaThreads;
}

/**
* Chooses a name for a new replica thread.
* @param datacenterToReplicateFrom The datacenter that we replicate from in this thread.
* @param threadIndexWithinPool The index of the thread within the thread pool.
* @return The name of the thread.
*/
protected String getReplicaThreadName(String datacenterToReplicateFrom, int threadIndexWithinPool) {
return "ReplicaThread-" + (dataNodeId.getDatacenterName().equals(datacenterToReplicateFrom) ? "Intra-"
: "Inter-") + threadIndexWithinPool + "-" + datacenterToReplicateFrom;
}

/**
* Reads the replica tokens from storage, populates the Remote replica info,
* and re-persists the tokens if they have been reset.
Expand Down

0 comments on commit 44069a7

Please sign in to comment.