Source:
public Object execute() throws Exception { Properties kafkaConfig = Utils.getKafkaConfig(identity, configAdmin, KafkaRpcConstants.RPC_TOPIC_PREFIX); if (kafkaConfig.isEmpty() || (kafkaConfig.getProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG) == null)) { System.out.println("Kafka not configured for RPC"); return null; } if (timeout <= 0) { timeout = DEFAULT_TIMEOUT; } kafkaConfig.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, timeout); try { Set<String> topics = Utils.getTopics(kafkaConfig); if (!topics.isEmpty()) { final String opennmsInstance = SystemInfoUtils.getInstanceId(); String locationSuffix = ""; if (identity.getType().equals(SystemType.Minion.name())) { locationSuffix = "." + identity.getLocation(); } final String topicName = opennmsInstance + locationSuffix; Set<String> rpcRequestTopics = topics.stream() .filter(topic -> topic.contains(topicName)) .filter(topic -> topic.contains(RPC_REQUEST_TOPIC_NAME)).collect(Collectors.toSet()); if (!rpcRequestTopics.isEmpty()) { System.out.println("\nRPC Request Topics:"); rpcRequestTopics.forEach(System.out::println); } Set<String> rpcResponseTopics = topics.stream() .filter(topic -> topic.contains(opennmsInstance)) .filter(topic -> topic.contains(RPC_RESPONSE_TOPIC_NAME)).collect(Collectors.toSet()); if (!rpcRequestTopics.isEmpty()) { System.out.println("\nRPC Response Topics:"); rpcResponseTopics.forEach(System.out::println); } return null; } System.out.println("No topics listed for Kafka RPC"); return null; } catch (Exception e) { e.printStackTrace(); } return null; }

Target:
public Object execute() throws Exception { Properties kafkaConfig = Utils.getKafkaConfig(identity, configAdmin, KafkaRpcConstants.RPC_TOPIC_PREFIX); if (kafkaConfig.isEmpty() || (kafkaConfig.getProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG) == null)) { System.out.println("Kafka not configured for RPC"); return null; } if (timeout <= 0) { timeout = DEFAULT_TIMEOUT; } kafkaConfig.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, timeout); try { Set<String> topics = Utils.getTopics(kafkaConfig); if (!topics.isEmpty()) { final String opennmsInstance = SystemInfoUtils.getInstanceId(); String locationSuffix = ""; if (identity.getType().equals(SystemType.Minion.name())) { locationSuffix = "." + identity.getLocation(); } final String topicName = opennmsInstance + locationSuffix; Set<String> rpcRequestTopics = topics.stream() .filter(topic -> topic.contains(topicName)) .filter(topic -> topic.contains(RPC_REQUEST_TOPIC_NAME)).collect(Collectors.toSet()); if (!rpcRequestTopics.isEmpty()) { System.out.println("\nRPC Request Topics:"); rpcRequestTopics.forEach(System.out::println); } else { System.out.println("No RPC Request topics found."); } Set<String> rpcResponseTopics = topics.stream() .filter(topic -> topic.contains(opennmsInstance)) .filter(topic -> topic.contains(RPC_RESPONSE_TOPIC_NAME)).collect(Collectors.toSet()); if (!rpcRequestTopics.isEmpty()) { System.out.println("\nRPC Response Topics:"); rpcResponseTopics.forEach(System.out::println); } else { System.out.println("No RPC Response topics found."); } return null; } System.out.println("No topics listed for Kafka RPC"); return null; } catch (Exception e) { e.printStackTrace(); } return null; }