Skip to content

Commit

Permalink
-- NameSrvAddr changed to BootstrapServer to conform to Kafka Standards.
Browse files Browse the repository at this point in the history
-- Tests changed
  • Loading branch information
deepPublicGit committed Jan 26, 2025
1 parent b26dda6 commit c57c15f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public class KafkaLogCollectClient extends AbstractLogConsumeClient<KafkaLogColl
@Override
public void initClient0(@NonNull final KafkaLogCollectConfig.KafkaLogConfig config) {
if (Objects.isNull(config)
|| StringUtils.isBlank(config.getNamesrvAddr())
|| StringUtils.isBlank(config.getBootstrapServer())
|| StringUtils.isBlank(config.getTopic())) {
LOG.error("kafka props is empty. failed init kafka producer");
return;
}
String topic = config.getTopic();
String nameserverAddress = config.getNamesrvAddr();
String nameserverAddress = config.getBootstrapServer();

if (StringUtils.isBlank(topic) || StringUtils.isBlank(nameserverAddress)) {
LOG.error("init kafkaLogCollectClient error, please check topic or nameserverAddress");
Expand All @@ -83,7 +83,7 @@ public void initClient0(@NonNull final KafkaLogCollectConfig.KafkaLogConfig conf
Properties props = new Properties();
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
props.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, config.getNamesrvAddr());
props.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, config.getBootstrapServer());
if (!StringUtils.isBlank(config.getSecurityProtocol())
&& !StringUtils.isBlank(config.getSaslMechanism())) {
props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, config.getSecurityProtocol());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static class KafkaLogConfig extends GenericGlobalConfig {

private String topic;

private String namesrvAddr;
private String bootstrapServer;

private String producerGroup;

Expand Down Expand Up @@ -186,17 +186,17 @@ public void setTopic(final String topic) {
*
* @return kafka nameserver address
*/
public String getNamesrvAddr() {
return namesrvAddr;
public String getBootstrapServer() {
return bootstrapServer;
}

/**
* set kafka nameserver address.
*
* @param namesrvAddr kafka nameserver address
* @param bootstrapServer kafka nameserver address
*/
public void setNamesrvAddr(final String namesrvAddr) {
this.namesrvAddr = namesrvAddr;
public void setBootstrapServer(final String bootstrapServer) {
this.bootstrapServer = bootstrapServer;
}

/**
Expand Down Expand Up @@ -230,7 +230,7 @@ public boolean equals(final Object o) {
KafkaLogConfig that = (KafkaLogConfig) o;
return Objects.equals(getTopic(), that.getTopic())
&& Objects.equals(getCompressAlg(), that.getCompressAlg())
&& Objects.equals(getNamesrvAddr(), that.getNamesrvAddr())
&& Objects.equals(getBootstrapServer(), that.getBootstrapServer())
&& Objects.equals(getProducerGroup(), that.getProducerGroup())
&& Objects.equals(getSampleRate(), that.getSampleRate())
&& Objects.equals(getBufferQueueSize(), that.getBufferQueueSize())
Expand All @@ -240,7 +240,7 @@ public boolean equals(final Object o) {

@Override
public int hashCode() {
return Objects.hash(topic, compressAlg, namesrvAddr, producerGroup);
return Objects.hash(topic, compressAlg, bootstrapServer, producerGroup);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void testSetGlobalLogConfigMaxRequestBody() {
}

@Test
public void testSetGlobalLogConfigNamesrvAddr() {
public void testSetGlobalLogConfigBootstrapServer() {
KafkaLogCollectConfig.KafkaLogConfig kafkaLogConfig = new KafkaLogCollectConfig.KafkaLogConfig();
kafkaLogConfig.setNamesrvAddr("test");
Assertions.assertEquals(kafkaLogConfig.getNamesrvAddr(), "test");
kafkaLogConfig.setBootstrapServer("test");
Assertions.assertEquals(kafkaLogConfig.getBootstrapServer(), "test");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setUp() {
selectorData.setConditionList(list);
pluginData.setEnabled(false);
pluginData.setId(UUID.randomUUID().toString().replace("-", ""));
pluginData.setConfig("{\"topic\":\"test\", \"namesrvAddr\":\"localhost:8082\"}");
pluginData.setConfig("{\"topic\":\"test\", \"bootstrapServer\":\"localhost:8082\"}");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import static org.mockito.Mockito.mockConstruction;

/**
* The Test Case For RocketMQLogCollectClient.
* The Test Case For KafkaLogCollectClient.
*/
public class KafkaLogCollectClientTest {

Expand All @@ -50,7 +50,7 @@ public class KafkaLogCollectClientTest {
public void setUp() {
this.kafkaLogCollectClient = new KafkaLogCollectClient();
pluginData.setEnabled(true);
pluginData.setConfig("{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\":\"localhost:8082\"}");
pluginData.setConfig("{\"topic\":\"shenyu-access-logging\", \"bootstrapServer\":\"localhost:8082\"}");
globalLogConfig = GsonUtils.getInstance().fromJson(pluginData.getConfig(), KafkaLogCollectConfig.KafkaLogConfig.class);
globalLogConfig.setCompressAlg("LZ4");
shenyuRequestLog.setClientIp("0.0.0.0");
Expand Down

0 comments on commit c57c15f

Please sign in to comment.