use of org.apache.kafka.server.common.ApiMessageAndVersion in project kafka by apache.
the class ClusterImage method write.
public void write(Consumer<List<ApiMessageAndVersion>> out) {
List<ApiMessageAndVersion> batch = new ArrayList<>();
for (BrokerRegistration broker : brokers.values()) {
batch.add(broker.toRecord());
}
out.accept(batch);
}
use of org.apache.kafka.server.common.ApiMessageAndVersion in project kafka by apache.
the class StandardAclRecordIterator method next.
@Override
public List<ApiMessageAndVersion> next() {
if (!hasNext())
throw new NoSuchElementException();
List<ApiMessageAndVersion> result = new ArrayList<>(10);
for (int i = 0; i < maxRecordsInBatch; i++) {
if (!iterator.hasNext())
break;
StandardAclWithId aclWithId = iterator.next();
result.add(new ApiMessageAndVersion(aclWithId.toRecord(), (short) 0));
}
return result;
}
use of org.apache.kafka.server.common.ApiMessageAndVersion in project kafka by apache.
the class BrokerRegistration method toRecord.
public ApiMessageAndVersion toRecord() {
RegisterBrokerRecord registrationRecord = new RegisterBrokerRecord().setBrokerId(id).setRack(rack.orElse(null)).setBrokerEpoch(epoch).setIncarnationId(incarnationId).setFenced(fenced);
for (Entry<String, Endpoint> entry : listeners.entrySet()) {
Endpoint endpoint = entry.getValue();
registrationRecord.endPoints().add(new BrokerEndpoint().setName(entry.getKey()).setHost(endpoint.host()).setPort(endpoint.port()).setSecurityProtocol(endpoint.securityProtocol().id));
}
for (Entry<String, VersionRange> entry : supportedFeatures.entrySet()) {
registrationRecord.features().add(new BrokerFeature().setName(entry.getKey()).setMinSupportedVersion(entry.getValue().min()).setMaxSupportedVersion(entry.getValue().max()));
}
return new ApiMessageAndVersion(registrationRecord, REGISTER_BROKER_RECORD.highestSupportedVersion());
}
use of org.apache.kafka.server.common.ApiMessageAndVersion in project kafka by apache.
the class RemoteLogMetadataSerde method serialize.
public byte[] serialize(RemoteLogMetadata remoteLogMetadata) {
Short apiKey = remoteLogStorageClassToApiKey.get(remoteLogMetadata.getClass().getName());
if (apiKey == null) {
throw new IllegalArgumentException("ApiKey for given RemoteStorageMetadata class: " + remoteLogMetadata.getClass() + " does not exist.");
}
@SuppressWarnings("unchecked") ApiMessageAndVersion apiMessageAndVersion = remoteLogMetadataTransform(apiKey).toApiMessageAndVersion(remoteLogMetadata);
return bytesApiMessageSerde.serialize(apiMessageAndVersion);
}
Aggregations