Search in sources :

Example 1 with KafkaConnectClient

use of org.sourcelab.kafka.connect.apiclient.KafkaConnectClient in project akhq by tchiotludo.

the class KafkaModule method getConnectRestClient.

public Map<String, KafkaConnectClient> getConnectRestClient(String clusterId) {
    if (!this.connectRestClient.containsKey(clusterId)) {
        Connection connection = this.getConnection(clusterId);
        if (connection.getConnect() != null && !connection.getConnect().isEmpty()) {
            Map<String, KafkaConnectClient> mapConnects = new HashMap<>();
            connection.getConnect().forEach(connect -> {
                URIBuilder uri = URIBuilder.fromString(connect.getUrl().toString());
                Configuration configuration = new Configuration(uri.toNormalizedURI(false).toString());
                if (connect.getBasicAuthUsername() != null) {
                    configuration.useBasicAuth(connect.getBasicAuthUsername(), connect.getBasicAuthPassword());
                }
                if (connect.getSslTrustStore() != null) {
                    configuration.useTrustStore(new File(connect.getSslTrustStore()), connect.getSslTrustStorePassword());
                }
                if (connect.getSslKeyStore() != null) {
                    configuration.useKeyStore(new File(connect.getSslKeyStore()), connect.getSslKeyStorePassword());
                }
                mapConnects.put(connect.getName(), new KafkaConnectClient(configuration));
            });
            this.connectRestClient.put(clusterId, mapConnects);
        }
    }
    return this.connectRestClient.get(clusterId);
}
Also used : KafkaConnectClient(org.sourcelab.kafka.connect.apiclient.KafkaConnectClient) Configuration(org.sourcelab.kafka.connect.apiclient.Configuration) Connection(org.akhq.configs.Connection) File(java.io.File) URIBuilder(org.codehaus.httpcache4j.uri.URIBuilder)

Aggregations

File (java.io.File)1 Connection (org.akhq.configs.Connection)1 URIBuilder (org.codehaus.httpcache4j.uri.URIBuilder)1 Configuration (org.sourcelab.kafka.connect.apiclient.Configuration)1 KafkaConnectClient (org.sourcelab.kafka.connect.apiclient.KafkaConnectClient)1