Skip to content

Commit

Permalink
naming locals3 threads. (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robothy authored Jan 1, 2025
1 parent eec7ad3 commit 21a31b0
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions local-s3-rest/src/main/java/com/robothy/s3/rest/LocalS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.net.ServerSocket;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.ThreadFactory;
import javax.xml.stream.XMLInputFactory;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -82,9 +83,9 @@ public static Builder builder() {
public void start() {
ServiceFactory serviceFactory = createServiceFactory();

this.parentGroup = new NioEventLoopGroup(nettyParentEventGroupThreadNum);
this.childGroup = new NioEventLoopGroup(nettyChildEventGroupThreadNum);
this.executorGroup = new DefaultEventLoopGroup(s3ExecutorThreadNum);
this.parentGroup = new NioEventLoopGroup(nettyParentEventGroupThreadNum, new NamingThreadFactory("locals3-parent-event-group"));
this.childGroup = new NioEventLoopGroup(nettyChildEventGroupThreadNum, new NamingThreadFactory("locals3-child-event-group"));
this.executorGroup = new DefaultEventLoopGroup(s3ExecutorThreadNum, new NamingThreadFactory("locals3-executor-group"));
ServerBootstrap serverBootstrap = new ServerBootstrap();
ChannelFuture channelFuture = null;
try {
Expand Down Expand Up @@ -322,4 +323,20 @@ private int findFreeTcpPort() {

}

private static final class NamingThreadFactory implements ThreadFactory {

private final String name;

private int counter = 0;

public NamingThreadFactory(String name) {
this.name = name;
}

@Override
public Thread newThread(Runnable r) {
return new Thread(r, name + "-" + counter++);
}
}

}

0 comments on commit 21a31b0

Please sign in to comment.