public static void init(String[] args) throws UnknownHostException {
        localAddr = null;
        if (!"0.0.0.0".equals(Config.frontend_address)) {
            if (!InetAddressValidator.getInstance().isValid(Config.frontend_address)) {
                throw new UnknownHostException("invalid frontend_address: " + Config.frontend_address);
            }
            localAddr = InetAddress.getByName(Config.frontend_address);
            LOG.info("use configured address. {}", localAddr);
            return;
        }

        List<InetAddress> hosts = NetUtils.getHosts();
        if (hosts.isEmpty()) {
            LOG.error("fail to get localhost");
            System.exit(-1);
        }

        HostType specifiedHostType = HostType.NOT_SPECIFIED;

        for (int i = 0; i < args.length; i++) {
            if (args[i].equalsIgnoreCase("-host_type")) {
                if (i + 1 >= args.length) {
                    System.out.println("-host_type need parameter FQDN or IP");
                    System.exit(-1);
                }
                String inputHostType = args[i + 1];
                try {
                    inputHostType = inputHostType.toUpperCase();
                    specifiedHostType = HostType.valueOf(inputHostType);
                } catch (Exception e) {
                    System.out.println("-host_type need parameter FQDN or IP");
                    System.exit(-1);
                }
            }   
        } 

        if (specifiedHostType == HostType.FQDN) {
            initAddrUseFqdn(hosts);
            return;
        }
        if (specifiedHostType == HostType.IP) {
            initAddrUseIp(hosts);
            return;
        }

        // Check if it is a new cluster, new clusters start with IP by default
        String roleFilePath = Config.meta_dir + ROLE_FILE_PATH;
        File roleFile = new File(roleFilePath);
        if (!roleFile.exists()) {
            initAddrUseIp(hosts);
            return;
        }
        
        Properties prop = new Properties();
        String fileStoredHostType;
        try (FileInputStream in = new FileInputStream(roleFile)) {
            prop.load(in);
        } catch (IOException e) {
            LOG.error("failed to read role file");
            System.exit(-1);
        }
        fileStoredHostType = prop.getProperty(HOST_TYPE, null);
        
        // Check if the ROLE file has property 'hostType'
        // If it not has property 'hostType', start with IP
        // If it has property 'hostType' & hostType = IP, start with IP
        if (Strings.isNullOrEmpty(fileStoredHostType) || fileStoredHostType.equals(HostType.IP.toString())) {
            initAddrUseIp(hosts);
            return;
        }
        // If it has property 'hostType' & hostType = FQDN, start with FQDN
        initAddrUseFqdn(hosts);
    }
@Test
    public void testChooseHostType() throws UnknownHostException {
        mockNet();
        useFqdn = true;
        FrontendOptions.init(new String[] {"-host_type", "ip"});
        Assert.assertTrue(!useFqdn);
        useFqdn = false;
        FrontendOptions.init(new String[] {"-host_type", "fqdn"});
        Assert.assertTrue(useFqdn);
        useFqdn = false;
        FrontendOptions.init(new String[] {});
        Assert.assertTrue(!useFqdn);
    }