Skip to content

Commit

Permalink
添加thread name space
Browse files Browse the repository at this point in the history
  • Loading branch information
黄志磊 committed Jan 18, 2016
1 parent b66b00d commit 9ab542f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Expand Up @@ -13,6 +13,7 @@
import com.shinemo.mpush.tools.config.ConfigCenter; import com.shinemo.mpush.tools.config.ConfigCenter;
import com.shinemo.mpush.tools.redis.RedisGroup; import com.shinemo.mpush.tools.redis.RedisGroup;
import com.shinemo.mpush.tools.spi.ServiceContainer; import com.shinemo.mpush.tools.spi.ServiceContainer;
import com.shinemo.mpush.tools.thread.ThreadNameSpace;
import com.shinemo.mpush.tools.thread.ThreadPoolUtil; import com.shinemo.mpush.tools.thread.ThreadPoolUtil;
import com.shinemo.mpush.tools.zk.ZKPath; import com.shinemo.mpush.tools.zk.ZKPath;
import com.shinemo.mpush.tools.zk.ZkRegister; import com.shinemo.mpush.tools.zk.ZkRegister;
Expand Down Expand Up @@ -104,7 +105,7 @@ public void onFailure(String message) {
} }
}); });
} }
}, "conn-server", false).start(); }, ThreadNameSpace.getServerName(server.getClass().getSimpleName()), false).start();


} }


Expand Down
Expand Up @@ -20,5 +20,17 @@ public class ThreadNameSpace {
public static final String getUniqueName(String serviceName) { public static final String getUniqueName(String serviceName) {
return "mp-sn-" + serviceName; return "mp-sn-" + serviceName;
} }

public static final String THREAD_NAME_PREFIX = "mp-t-";


public static final String getServerName(String serverName){
if(serverName.equals("ConnectionServer")){
return "mp-start-cs";
}else if(serverName.equals("GatewayServer")){
return "mp-start-gs";
}else{
return "mp-start-unknow";
}
}

} }
Expand Up @@ -6,7 +6,7 @@




public class ThreadPoolUtil { public class ThreadPoolUtil {
public static final String THREAD_NAME_PREFIX = "mp-t-";
private static final ThreadPoolManager threadPoolManager = private static final ThreadPoolManager threadPoolManager =
new ThreadPoolManager(Constants.MIN_POOL_SIZE, Constants.MAX_POOL_SIZE, Constants.THREAD_QUEUE_SIZE); new ThreadPoolManager(Constants.MIN_POOL_SIZE, Constants.MAX_POOL_SIZE, Constants.THREAD_QUEUE_SIZE);


Expand All @@ -31,7 +31,7 @@ public static Executor getWorkExecutor() {
public static Thread newThread(Runnable r, String name, boolean daemon) { public static Thread newThread(Runnable r, String name, boolean daemon) {
Thread t = new Thread(r); Thread t = new Thread(r);
t.setDaemon(daemon); t.setDaemon(daemon);
t.setName(THREAD_NAME_PREFIX + name); t.setName(ThreadNameSpace.THREAD_NAME_PREFIX + name);
return t; return t;
} }


Expand Down

0 comments on commit 9ab542f

Please sign in to comment.