Skip to content

Commit

Permalink
[CARBONDATA-3142]Add timestamp with thread name which created by Carb…
Browse files Browse the repository at this point in the history
…onThreadFactory

Add timestamp with thread name which created by CarbonThreadFactory
Because the names of threads created by CarbonThreadFactory are all the same, such as ProducerPool_, this logs are confused, we can't distinguish threads in the thread pool

This closes #2970
  • Loading branch information
qiuchenjian authored and jackylk committed Dec 27, 2018
1 parent 128a6c8 commit 04b5256
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,25 @@ public class CarbonThreadFactory implements ThreadFactory {
*/
private String name;

private boolean withTime = false;

public CarbonThreadFactory(String name) {
this.defaultFactory = Executors.defaultThreadFactory();
this.name = name;
}

public CarbonThreadFactory(String name, boolean withTime) {
this(name);
this.withTime = withTime;
}

@Override public Thread newThread(Runnable r) {
final Thread thread = defaultFactory.newThread(r);
thread.setName(name);
if (withTime) {
thread.setName(name + "_" + System.currentTimeMillis());
} else {
thread.setName(name);
}
return thread;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ private void initParameters(CarbonFactDataHandlerModel model) {
blockletProcessingCount = new AtomicInteger(0);
producerExecutorService = Executors.newFixedThreadPool(model.getNumberOfCores(),
new CarbonThreadFactory(
"ProducerPool_" + System.nanoTime() + ":" + model.getTableName() + ", range: " + model
.getBucketId()));
String.format("ProducerPool:%s, range: %d",
model.getTableName(),model.getBucketId()), true));
producerExecutorServiceTaskList =
new ArrayList<>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
LOGGER.debug("Initializing writer executors");
consumerExecutorService = Executors.newFixedThreadPool(1, new CarbonThreadFactory(
"ConsumerPool_" + System.nanoTime() + ":" + model.getTableName() + ", range: " + model
.getBucketId()));
String.format("ConsumerPool:%s, range: %d",
model.getTableName(),model.getBucketId()), true));
consumerExecutorServiceTaskList = new ArrayList<>(1);
semaphore = new Semaphore(numberOfCores);
tablePageList = new TablePageList();
Expand Down

0 comments on commit 04b5256

Please sign in to comment.