public static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
private static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
private static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
@Override protected void initializeConnections() { URL contactUrl = NetUtils.getCorrectHostnamePort(seedBrokerAddresses[currentContactSeedBrokerIndex]); this.consumer = new SimpleConsumer(contactUrl.getHost(), contactUrl.getPort(), soTimeout, bufferSize, dummyClientId); }
/** * Re-establish broker connection using the next available seed broker address. */ private void useNextAddressAsNewContactSeedBroker() { if (++currentContactSeedBrokerIndex == seedBrokerAddresses.length) { currentContactSeedBrokerIndex = 0; } URL newContactUrl = NetUtils.getCorrectHostnamePort(seedBrokerAddresses[currentContactSeedBrokerIndex]); this.consumer = new SimpleConsumer(newContactUrl.getHost(), newContactUrl.getPort(), soTimeout, bufferSize, dummyClientId); }
/** * Validate that at least one seed broker is valid in case of a * ClosedChannelException. * * @param seedBrokers * array containing the seed brokers e.g. ["host1:port1", * "host2:port2"] * @param exception * instance */ private static void validateSeedBrokers(String[] seedBrokers, Exception exception) { if (!(exception instanceof ClosedChannelException)) { return; } int unknownHosts = 0; for (String broker : seedBrokers) { URL brokerUrl = NetUtils.getCorrectHostnamePort(broker.trim()); try { InetAddress.getByName(brokerUrl.getHost()); } catch (UnknownHostException e) { unknownHosts++; } } // throw meaningful exception if all the provided hosts are invalid if (unknownHosts == seedBrokers.length) { throw new IllegalArgumentException("All the servers provided in: '" + ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG + "' config are invalid. (unknown hosts)"); } } }
private static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
public static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
public static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
private static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
public static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
private static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
@Override protected void initializeConnections() { URL contactUrl = NetUtils.getCorrectHostnamePort(seedBrokerAddresses[currentContactSeedBrokerIndex]); this.consumer = new SimpleConsumer(contactUrl.getHost(), contactUrl.getPort(), soTimeout, bufferSize, dummyClientId); }
/** * Re-establish broker connection using the next available seed broker address. */ private void useNextAddressAsNewContactSeedBroker() { if (++currentContactSeedBrokerIndex == seedBrokerAddresses.length) { currentContactSeedBrokerIndex = 0; } URL newContactUrl = NetUtils.getCorrectHostnamePort(seedBrokerAddresses[currentContactSeedBrokerIndex]); this.consumer = new SimpleConsumer(newContactUrl.getHost(), newContactUrl.getPort(), soTimeout, bufferSize, dummyClientId); }
@Override protected void initializeConnections() { URL contactUrl = NetUtils.getCorrectHostnamePort(seedBrokerAddresses[currentContactSeedBrokerIndex]); this.consumer = new SimpleConsumer(contactUrl.getHost(), contactUrl.getPort(), soTimeout, bufferSize, dummyClientId); }
/** * Re-establish broker connection using the next available seed broker address. */ private void useNextAddressAsNewContactSeedBroker() { if (++currentContactSeedBrokerIndex == seedBrokerAddresses.length) { currentContactSeedBrokerIndex = 0; } URL newContactUrl = NetUtils.getCorrectHostnamePort(seedBrokerAddresses[currentContactSeedBrokerIndex]); this.consumer = new SimpleConsumer(newContactUrl.getHost(), newContactUrl.getPort(), soTimeout, bufferSize, dummyClientId); }
/** * Validate that at least one seed broker is valid in case of a * ClosedChannelException. * * @param seedBrokers * array containing the seed brokers e.g. ["host1:port1", * "host2:port2"] * @param exception * instance */ private static void validateSeedBrokers(String[] seedBrokers, Exception exception) { if (!(exception instanceof ClosedChannelException)) { return; } int unknownHosts = 0; for (String broker : seedBrokers) { URL brokerUrl = NetUtils.getCorrectHostnamePort(broker.trim()); try { InetAddress.getByName(brokerUrl.getHost()); } catch (UnknownHostException e) { unknownHosts++; } } // throw meaningful exception if all the provided hosts are invalid if (unknownHosts == seedBrokers.length) { throw new IllegalArgumentException("All the servers provided in: '" + ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG + "' config are invalid. (unknown hosts)"); } } }
/** * Validate that at least one seed broker is valid in case of a * ClosedChannelException. * * @param seedBrokers * array containing the seed brokers e.g. ["host1:port1", * "host2:port2"] * @param exception * instance */ private static void validateSeedBrokers(String[] seedBrokers, Exception exception) { if (!(exception instanceof ClosedChannelException)) { return; } int unknownHosts = 0; for (String broker : seedBrokers) { URL brokerUrl = NetUtils.getCorrectHostnamePort(broker.trim()); try { InetAddress.getByName(brokerUrl.getHost()); } catch (UnknownHostException e) { unknownHosts++; } } // throw meaningful exception if all the provided hosts are invalid if (unknownHosts == seedBrokers.length) { throw new IllegalArgumentException("All the servers provided in: '" + ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG + "' config are invalid. (unknown hosts)"); } }
/** * Validate that at least one seed broker is valid in case of a * ClosedChannelException. * * @param seedBrokers * array containing the seed brokers e.g. ["host1:port1", * "host2:port2"] * @param exception * instance */ private static void validateSeedBrokers(String[] seedBrokers, Exception exception) { if (!(exception instanceof ClosedChannelException)) { return; } int unknownHosts = 0; for (String broker : seedBrokers) { URL brokerUrl = NetUtils.getCorrectHostnamePort(broker.trim()); try { InetAddress.getByName(brokerUrl.getHost()); } catch (UnknownHostException e) { unknownHosts++; } } // throw meaningful exception if all the provided hosts are invalid if (unknownHosts == seedBrokers.length) { throw new IllegalArgumentException("All the servers provided in: '" + ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG + "' config are invalid. (unknown hosts)"); } } }
URL brokerUrl = NetUtils.getCorrectHostnamePort(seedBroker); SimpleConsumer consumer = null; try {