-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 bytesIn/OutPerSec params for clusterMetrics object #56
Conversation
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/ClusterUtil.java
Outdated
Show resolved
Hide resolved
public static Map<String, String> getJmxTrafficMetrics(String jmxUrl, String metricName) { | ||
Map<String, String> result = new HashMap<>(); | ||
try { | ||
JMXServiceURL url = new JMXServiceURL(jmxUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's bad idea to create connection each time, please use connection pool
// TODO: fill bytes in/out metrics | ||
Map<String, String> bytesInPerSec; | ||
Map<String, String> bytesOutPerSec; | ||
var jmx = kafkaJmxDto.getJmxParams().stream().filter(j -> j.getBrokerId() == c.id()).findFirst().orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should get broker addresses from kafka cluster and use preconfigured jmx port
@@ -1,4 +1,12 @@ | |||
kafka: | |||
jmxParams: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's configure only jmx port per cluster and discovery brokers from cluster
|
@@ -19,5 +19,7 @@ | |||
String name; | |||
String bootstrapServers; | |||
String zookeeper; | |||
int jmxPort; | |||
String jmxHost; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
List<Jmx> jmxParams = new ArrayList<>(); | ||
|
||
@Data | ||
public static class Jmx { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be configured only on cluster level
//TODO: find way to fill | ||
private final int bytesInPerSec; | ||
private final int bytesOutPerSec; | ||
private final Map<String, String> bytesInPerSec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BigDecimal
|
||
private static final List<String> attrNames = Arrays.asList("OneMinuteRate", "FiveMinuteRate", "FifteenMinuteRate"); | ||
|
||
private static KeyedObjectPool pool = new GenericKeyedObjectPool(new JmxPoolFactory()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to bean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configure min/max connections
Map<String, String> result = new HashMap<>(); | ||
JMXConnector srv = null; | ||
try { | ||
srv = (JMXConnector) pool.borrowObject(jmxUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try with resources
public Mono<ExtendedAdminClient> getOrCreateAdminClient(KafkaCluster cluster) { | ||
Consumer<Long, String> kek = createConsumer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug?
@@ -4,14 +4,23 @@ kafka: | |||
name: local | |||
bootstrapServers: localhost:29091 | |||
zookeeper: localhost:2183 | |||
jmxPort: 9997 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only port
@@ -303,9 +303,13 @@ components: | |||
topicCount: | |||
type: integer | |||
bytesInPerSec: | |||
type: integer | |||
type: object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number
bytesOutPerSec: | ||
type: integer | ||
type: object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just a number, why object?
kafka-ui-api/pom.xml
Outdated
@@ -85,6 +85,12 @@ | |||
<artifactId>reactor-test</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.commons</groupId> | |||
<artifactId>commons-dbcp2</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commons-pool?
…emoved redundant methods and code
import reactor.core.publisher.Mono; | ||
|
||
import javax.management.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this one is used here
InternalClusterMetrics.InternalClusterMetricsBuilder metricsBuilder = InternalClusterMetrics.builder(); | ||
metricsBuilder.brokerCount(brokers.size()).activeControllers(c != null ? 1 : 0); | ||
// TODO: fill bytes in/out metrics | ||
Map<String, BigDecimal> bytesInPerSec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you initialize it before method invocation?
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/config/Config.java
Outdated
Show resolved
Hide resolved
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/JmxClusterUtil.java
Outdated
Show resolved
Hide resolved
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/JmxClusterUtil.java
Outdated
Show resolved
Hide resolved
kafka-ui-api/src/main/java/com/provectus/kafka/ui/kafka/KafkaService.java
Outdated
Show resolved
Hide resolved
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/JmxClusterUtil.java
Outdated
Show resolved
Hide resolved
* Added bytesIn/OutPerSec params for clusterMetrics object * Removed redundant todos, cleaned imports * Jmx connections moved to pool, methods moved to separate classes * Added pool handling and returning methods * Fix after previous PR comments - fixed result map, configured pool, removed redundant methods and code * Removed redundant imports and empty initialization * Removed fill method * Closing connection replaced to destroyObject method * Try catch block while returning object to pool was fixed * Removed redundant logs and try catch Co-authored-by: Roman Nedzvetskiy <roman@Romans-MacBook-Pro.local>
No description provided.