Search in sources :

Example 1 with ParameterParser

use of io.seata.server.ParameterParser in project seata by seata.

the class AbstractServerTest method startSeataServer.

protected static void startSeataServer() throws InterruptedException {
    (new Thread(new Runnable() {

        @Override
        public void run() {
            File file = new File("sessionStore/root.data");
            if (file.exists()) {
                file.delete();
            }
            ParameterParser parameterParser = new ParameterParser(new String[] {});
            // initialize the metrics
            MetricsManager.get().init();
            System.setProperty(ConfigurationKeys.STORE_MODE, parameterParser.getStoreMode());
            nettyServer = new NettyRemotingServer(workingThreads);
            // server port
            nettyServer.setListenPort(parameterParser.getPort());
            UUIDGenerator.init(parameterParser.getServerNode());
            // log store mode : file态db
            SessionHolder.init(parameterParser.getStoreMode());
            DefaultCoordinator coordinator = new DefaultCoordinator(nettyServer);
            coordinator.init();
            nettyServer.setHandler(coordinator);
            // register ShutdownHook
            ShutdownHook.getInstance().addDisposable(coordinator);
            // 127.0.0.1 and 0.0.0.0 are not valid here.
            if (NetUtil.isValidIp(parameterParser.getHost(), false)) {
                XID.setIpAddress(parameterParser.getHost());
            } else {
                XID.setIpAddress(NetUtil.getLocalIp());
            }
            XID.setPort(nettyServer.getListenPort());
            nettyServer.init();
        }
    })).start();
    Thread.sleep(5000);
}
Also used : NettyRemotingServer(io.seata.core.rpc.netty.NettyRemotingServer) ParameterParser(io.seata.server.ParameterParser) DefaultCoordinator(io.seata.server.coordinator.DefaultCoordinator) File(java.io.File)

Aggregations

NettyRemotingServer (io.seata.core.rpc.netty.NettyRemotingServer)1 ParameterParser (io.seata.server.ParameterParser)1 DefaultCoordinator (io.seata.server.coordinator.DefaultCoordinator)1 File (java.io.File)1