Search in sources :

Example 1 with UpdateMetadataTopicState

use of org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataTopicState in project kafka by apache.

the class UpdateMetadataRequest method normalize.

private void normalize() {
    // Version 3 added support for listener name, which we can infer from the security protocol for older versions
    if (version() < 3) {
        for (UpdateMetadataBroker liveBroker : data.liveBrokers()) {
            // Set endpoints so that callers can rely on it always being present
            if (version() == 0 && liveBroker.endpoints().isEmpty()) {
                SecurityProtocol securityProtocol = SecurityProtocol.PLAINTEXT;
                liveBroker.setEndpoints(singletonList(new UpdateMetadataEndpoint().setHost(liveBroker.v0Host()).setPort(liveBroker.v0Port()).setSecurityProtocol(securityProtocol.id).setListener(ListenerName.forSecurityProtocol(securityProtocol).value())));
            } else {
                for (UpdateMetadataEndpoint endpoint : liveBroker.endpoints()) {
                    // Set listener so that callers can rely on it always being present
                    if (endpoint.listener().isEmpty())
                        endpoint.setListener(listenerNameFromSecurityProtocol(endpoint));
                }
            }
        }
    }
    if (version() >= 5) {
        for (UpdateMetadataTopicState topicState : data.topicStates()) {
            for (UpdateMetadataPartitionState partitionState : topicState.partitionStates()) {
                // Set the topic name so that we can always present the ungrouped view to callers
                partitionState.setTopicName(topicState.topicName());
            }
        }
    }
}
Also used : UpdateMetadataBroker(org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataBroker) SecurityProtocol(org.apache.kafka.common.security.auth.SecurityProtocol) UpdateMetadataTopicState(org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataTopicState) UpdateMetadataEndpoint(org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataEndpoint) UpdateMetadataPartitionState(org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataPartitionState)

Aggregations

UpdateMetadataBroker (org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataBroker)1 UpdateMetadataEndpoint (org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataEndpoint)1 UpdateMetadataPartitionState (org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataPartitionState)1 UpdateMetadataTopicState (org.apache.kafka.common.message.UpdateMetadataRequestData.UpdateMetadataTopicState)1 SecurityProtocol (org.apache.kafka.common.security.auth.SecurityProtocol)1