DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
org.apache.kafka.common.utils.AppInfoParser.AppInfoMBean
Proposed Changes
1) Update the AppInfoMBean interface to The new MBean will include a new method getClientId().tag, client-id
| Code Block |
|---|
publicprivate interfacestatic AppInfoMBean { void registerMetrics(Metrics metrics, AppInfo appInfo, String getVersion(clientId); String getCommitId(); { Longif getStartTimeMs(); metrics != null && String getClientId(); } |
2) Deprecated the old AppInfoMBean implementation and marked it as @Deprecated.
| Code Block |
|---|
@Deprecated(since = "4.2")
public static class DeprecatedAppInfo implements AppInfoMBean {
} |
3) Introduced a new implementation of AppInfoMBean.
| Code Block |
|---|
public static class AppInfo implements AppInfoMBean { private final Long startTimeMs; public AppInfo(long startTimeMs) { this.startTimeMs = startTimeMsclientId != null) { metrics.addMetric(metricName(metrics, "version", Map.of("client-id", clientId)), new ImmutableValue<>(appInfo.getVersion())); metrics.addMetric(metricName(metrics, "commit-id", Map.of("client-id", clientId)), new ImmutableValue<>(appInfo.getCommitId())); logmetrics.info("Kafka version: {}", AppInfoParser.getVersion(addMetric(metricName(metrics, "start-time-ms", Map.of("client-id", clientId)), new ImmutableValue<>(appInfo.getStartTimeMs())); } else if log.info("Kafka commitId: {}", AppInfoParser.getCommitId());(metrics != null) { logmetrics.info("Kafka startTimeMs: {}", startTimeMsaddMetric(metricName(metrics, "version", Map.of()), new ImmutableValue<>(appInfo.getVersion())); logmetrics.info("Kafka client id: {}addMetric(metricName(metrics, "commit-id", AppInfoParserMap.getClientIdof()); , } // skip... new ImmutableValue<>(appInfo.getCommitId())); @Override public String getClientId() { return AppInfoParser.getClientId(metrics.addMetric(metricName(metrics, "start-time-ms", Map.of()), new ImmutableValue<>(appInfo.getStartTimeMs())); } } |
42) When AppInfoParser registers an MBean, it will register both the new and the deprecated implementationsMBean.
| Code Block | ||
|---|---|---|
| ||
public static synchronized void registerAppInfo(String prefix, String id, Metrics metrics, long nowMs) {
try {
// skip...
registerMetrics(metrics, mBean, DeprecatedAppInfo deprecatedMBean = new DeprecatedAppInfo(nowMs);null); // prefix will be added later by JmxReporter
registerMetrics(metrics, mBean, CLIENT_ID);
} catch (JMException e) {
AppInfo mBean = new AppInfo(nowMs);log.warn("Error registering AppInfo mbean", e);
}
} |
3) When unregisters an MBean, also remove the new and deprecated MBean.
| Code Block |
|---|
private static void unregisterMetrics(Metrics metrics, String clientId) { if (metrics != null && clientId != null) { server.registerMBean(deprecatedMBean, namemetrics.removeMetric(metricName(metrics, "version", Map.of("client-id", clientId))); metrics.removeMetric(metricName(metrics, server.registerMBean(mBean, name"commit-id", Map.of("client-id", clientId))); registerMetricsmetrics.removeMetric(metricName(metrics, mBean); // prefix will be added later by JmxReporter "start-time-ms", Map.of("client-id", clientId))); } else if (metrics != null) { } catch (JMException e) {metrics.removeMetric(metricName(metrics, "version", Map.of())); logmetrics.warn("Error registering AppInfo mbean", eremoveMetric(metricName(metrics, "commit-id", Map.of())); metrics.removeMetric(metricName(metrics, "start-time-ms", Map.of())); } } |
Compatibility, Deprecation, and Migration Plan
...