@Override public void stop() { try { super.stop(); log.info("Stopped lealone tcp server"); } finally { TcpPortTracker.deleteTcpPortEphemeralNode(serverName, tcpPort, master != null); } }
private void init(Configuration conf) { ArrayList<String> args = new ArrayList<String>(); for (String arg : conf.getStrings(TCP_SERVER_START_ARGS, DEFAULT_TCP_SERVER_START_ARGS)) { int pos = arg.indexOf('='); if (pos == -1) { args.add(arg.trim()); } else { args.add(arg.substring(0, pos).trim()); args.add(arg.substring(pos + 1).trim()); } } args.add("-tcpPort"); args.add("" + tcpPort); super.init(args.toArray(new String[0])); }
@Override public void start() { try { super.start(); TcpPortTracker.createTcpPortEphemeralNode(serverName, tcpPort, master != null); ZooKeeperAdmin.getTcpPortTracker(); // 初始化TcpPortTracker String name = getName() + " (" + getURL() + ")"; Thread t = new Thread(this, name); t.setDaemon(isDaemon()); t.start(); log.info("Started lealone tcp server at port " + tcpPort); } catch (SQLException e) { throw new RuntimeException(e); } }