Java Code Examples for org.apache.kafka.common.utils.Utils#join()

The following examples show how to use org.apache.kafka.common.utils.Utils#join() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterTestHarness.java    From kareldb with Apache License 2.0 7 votes vote down vote up
@Before
public void setUp() throws Exception {
    zookeeper = new EmbeddedZookeeper();
    zkConnect = String.format("localhost:%d", zookeeper.port());

    configs = new Vector<>();
    servers = new Vector<>();
    for (int i = 0; i < numBrokers; i++) {
        KafkaConfig config = getKafkaConfig(i);
        configs.add(config);

        KafkaServer server = TestUtils.createServer(config, Time.SYSTEM);
        servers.add(server);
    }

    String[] serverUrls = new String[servers.size()];
    ListenerName listenerType = ListenerName.forSecurityProtocol(getSecurityProtocol());
    for (int i = 0; i < servers.size(); i++) {
        serverUrls[i] =
            Utils.formatAddress(
                servers.get(i).config().advertisedListeners().head().host(),
                servers.get(i).boundPort(listenerType)
            );
    }
    bootstrapServers = Utils.join(serverUrls, ",");
}
 
Example 2
Source File: ClusterTestHarness.java    From kcache with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    zookeeper = new EmbeddedZookeeper();
    zkConnect = String.format("localhost:%d", zookeeper.port());

    configs = new Vector<>();
    servers = new Vector<>();
    for (int i = 0; i < numBrokers; i++) {
        KafkaConfig config = getKafkaConfig(i);
        configs.add(config);

        KafkaServer server = TestUtils.createServer(config, Time.SYSTEM);
        servers.add(server);
    }

    String[] serverUrls = new String[servers.size()];
    ListenerName listenerType = ListenerName.forSecurityProtocol(getSecurityProtocol());
    for (int i = 0; i < servers.size(); i++) {
        serverUrls[i] =
            Utils.formatAddress(
                servers.get(i).config().advertisedListeners().head().host(),
                servers.get(i).boundPort(listenerType)
            );
    }
    bootstrapServers = Utils.join(serverUrls, ",");
}
 
Example 3
Source File: InvocationClientConfig.java    From kafka-connect-lambda with Apache License 2.0 5 votes vote down vote up
@Override
public void ensureValid(String name, Object invocationMode) {
    try {
        InvocationMode.valueOf(((String)invocationMode).trim());
    } catch (Exception e) {
        throw new ConfigException(name, invocationMode, "Value must be one of [" +
            Utils.join(InvocationMode.values(), ", ") + "]");
    }
}
 
Example 4
Source File: InvocationClientConfig.java    From kafka-connect-lambda with Apache License 2.0 5 votes vote down vote up
@Override
public void ensureValid(String name, Object invocationFailure) {
    try {
        InvocationFailure.valueOf(((String)invocationFailure).trim());
    } catch (Exception e) {
        throw new ConfigException(name, invocationFailure, "Value must be one of [" +
            Utils.join(InvocationFailure.values(), ", ") + "]");
    }
}
 
Example 5
Source File: AwsLambdaSinkConnectorConfig.java    From kafka-connect-aws-lambda with Apache License 2.0 5 votes vote down vote up
@Override
public void ensureValid(String name, Object region) {
  String regionStr = ((String) region).toLowerCase().trim();
  if (RegionUtils.getRegion(regionStr) == null) {
    throw new ConfigException(name, region, "Value must be one of: " + Utils.join(RegionUtils.getRegions(), ", "));
  }
}
 
Example 6
Source File: AwsLambdaSinkConnectorConfig.java    From kafka-connect-aws-lambda with Apache License 2.0 5 votes vote down vote up
@Override
public void ensureValid(String name, Object invocationType) {
  try {
    InvocationType.fromValue(((String) invocationType).trim());
  } catch (Exception e) {
    throw new ConfigException(name, invocationType, "Value must be one of: " +
      Utils.join(InvocationType.values(), ", "));
  }
}
 
Example 7
Source File: InvocationClientConfig.java    From kafka-connect-lambda with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return "[" + Utils.join(InvocationMode.values(), ", ") + "]";
}
 
Example 8
Source File: InvocationClientConfig.java    From kafka-connect-lambda with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return "[" + Utils.join(InvocationFailure.values(), ", ") + "]";
}
 
Example 9
Source File: AwsLambdaSinkConnectorConfig.java    From kafka-connect-aws-lambda with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
  return "[" + Utils.join(RegionUtils.getRegions(), ", ") + "]";
}
 
Example 10
Source File: AwsLambdaSinkConnectorConfig.java    From kafka-connect-aws-lambda with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
  return "[" + Utils.join(InvocationType.values(), ", ") + "]";
}