public void start() throws Exception {
        //TODO executors
        new Thread(null, flushManager, "node-manager[" + name + "]").start();
//        new Thread(null, compactManager, "compact-manager[" + name + "]").start();

        System.out.println("NODE: INFO: Starting Node");

        Selector selector;
        ServerSocketChannel serverChannel;
        SelectionKey acceptKey;
        try {
            selector = Selector.open();
            serverChannel = ServerSocketChannel.open();
            serverChannel.configureBlocking(false);

            serverChannel.bind(new InetSocketAddress(port));
            acceptKey = serverChannel.register(selector, SelectionKey.OP_ACCEPT);
        } catch (IOException e) {
            System.out.println("NODE: ERROR: Can't open ServerSocket (probably, port is busy)");
            return;
        }

        try {
            boolean firstTime = true;
            while (!stopSignal) {
                if (!firstTime) {
                    selector.select(100);
                }

                if (firstTime || selector.selectedKeys().size() > 0) {
                    SocketChannel clientChannel;
                    while ((clientChannel = serverChannel.accept()) != null) {
                        clientChannel.configureBlocking(false);
                        executorService.submit(queryHandlerFactory.makeQueryHandler(clientChannel));
                    }
                    if (firstTime) {
                        firstTime = false;
                    } else {
                        selector.selectedKeys().remove(acceptKey);
                    }
                }
            }
        } finally {
            System.out.println("NODE: INFO: Node is stopping");

            flushManager.stop();
//            compactManager.stop();

            executorService.shutdown();
            executorService.awaitTermination(500, TimeUnit.MILLISECONDS);
            if (!executorService.isTerminated()) {
                executorService.shutdownNow();
            }

            commitLog.close();

            System.out.println("NODE: INFO: Node is stopped");
        }
    }