本文整理汇总了Java中org.grain.thread.AsyncThreadManager.init方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncThreadManager.init方法的具体用法?Java AsyncThreadManager.init怎么用?Java AsyncThreadManager.init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.grain.thread.AsyncThreadManager
的用法示例。
在下文中一共展示了AsyncThreadManager.init方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
@Override
public void init(HttpServlet servlet) throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
ServletContext servletContext = servlet.getServletContext();
String configFileName = servletContext.getInitParameter("configFileName");
Properties properties = loadConfig(configFileName);
MybatisManager.init(properties.getProperty("config_dir"), "mybatis-config.xml", new MariadbLog());
HttpUtil.init("UTF-8", new HttpclientLog());
ThreadmsgLog threadmsgLog = new ThreadmsgLog();
AsyncThreadManager.init(100, 10, 3, 0, threadmsgLog);
AsyncThreadManager.start();
MsgManager.init(true, threadmsgLog);
CommonConfig.init(properties);
HOpCode.init();
MsgOpCode.init();
HttpManager.addFilter(new TokenHttpFilter());
HttpManager.addHttpListener(new AppService());
HttpManager.addHttpListener(new OrderRecordService());
HttpManager.addHttpListener(new PayService());
HttpManager.addHttpListener(new LoginService());
MsgManager.addMsgListener(new NotifyService(10));
}
示例2: init
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
@Override
public void init() throws ServletException {
// TODO Auto-generated method stub
super.init();
try {
GrainLog grainLog = new GrainLog(LoggerFactory.getLogger("minaLog"));
GrainLog grainLog1 = new GrainLog(LoggerFactory.getLogger("msgLog"));
// 初始化线程消息
AsyncThreadManager.init(100, 10, 3, 0, grainLog1);
AsyncThreadManager.start();
MsgManager.init(true, grainLog1);
WSManager.init(grainLog1);
// 映射操作码解析类,如果不设置线程优先级则随机线程优先级
ThreadWSManager.addThreadMapping("testc", TestC.class, new int[] { 2, 1 });
ThreadWSManager.addThreadMapping("tests", TestS.class, null);
// 注册tcp回调函数
TestWSService testWSService = new TestWSService();
WSManager.addWSListener(testWSService);
} catch (Exception e) {
// TODO: handle exception
}
}
示例3: main
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
GrainLog grainLog = new GrainLog(LoggerFactory.getLogger("minaLog"));
GrainLog grainLog1 = new GrainLog(LoggerFactory.getLogger("msgLog"));
// 初始化线程消息(需要锁定两条线程第一条唤醒用的,第二条获取锁信息汇集用的)
AsyncThreadManager.init(100, 10, 3, 2, grainLog1);
AsyncThreadManager.start();
MsgManager.init(true, grainLog1);
// 设置消息归属线程,不设置则随机分配
ThreadMsgManager.addMapping(TcpMsg.MINA_CLIENT_CREATE_CONNECT, new int[] { 1, 1 });
ThreadMsgManager.addMapping(TcpMsg.MINA_CLIENT_DISCONNECT, new int[] { 1, 1 });
// 第二条用于汇集用
int[] threadPriority = AsyncThreadManager.getLockThreadPriority(2);
ThreadMsgManager.addMapping(DistributedlockMsg.MERGE_TCPPACKET, threadPriority);
// 注册关注的消息
MergeTCPService mergeTCPService = new MergeTCPService();
MsgManager.addMsgListener(mergeTCPService);
WaitLockManager.init(120000);
ThreadTcpManager.init();
// 初始化分布式锁服务器
ArrayList<String> types = new ArrayList<>();
types.add("user");
types.add("group");
DistributedLockServer.init(types, grainLog1);
// 注册tcp回调函数
DistributedLockService distributedLockService = new DistributedLockService();
TcpManager.addTcpListener(distributedLockService);
// 创建TCP服务器
MinaServer.init("0.0.0.0", 7005, DistributedlockServerHandler.class, true, grainLog);
}
示例4: main
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
GrainLog grainLog = new GrainLog(LoggerFactory.getLogger("minaLog"));
GrainLog grainLog1 = new GrainLog(LoggerFactory.getLogger("msgLog"));
// 初始化线程消息
AsyncThreadManager.init(100, 10, 3, 1, grainLog1);
AsyncThreadManager.start();
MsgManager.init(true, grainLog1);
// 设置消息归属线程,不设置则随机分配
ThreadMsgManager.addMapping(TcpMsg.MINA_CLIENT_CREATE_CONNECT, new int[] { 1, 1 });
ThreadMsgManager.addMapping(TcpMsg.MINA_CLIENT_DISCONNECT, new int[] { 1, 1 });
// 注册关注的消息
TestMsgService testService = new TestMsgService();
MsgManager.addMsgListener(testService);
// 映射操作码解析类
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_C, RPCTestC.class, null);
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_S, RPCTestS.class, null);
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_SERVER, RPCTestS.class, null);
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_CLIENT, RPCTestC.class, null);
// 注册tcp回调函数
TestRPCServiceS testRPCServiceS = new TestRPCServiceS();
TcpManager.addTcpListener(testRPCServiceS);
WaitLockManager.init(120000);
ThreadTcpManager.init();
// 创建TCP服务器
MinaServer.init("0.0.0.0", 7005, ThreadMinaServerHandler.class, true, grainLog);
}
示例5: main
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
GrainLog grainLog = new GrainLog(LoggerFactory.getLogger("minaLog"));
GrainLog grainLog1 = new GrainLog(LoggerFactory.getLogger("msgLog"));
// 初始化线程消息
AsyncThreadManager.init(100, 10, 3, 1, grainLog1);
AsyncThreadManager.start();
MsgManager.init(true, grainLog1);
// 设置消息归属线程,不设置则随机分配
ThreadMsgManager.addMapping(TcpMsg.MINA_SERVER_CONNECTED, new int[] { 1, 1 });
ThreadMsgManager.addMapping(TcpMsg.MINA_SERVER_DISCONNECT, new int[] { 1, 1 });
ThreadMsgManager.addMapping(DistributedlockMsg.DISTRIBUTEDLOCK_SERVER_CAN_USE, new int[] { 1, 1 });
// 注册关注的消息
MinaClientService minaClientService = new MinaClientService();
MsgManager.addMsgListener(minaClientService);
TestMsgService testMsgService = new TestMsgService();
MsgManager.addMsgListener(testMsgService);
WaitLockManager.init(120000);
ThreadTcpManager.init();
// 初始化分布式锁客户端
Map<String, String> lockToServer = new HashMap<String, String>();
lockToServer.put("user", "testserver");
lockToServer.put("group", "testserver");
DistributedLockClient.init(lockToServer, grainLog1);
// 创建TCP客户端
MinaClient.init(new String[] { "0.0.0.0" }, new int[] { 7005 }, new String[] { "testserver" }, ThreadMinaClientHandler.class, 10, true, grainLog);
}
示例6: main
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
GrainLog grainLog = new GrainLog(LoggerFactory.getLogger("minaLog"));
GrainLog grainLog1 = new GrainLog(LoggerFactory.getLogger("msgLog"));
// 初始化线程消息
AsyncThreadManager.init(100, 10, 3, 1, grainLog1);
AsyncThreadManager.start();
MsgManager.init(true, grainLog1);
// 设置消息归属线程,不设置则随机分配
ThreadMsgManager.addMapping(TcpMsg.MINA_SERVER_CONNECTED, new int[] { 1, 1 });
ThreadMsgManager.addMapping(TcpMsg.MINA_SERVER_DISCONNECT, new int[] { 1, 1 });
// 注册关注的消息
TestMsgService testService = new TestMsgService();
MsgManager.addMsgListener(testService);
// 映射操作码解析类
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_C, RPCTestC.class, null);
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_S, RPCTestS.class, null);
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_SERVER, RPCTestS.class, null);
ThreadTcpManager.addThreadMapping(TestTCode.TEST_RPC_CLIENT, RPCTestC.class, null);
TestRPCServiceC testRPCServiceC = new TestRPCServiceC();
TcpManager.addTcpListener(testRPCServiceC);
WaitLockManager.init(120000);
ThreadTcpManager.init();
// 创建TCP客户端
MinaClient.init(new String[] { "0.0.0.0" }, new int[] { 7005 }, new String[] { "testserver" }, ThreadMinaClientHandler.class, 10, true, grainLog);
}
示例7: setUpBeforeClass
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
AsyncThreadManager.init(100, 10, 3, 0, null);
AsyncThreadManager.start();
MsgManager.init(true, null);
ThreadMsgManager.addMapping("createuser", new int[] { 1, 1 });
TestThreadMsgListener testThreadMsgListener = new TestThreadMsgListener();
MsgManager.addMsgListener(testThreadMsgListener);
}
示例8: init
import org.grain.thread.AsyncThreadManager; //导入方法依赖的package包/类
@Override
public void init() throws ServletException {
// TODO Auto-generated method stub
super.init();
WebSocketLog log = null;
try {
log = new WebSocketLog();
WSManager.init(log);
ThreadmsgLog threadmsgLog = new ThreadmsgLog();
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
ServletContext servletContext = this.getServletContext();
String configFileName = servletContext.getInitParameter("configFileName");
Properties properties = loadConfig(configFileName);
MybatisManager.init(properties.getProperty("config_dir"), "mybatis-config.xml", new MariadbLog());
HttpUtil.init("UTF-8", new HttpclientLog());
// 初始化线程消息
AsyncThreadManager.init(100, 10, 3, 0, threadmsgLog);
AsyncThreadManager.start();
MsgManager.init(true, threadmsgLog);
WsOpCodeChat.init();
CommonConfigChat.init(properties);
MsgOpCodeChat.init();
if (CommonConfigChat.IS_USE_MONGODB) {
MongodbManager.init(CommonConfigChat.MONGODB_URL, CommonConfigChat.MONGODB_PORT, CommonConfigChat.MONGODB_USERNAME, CommonConfigChat.MONGODB_PASSWORD, CommonConfigChat.MONGODB_DBNAME, new MongodbLog());
LoginChatServiceMongodb loginChatServiceMongodb = new LoginChatServiceMongodb();
MsgManager.addMsgListener(loginChatServiceMongodb);
WSManager.addWSListener(loginChatServiceMongodb);
WSManager.addWSListener(new MessageServiceMongodb());
} else {
LoginChatService loginChatService = new LoginChatService();
MsgManager.addMsgListener(loginChatService);
WSManager.addWSListener(loginChatService);
WSManager.addWSListener(new MessageService());
}
} catch (Exception e) {
if (log != null) {
log.error("启动失败", e);
}
}
}