@Override protected List<ConfigIssue> init() { List<ConfigIssue> issues = super.init(); issues.addAll(udpConfigs.init(getContext())); kafkaConfigBean.init(getContext(), DataFormat.BINARY, issues); if (issues.isEmpty()) { errorQueue = new ArrayBlockingQueue<>(100); errorList = new ArrayList<>(100); if (!udpConfigs.getAddresses().isEmpty()) { udpConsumer = new KafkaUDPConsumer(getContext(), udpConfigs, kafkaConfigBean, errorQueue); udpConsumer.init(); udpServer = new UDPConsumingServer( udpConfigs.enableEpoll, udpConfigs.acceptThreads, udpConfigs.getAddresses(), udpConsumer); try { udpServer.listen(); udpServer.start(); } catch (Exception ex) { udpServer.destroy(); udpServer = null; if (ex instanceof SocketException && udpConfigs.isPrivilegedPortUsage()) { issues.add( getContext() .createConfigIssue( Groups.UDP.name(), "ports", Errors.UDP_KAFKA_ORIG_01, udpConfigs.ports, ex)); } else { LOG.debug("Caught exception while starting up UDP server: {}", ex); issues.add( getContext() .createConfigIssue( null, null, Errors.UDP_KAFKA_ORIG_02, udpConfigs.getAddresses().toString(), ex.toString(), ex)); } } } } return issues; }
@Override public void destroy() { if (udpServer != null) { udpServer.destroy(); udpServer = null; } if (udpConsumer != null) { udpConsumer.destroy(); udpConsumer = null; } udpConfigs.destroy(); kafkaConfigBean.destroy(); super.destroy(); }