static WordCountInteractiveQueriesRestService startRestProxy(final KafkaStreams streams, final int port, final String host) throws Exception { final HostInfo hostInfo = new HostInfo(host, port); final WordCountInteractiveQueriesRestService wordCountInteractiveQueriesRestService = new WordCountInteractiveQueriesRestService(streams, hostInfo); wordCountInteractiveQueriesRestService.start(port); return wordCountInteractiveQueriesRestService; }
final String schemaRegistryUrl = args.length > 2 ? args[2] : "http://localhost:8081"; final String restEndpointHostname = args.length > 3 ? args[3] : DEFAULT_REST_ENDPOINT_HOSTNAME; final HostInfo restEndpoint = new HostInfo(restEndpointHostname, restEndpointPort);
private void createStreams(final String host) throws Exception { appServerPort = randomFreeLocalPort(); streams = KafkaMusicExample.createChartsStreams(CLUSTER.bootstrapServers(), CLUSTER.schemaRegistryUrl(), appServerPort, TestUtils.tempDirectory().getPath(), host); int count = 0; final int maxTries = 3; while (count <= maxTries) { try { // Starts the Rest Service on the provided host:port restProxy = KafkaMusicExample.startRestProxy(streams, new HostInfo(host, appServerPort)); } catch (final Exception ex) { log.error("Could not start Rest Service due to: " + ex.toString()); } count++; } }
private static void decodeGlobalAssignmentData(final AssignmentInfo assignmentInfo, final DataInputStream in) throws IOException { assignmentInfo.partitionsByHost = new HashMap<>(); final int numEntries = in.readInt(); for (int i = 0; i < numEntries; i++) { final HostInfo hostInfo = new HostInfo(in.readUTF(), in.readInt()); assignmentInfo.partitionsByHost.put(hostInfo, readTopicPartitions(in)); } }
private static HostInfo parseHostInfo(final String endPoint) { if (endPoint == null || endPoint.trim().isEmpty()) { return StreamsMetadataState.UNKNOWN_HOST; } final String host = getHost(endPoint); final Integer port = getPort(endPoint); if (host == null || port == null) { throw new ConfigException(String.format("Error parsing host address %s. Expected format host:port.", endPoint)); } return new HostInfo(host, port); }
/** * Gets the current {@link HostInfo} that the calling kafka streams application is running on. * * Note that the end user applications must provide `applicaiton.server` as a configuration property * when calling this method. If this is not available, then null is returned. * * @return the current {@link HostInfo} */ public HostInfo getCurrentHostInfo() { Map<String, String> configuration = this.binderConfigurationProperties.getConfiguration(); if (configuration.containsKey("application.server")) { String applicationServer = configuration.get("application.server"); String[] splits = StringUtils.split(applicationServer, ":"); return new HostInfo(splits[0], Integer.valueOf(splits[1])); } return null; }
ClientMetadata(final String endPoint) { // get the host info if possible if (endPoint != null) { final String host = getHost(endPoint); final Integer port = getPort(endPoint); if (host == null || port == null) { throw new ConfigException(String.format("Error parsing host address %s. Expected format host:port.", endPoint)); } hostInfo = new HostInfo(host, port); } else { hostInfo = null; } // initialize the consumer memberIds consumers = new HashSet<>(); // initialize the client state state = new ClientState(); }