| 71 | } |
| 72 | |
| 73 | private InetSocketAddress start() throws IOException, InterruptedException { |
| 74 | int port = 0; // Ephemeral port. |
| 75 | int maxconnections = 1000; |
| 76 | |
| 77 | File dataFile = new File(logdir, "zookeeper_data").getAbsoluteFile(); |
| 78 | File snapFile = new File(logdir, "zookeeper_snap").getAbsoluteFile(); |
| 79 | |
| 80 | server = new ZooKeeperServer( |
| 81 | new FileTxnSnapLog(dataFile, snapFile), |
| 82 | new BasicDataTreeBuilder()); |
| 83 | |
| 84 | connection = new NIOServerCnxnFactory(); |
| 85 | connection.configure(new InetSocketAddress(port), maxconnections); |
| 86 | connection.startup(server); |
| 87 | |
| 88 | return connection.getLocalAddress(); |
| 89 | } |
| 90 | |
| 91 | private void stop() { |
| 92 | if (connection != null) { |