|
1 | 1 | package com.michelin.ns4kafka.services.executors;
|
2 | 2 |
|
3 |
| -import com.michelin.ns4kafka.models.connector.Connector; |
4 | 3 | import com.michelin.ns4kafka.models.ObjectMeta;
|
| 4 | +import com.michelin.ns4kafka.models.connector.Connector; |
5 | 5 | import com.michelin.ns4kafka.repositories.ConnectorRepository;
|
6 | 6 | import com.michelin.ns4kafka.services.connect.KafkaConnectClientProxy;
|
7 | 7 | import com.michelin.ns4kafka.services.connect.client.KafkaConnectClient;
|
|
11 | 11 | import io.micronaut.http.client.exceptions.HttpClientResponseException;
|
12 | 12 | import io.micronaut.http.client.exceptions.ReadTimeoutException;
|
13 | 13 | import io.reactivex.Single;
|
| 14 | +import io.reactivex.internal.observers.ConsumerSingleObserver; |
14 | 15 | import lombok.extern.slf4j.Slf4j;
|
15 | 16 |
|
16 | 17 | import javax.inject.Inject;
|
@@ -68,7 +69,7 @@ private void synchronizeConnectCluster(String connectCluster) {
|
68 | 69 | connectCluster);
|
69 | 70 |
|
70 | 71 | collectBrokerConnectors(connectCluster)
|
71 |
| - .subscribe(brokerConnectors -> { |
| 72 | + .subscribe(new ConsumerSingleObserver<>(brokerConnectors -> { |
72 | 73 | List<Connector> ns4kafkaConnectors = collectNs4KafkaConnectors(connectCluster);
|
73 | 74 |
|
74 | 75 | List<Connector> toCreate = ns4kafkaConnectors.stream()
|
@@ -100,20 +101,19 @@ private void synchronizeConnectCluster(String connectCluster) {
|
100 | 101 | },
|
101 | 102 | error -> {
|
102 | 103 | if (error instanceof HttpClientResponseException) {
|
103 |
| - log.error("Invalid Http response {} during connectors synchronization for Kafka cluster {} and Connect cluster {}", |
104 |
| - ((HttpClientResponseException) error).getStatus(), |
105 |
| - kafkaAsyncExecutorConfig.getName(), |
106 |
| - connectCluster); |
| 104 | + log.error("Invalid HTTP response {} ({}) during connectors synchronization for Kafka cluster {} and Connect cluster {}", |
| 105 | + ((HttpClientResponseException) error).getStatus(), ((HttpClientResponseException) error).getResponse().getStatus(), |
| 106 | + kafkaAsyncExecutorConfig.getName(), connectCluster); |
107 | 107 | } else if (error instanceof ReadTimeoutException) {
|
108 |
| - log.error("ReadTimeoutException during connectors synchronization for Kafka cluster {} and Connect cluster {}", |
| 108 | + log.error("Read timeout during connectors synchronization for Kafka cluster {} and Connect cluster {}", |
109 | 109 | kafkaAsyncExecutorConfig.getName(),
|
110 | 110 | connectCluster);
|
111 | 111 | } else {
|
112 | 112 | log.error("Exception during connectors synchronization for Kafka cluster {} and Connect cluster {} : {}",
|
113 | 113 | kafkaAsyncExecutorConfig.getName(),
|
114 | 114 | connectCluster, error);
|
115 | 115 | }
|
116 |
| - }); |
| 116 | + })); |
117 | 117 | }
|
118 | 118 |
|
119 | 119 | /**
|
@@ -194,10 +194,10 @@ private boolean connectorsAreSame(Connector expected, Connector actual) {
|
194 | 194 | private void deployConnector(Connector connector) {
|
195 | 195 | kafkaConnectClient.createOrUpdate(KafkaConnectClientProxy.PROXY_SECRET, kafkaAsyncExecutorConfig.getName(),
|
196 | 196 | connector.getSpec().getConnectCluster(), connector.getMetadata().getName(),
|
197 |
| - ConnectorSpecs.builder().config(connector.getSpec().getConfig()).build()) |
198 |
| - .subscribe(httpResponse -> log.info("Success deploying Connector [{}] on Kafka [{}] Connect [{}]", |
199 |
| - connector.getMetadata().getName(), kafkaAsyncExecutorConfig.getName(), connector.getSpec().getConnectCluster()), |
200 |
| - httpError -> log.error(String.format("Error deploying Connector [%s] on Kafka [%s] Connect [%s]", |
201 |
| - connector.getMetadata().getName(), kafkaAsyncExecutorConfig.getName(), connector.getSpec().getConnectCluster()))); |
| 197 | + ConnectorSpecs.builder().config(connector.getSpec().getConfig()).build()) |
| 198 | + .subscribe(new ConsumerSingleObserver<>(httpResponse -> log.info("Success deploying Connector [{}] on Kafka [{}] Connect [{}]", |
| 199 | + connector.getMetadata().getName(), kafkaAsyncExecutorConfig.getName(), connector.getSpec().getConnectCluster()), |
| 200 | + httpError -> log.error(String.format("Error deploying Connector [%s] on Kafka [%s] Connect [%s]", |
| 201 | + connector.getMetadata().getName(), kafkaAsyncExecutorConfig.getName(), connector.getSpec().getConnectCluster())))); |
202 | 202 | }
|
203 | 203 | }
|
0 commit comments