@Test public void testCassandraHostWithUnderscoreSucceedsValidation() { Configuration config = Configuration.getInstance(); config.setProperty(CoreConfig.CASSANDRA_HOSTS, "my_hostname:9160"); BluefloodServiceStarter.validateCassandraHosts(); }
public static void validateCassandraHosts() { String hosts = Configuration.getInstance().getStringProperty(CoreConfig.CASSANDRA_HOSTS); if (!(hosts.length() >= 3)) { log.error("No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); throw new BluefloodServiceStarterException(-1, "No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); } for (String host : hosts.split(",")) { if (!host.matches("[\\d\\w\\.\\-_]+:\\d+")) { log.error("Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); throw new BluefloodServiceStarterException(-1, "Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); } } }
BluefloodServiceStarter { public static void validateCassandraHosts() { String hosts = Configuration.getInstance().getStringProperty(CoreConfig.CASSANDRA_HOSTS); if (!(hosts.length() >= 3)) { log.error("No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); throw new BluefloodServiceStarterException(-1, "No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); } for (String host : hosts.split(",")) { if (!host.matches("[\\d\\w\\.\\-_]+:\\d+")) { log.error("Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); throw new BluefloodServiceStarterException(-1, "Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); } } } }
BluefloodServiceStarter { public static void validateCassandraHosts() { String hosts = Configuration.getInstance().getStringProperty(CoreConfig.CASSANDRA_HOSTS); if (!(hosts.length() >= 3)) { log.error("No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); throw new BluefloodServiceStarterException(-1, "No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); } for (String host : hosts.split(",")) { if (!host.matches("[\\d\\w\\.\\-_]+:\\d+")) { log.error("Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); throw new BluefloodServiceStarterException(-1, "Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); } } }  }
BluefloodServiceStarter { public static void validateCassandraHosts() { String hosts = Configuration.getInstance().getStringProperty(CoreConfig.CASSANDRA_HOSTS); if (!(hosts.length() >= 3)) { log.error("No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); throw new BluefloodServiceStarterException(-1, "No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); } for (String host : hosts.split(",")) { if (!host.matches("[\\d\\w\\.\\-_]+:\\d+")) { log.error("Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); throw new BluefloodServiceStarterException(-1, "Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); } } }  static void validateCassandraHosts(); static void main(String args[]); static void run(); static MetricRegistry getRegistry(); }
BluefloodServiceStarter { public static void validateCassandraHosts() { String hosts = Configuration.getInstance().getStringProperty(CoreConfig.CASSANDRA_HOSTS); if (!(hosts.length() >= 3)) { log.error("No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); throw new BluefloodServiceStarterException(-1, "No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); } for (String host : hosts.split(",")) { if (!host.matches("[\\d\\w\\.\\-_]+:\\d+")) { log.error("Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); throw new BluefloodServiceStarterException(-1, "Invalid Cassandra host found in Configuration option 'CASSANDRA_HOSTS' -- Should be of the form <hostname>:<port>"); } } }  static void validateCassandraHosts(); static void main(String args[]); static void run(); static MetricRegistry getRegistry();  }