Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to allow user to add a message to a topic partition manually #703

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nguyen-tri-nhan
Copy link

Resolve conflict for #230

Copy link
Collaborator

@Bert-R Bert-R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nguyen-tri-nhan Thanks for this contribution!

I've reviewed it and added a couple of small comments and a question

Besides these, our linter isn't happy, see the below log.

If you resolve these, I would be happy to merge this PR.

2024-12-05 19:29:28 [INFO]   Linting EDITORCONFIG items...
  Error: -05 19:29:29 [ERROR]   Found errors when linting EDITORCONFIG. Exit code: 1.
  2024-12-05 19:29:29 [INFO]   Command output for EDITORCONFIG:
  ------
  src/main/java/kafdrop/util/DefaultMessageSerializer.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	5: Wrong indent style found (tabs instead of spaces)
  	6: Wrong indent style found (tabs instead of spaces)
  	7: Wrong indent style found (tabs instead of spaces)
  	8: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/controller/MessageController.java:
  	211: Wrong indent style found (tabs instead of spaces)
  	212: Wrong indent style found (tabs instead of spaces)
  	213: Wrong indent style found (tabs instead of spaces)
  	214: Wrong indent style found (tabs instead of spaces)
  	215: Wrong indent style found (tabs instead of spaces)
  	216: Wrong indent style found (tabs instead of spaces)
  	217: Wrong indent style found (tabs instead of spaces)
  	218: Wrong indent style found (tabs instead of spaces)
  	219: Wrong indent style found (tabs instead of spaces)
  	[220](https://github.com/obsidiandynamics/kafdrop/actions/runs/12143699503/job/33995776344?pr=703#step:4:222): Wrong indent style found (tabs instead of spaces)
  	221: Wrong indent style found (tabs instead of spaces)
  	222: Wrong indent style found (tabs instead of spaces)
  	[223](https://github.com/obsidiandynamics/kafdrop/actions/runs/12143699503/job/33995776344?pr=703#step:4:225): Wrong indent style found (tabs instead of spaces)
  	224: Wrong indent style found (tabs instead of spaces)
  	[225](https://github.com/obsidiandynamics/kafdrop/actions/runs/12143699503/job/33995776344?pr=703#step:4:227): Wrong indent style found (tabs instead of spaces)
  	227: Wrong indent style found (tabs instead of spaces)
  	228: Wrong indent style found (tabs instead of spaces)
  	229: Wrong indent style found (tabs instead of spaces)
  	230: Wrong indent style found (tabs instead of spaces)
  	231: Wrong indent style found (tabs instead of spaces)
  	233: Wrong indent style found (tabs instead of spaces)
  	234: Wrong indent style found (tabs instead of spaces)
  	235: Wrong indent style found (tabs instead of spaces)
  	236: Wrong indent style found (tabs instead of spaces)
  	237: Wrong indent style found (tabs instead of spaces)
  	238: Wrong indent style found (tabs instead of spaces)
  	240: Wrong indent style found (tabs instead of spaces)
  	241: Wrong indent style found (tabs instead of spaces)
  	242: Wrong indent style found (tabs instead of spaces)
  	243: Wrong indent style found (tabs instead of spaces)
  	244: Wrong indent style found (tabs instead of spaces)
  	245: Wrong indent style found (tabs instead of spaces)
  	253: Wrong indent style found (tabs instead of spaces)
  	254: Wrong indent style found (tabs instead of spaces)
  	255: Wrong indent style found (tabs instead of spaces)
  	256: Wrong indent style found (tabs instead of spaces)
  	440: Wrong indent style found (tabs instead of spaces)
  	441: Wrong indent style found (tabs instead of spaces)
  	442: Wrong indent style found (tabs instead of spaces)
  	443: Wrong indent style found (tabs instead of spaces)
  	444: Wrong indent style found (tabs instead of spaces)
  	446: Wrong indent style found (tabs instead of spaces)
  	447: Wrong indent style found (tabs instead of spaces)
  	448: Wrong indent style found (tabs instead of spaces)
  	449: Wrong indent style found (tabs instead of spaces)
  	450: Wrong indent style found (tabs instead of spaces)
  	451: Wrong indent style found (tabs instead of spaces)
  	452: Wrong indent style found (tabs instead of spaces)
  	453: Wrong indent style found (tabs instead of spaces)
  	454: Wrong indent style found (tabs instead of spaces)
  	455: Wrong indent style found (tabs instead of spaces)
  	456: Wrong indent style found (tabs instead of spaces)
  	457: Wrong indent style found (tabs instead of spaces)
  	458: Wrong indent style found (tabs instead of spaces)
  	459: Wrong indent style found (tabs instead of spaces)
  	460: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/util/MessageSerializer.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	5: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/util/MsgPackMessageSerializer.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	12: Wrong indent style found (tabs instead of spaces)
  	13: Wrong indent style found (tabs instead of spaces)
  	14: Wrong indent style found (tabs instead of spaces)
  	15: Wrong indent style found (tabs instead of spaces)
  	16: Wrong indent style found (tabs instead of spaces)
  	17: Wrong indent style found (tabs instead of spaces)
  	18: Wrong indent style found (tabs instead of spaces)
  	19: Wrong indent style found (tabs instead of spaces)
  	20: Wrong indent style found (tabs instead of spaces)
  	21: Wrong indent style found (tabs instead of spaces)
  	22: Wrong indent style found (tabs instead of spaces)
  	23: Wrong indent style found (tabs instead of spaces)
  	24: Wrong indent style found (tabs instead of spaces)
  	25: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/model/CreateMessageVO.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	9: Wrong indent style found (tabs instead of spaces)
  	10: Wrong indent style found (tabs instead of spaces)
  	11: Wrong indent style found (tabs instead of spaces)
  	12: Wrong indent style found (tabs instead of spaces)
  	13: Wrong indent style found (tabs instead of spaces)
  	14: Wrong indent style found (tabs instead of spaces)
  	15: Wrong indent style found (tabs instead of spaces)
  	16: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/util/ProtobufMessageSerializer.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	24: Wrong indent style found (tabs instead of spaces)
  	25: Wrong indent style found (tabs instead of spaces)
  	27: Wrong indent style found (tabs instead of spaces)
  	29: Wrong indent style found (tabs instead of spaces)
  	30: Wrong indent style found (tabs instead of spaces)
  	31: Wrong indent style found (tabs instead of spaces)
  	32: Wrong indent style found (tabs instead of spaces)
  	34: Wrong indent style found (tabs instead of spaces)
  	35: Wrong indent style found (tabs instead of spaces)
  	36: Wrong indent style found (tabs instead of spaces)
  	37: Wrong indent style found (tabs instead of spaces)
  	39: Wrong indent style found (tabs instead of spaces)
  	40: Wrong indent style found (tabs instead of spaces)
  	41: Wrong indent style found (tabs instead of spaces)
  	42: Wrong indent style found (tabs instead of spaces)
  	43: Wrong indent style found (tabs instead of spaces)
  	44: Wrong indent style found (tabs instead of spaces)
  	46: Wrong indent style found (tabs instead of spaces)
  	47: Wrong indent style found (tabs instead of spaces)
  	49: Wrong indent style found (tabs instead of spaces)
  	50: Wrong indent style found (tabs instead of spaces)
  	51: Wrong indent style found (tabs instead of spaces)
  	52: Wrong indent style found (tabs instead of spaces)
  	53: Wrong indent style found (tabs instead of spaces)
  	54: Wrong indent style found (tabs instead of spaces)
  	55: Wrong indent style found (tabs instead of spaces)
  	56: Wrong indent style found (tabs instead of spaces)
  	57: Wrong indent style found (tabs instead of spaces)
  	58: Wrong indent style found (tabs instead of spaces)
  	59: Wrong indent style found (tabs instead of spaces)
  	60: Wrong indent style found (tabs instead of spaces)
  	61: Wrong indent style found (tabs instead of spaces)
  	62: Wrong indent style found (tabs instead of spaces)
  	63: Wrong indent style found (tabs instead of spaces)
  	64: Wrong indent style found (tabs instead of spaces)
  	65: Wrong indent style found (tabs instead of spaces)
  	66: Wrong indent style found (tabs instead of spaces)
  	67: Wrong indent style found (tabs instead of spaces)
  	68: Wrong indent style found (tabs instead of spaces)
  	69: Wrong indent style found (tabs instead of spaces)
  	70: Wrong indent style found (tabs instead of spaces)
  	71: Wrong indent style found (tabs instead of spaces)
  	72: Wrong indent style found (tabs instead of spaces)
  	73: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/util/SerializationException.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	5: Wrong indent style found (tabs instead of spaces)
  	6: Wrong indent style found (tabs instead of spaces)
  	7: Wrong indent style found (tabs instead of spaces)
  	8: Wrong indent style found (tabs instead of spaces)
  	9: Wrong indent style found (tabs instead of spaces)
  	10: Wrong indent style found (tabs instead of spaces)
  	11: Wrong indent style found (tabs instead of spaces)
  	12: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/service/KafkaHighLevelProducer.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	24: Wrong indent style found (tabs instead of spaces)
  	26: Wrong indent style found (tabs instead of spaces)
  	28: Wrong indent style found (tabs instead of spaces)
  	30: Wrong indent style found (tabs instead of spaces)
  	31: Wrong indent style found (tabs instead of spaces)
  	32: Wrong indent style found (tabs instead of spaces)
  	34: Wrong indent style found (tabs instead of spaces)
  	35: Wrong indent style found (tabs instead of spaces)
  	36: Wrong indent style found (tabs instead of spaces)
  	37: Wrong indent style found (tabs instead of spaces)
  	38: Wrong indent style found (tabs instead of spaces)
  	39: Wrong indent style found (tabs instead of spaces)
  	40: Wrong indent style found (tabs instead of spaces)
  	41: Wrong indent style found (tabs instead of spaces)
  	42: Wrong indent style found (tabs instead of spaces)
  	43: Wrong indent style found (tabs instead of spaces)
  	44: Wrong indent style found (tabs instead of spaces)
  	45: Wrong indent style found (tabs instead of spaces)
  	46: Wrong indent style found (tabs instead of spaces)
  	47: Wrong indent style found (tabs instead of spaces)
  	48: Wrong indent style found (tabs instead of spaces)
  	49: Wrong indent style found (tabs instead of spaces)
  	50: Wrong indent style found (tabs instead of spaces)
  	51: Wrong indent style found (tabs instead of spaces)
  	52: Wrong indent style found (tabs instead of spaces)
  	53: Wrong indent style found (tabs instead of spaces)
  	54: Wrong indent style found (tabs instead of spaces)
  	55: Wrong indent style found (tabs instead of spaces)
  	56: Wrong indent style found (tabs instead of spaces)
  	58: Wrong indent style found (tabs instead of spaces)
  	59: Wrong indent style found (tabs instead of spaces)
  	60: Wrong indent style found (tabs instead of spaces)
  	61: Wrong indent style found (tabs instead of spaces)
  	62: Wrong indent style found (tabs instead of spaces)
  	63: Wrong indent style found (tabs instead of spaces)
  	64: Wrong indent style found (tabs instead of spaces)
  	65: Wrong indent style found (tabs instead of spaces)
  	66: Wrong indent style found (tabs instead of spaces)
  	67: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/util/Serializers.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	5: Wrong indent style found (tabs instead of spaces)
  	6: Wrong indent style found (tabs instead of spaces)
  	7: Wrong indent style found (tabs instead of spaces)
  	8: Wrong indent style found (tabs instead of spaces)
  	9: Wrong indent style found (tabs instead of spaces)
  	10: Wrong indent style found (tabs instead of spaces)
  	11: Wrong indent style found (tabs instead of spaces)
  	13: Wrong indent style found (tabs instead of spaces)
  	14: Wrong indent style found (tabs instead of spaces)
  	15: Wrong indent style found (tabs instead of spaces)
  	17: Wrong indent style found (tabs instead of spaces)
  	18: Wrong indent style found (tabs instead of spaces)
  	19: Wrong indent style found (tabs instead of spaces)
  	20: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/service/KafkaMonitorImpl.java:
  	49: Line too long (159 instead of 120)
  	406: Wrong indent style found (tabs instead of spaces)
  	407: Wrong indent style found (tabs instead of spaces)
  	408: Wrong indent style found (tabs instead of spaces)
  	409: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/service/KafkaProducerException.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	8: Wrong indent style found (tabs instead of spaces)
  	9: Wrong indent style found (tabs instead of spaces)
  	10: Wrong indent style found (tabs instead of spaces)
  	11: Wrong indent style found (tabs instead of spaces)
  	12: Wrong indent style found (tabs instead of spaces)
  	13: Wrong indent style found (tabs instead of spaces)
  	14: Wrong indent style found (tabs instead of spaces)
  	15: Wrong indent style found (tabs instead of spaces)
  src/main/java/kafdrop/util/AvroMessageSerializer.java:
  	Wrong line endings or no final newline
  	Not all lines have the correct end of line character
  	10: Wrong indent style found (tabs instead of spaces)
  	11: Wrong indent style found (tabs instead of spaces)
  	13: Wrong indent style found (tabs instead of spaces)
  	14: Wrong indent style found (tabs instead of spaces)
  	15: Wrong indent style found (tabs instead of spaces)
  	16: Wrong indent style found (tabs instead of spaces)
  	18: Wrong indent style found (tabs instead of spaces)
  	19: Wrong indent style found (tabs instead of spaces)
  	20: Wrong indent style found (tabs instead of spaces)
  	21: Wrong indent style found (tabs instead of spaces)
  	22: Wrong indent style found (tabs instead of spaces)
  	24: Wrong indent style found (tabs instead of spaces)
  	25: Wrong indent style found (tabs instead of spaces)
  	26: Wrong indent style found (tabs instead of spaces)
  	27: Wrong indent style found (tabs instead of spaces)
  	28: Wrong indent style found (tabs instead of spaces)
  	29: Wrong indent style found (tabs instead of spaces)
  	30: Wrong indent style found (tabs instead of spaces)
  	31: Wrong indent style found (tabs instead of spaces)
  	32: Wrong indent style found (tabs instead of spaces)
  	33: Wrong indent style found (tabs instead of spaces)
  	34: Wrong indent style found (tabs instead of spaces)
  
243 errors found

Comment on lines +215 to +218
if (partitionOpt.isEmpty()) {
throw new IllegalArgumentException("Partition does not exist in topic");
}
partitions = List.of(partitionOpt.get());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a little more compact:

Suggested change
if (partitionOpt.isEmpty()) {
throw new IllegalArgumentException("Partition does not exist in topic");
}
partitions = List.of(partitionOpt.get());
partitions = List.of(partitionOpt.orElseThrow(() -> new IllegalArgumentException("Partition " + partition + " does not exist in topic")));

}
}

public RecordMetadata publishMessage(CreateMessageVO message, Serializers searilazers) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error:

Suggested change
public RecordMetadata publishMessage(CreateMessageVO message, Serializers searilazers) {
public RecordMetadata publishMessage(CreateMessageVO message, Serializers serializers) {

Comment on lines +31 to +32
import kafdrop.model.*;
import kafdrop.util.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use wildcard imports as that is not our coding convention.

Comment on lines +21 to +35
import kafdrop.model.*;
import kafdrop.util.*;
import org.apache.kafka.clients.admin.*;
import org.apache.kafka.clients.admin.ConfigEntry.*;
import org.apache.kafka.clients.consumer.*;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.*;
import org.apache.kafka.common.header.*;
import org.slf4j.*;
import org.springframework.stereotype.*;

import java.util.*;
import java.util.Map.*;
import java.util.function.*;
import java.util.stream.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use wildcard imports as that is not our coding convention.

@@ -38,6 +38,7 @@ kafdrop.monitor:

kafka:
brokerConnect: localhost:9092
isSecured: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants