Search in sources :

Example 1 with PartitionLeaderTermsEncoder

use of io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder in project zeebe by zeebe-io.

the class BrokerInfo method write.

// TODO: This will be fixed in the https://github.com/zeebe-io/zeebe/issues/5640
@Override
public void write(final MutableDirectBuffer buffer, int offset) {
    headerEncoder.wrap(buffer, offset).blockLength(bodyEncoder.sbeBlockLength()).templateId(bodyEncoder.sbeTemplateId()).schemaId(bodyEncoder.sbeSchemaId()).version(bodyEncoder.sbeSchemaVersion());
    offset += headerEncoder.encodedLength();
    bodyEncoder.wrap(buffer, offset).nodeId(nodeId).partitionsCount(partitionsCount).clusterSize(clusterSize).replicationFactor(replicationFactor);
    final int addressesCount = addresses.size();
    final AddressesEncoder addressesEncoder = bodyEncoder.addressesCount(addressesCount);
    if (addressesCount > 0) {
        for (final Entry<DirectBuffer, DirectBuffer> entry : addresses.entrySet()) {
            final DirectBuffer apiName = entry.getKey();
            final DirectBuffer address = entry.getValue();
            addressesEncoder.next().putApiName(apiName, 0, apiName.capacity()).putAddress(address, 0, address.capacity());
        }
    }
    final int partitionRolesCount = partitionRoles.size();
    final PartitionRolesEncoder partitionRolesEncoder = bodyEncoder.partitionRolesCount(partitionRolesCount);
    if (partitionRolesCount > 0) {
        for (final Entry<Integer, PartitionRole> entry : partitionRoles.entrySet()) {
            partitionRolesEncoder.next().partitionId(entry.getKey()).role(entry.getValue());
        }
    }
    final int partitionLeaderTermsCount = partitionLeaderTerms.size();
    final PartitionLeaderTermsEncoder partitionLeaderTermsEncoder = bodyEncoder.partitionLeaderTermsCount(partitionLeaderTermsCount);
    if (partitionLeaderTermsCount > 0) {
        for (final Entry<Integer, Long> entry : partitionLeaderTerms.entrySet()) {
            partitionLeaderTermsEncoder.next().partitionId(entry.getKey()).term(entry.getValue());
        }
    }
    bodyEncoder.putVersion(version, 0, version.capacity());
    final int partitionHealthCount = partitionHealthStatuses.size();
    final PartitionHealthEncoder partitionHealthEncoder = bodyEncoder.partitionHealthCount(partitionHealthCount);
    if (partitionHealthCount > 0) {
        for (final Entry<Integer, PartitionHealthStatus> entry : partitionHealthStatuses.entrySet()) {
            partitionHealthEncoder.next().partitionId(entry.getKey()).healthStatus(entry.getValue());
        }
    }
}
Also used : AddressesEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.AddressesEncoder) PartitionLeaderTermsEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder) PartitionHealthStatus(io.camunda.zeebe.protocol.record.PartitionHealthStatus) PartitionRole(io.camunda.zeebe.protocol.record.PartitionRole) PartitionHealthEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionHealthEncoder) MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) PartitionRolesEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionRolesEncoder)

Example 2 with PartitionLeaderTermsEncoder

use of io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder in project zeebe by camunda-cloud.

the class BrokerInfo method write.

// TODO: This will be fixed in the https://github.com/zeebe-io/zeebe/issues/5640
@Override
public void write(final MutableDirectBuffer buffer, int offset) {
    headerEncoder.wrap(buffer, offset).blockLength(bodyEncoder.sbeBlockLength()).templateId(bodyEncoder.sbeTemplateId()).schemaId(bodyEncoder.sbeSchemaId()).version(bodyEncoder.sbeSchemaVersion());
    offset += headerEncoder.encodedLength();
    bodyEncoder.wrap(buffer, offset).nodeId(nodeId).partitionsCount(partitionsCount).clusterSize(clusterSize).replicationFactor(replicationFactor);
    final int addressesCount = addresses.size();
    final AddressesEncoder addressesEncoder = bodyEncoder.addressesCount(addressesCount);
    if (addressesCount > 0) {
        for (final Entry<DirectBuffer, DirectBuffer> entry : addresses.entrySet()) {
            final DirectBuffer apiName = entry.getKey();
            final DirectBuffer address = entry.getValue();
            addressesEncoder.next().putApiName(apiName, 0, apiName.capacity()).putAddress(address, 0, address.capacity());
        }
    }
    final int partitionRolesCount = partitionRoles.size();
    final PartitionRolesEncoder partitionRolesEncoder = bodyEncoder.partitionRolesCount(partitionRolesCount);
    if (partitionRolesCount > 0) {
        for (final Entry<Integer, PartitionRole> entry : partitionRoles.entrySet()) {
            partitionRolesEncoder.next().partitionId(entry.getKey()).role(entry.getValue());
        }
    }
    final int partitionLeaderTermsCount = partitionLeaderTerms.size();
    final PartitionLeaderTermsEncoder partitionLeaderTermsEncoder = bodyEncoder.partitionLeaderTermsCount(partitionLeaderTermsCount);
    if (partitionLeaderTermsCount > 0) {
        for (final Entry<Integer, Long> entry : partitionLeaderTerms.entrySet()) {
            partitionLeaderTermsEncoder.next().partitionId(entry.getKey()).term(entry.getValue());
        }
    }
    bodyEncoder.putVersion(version, 0, version.capacity());
    final int partitionHealthCount = partitionHealthStatuses.size();
    final PartitionHealthEncoder partitionHealthEncoder = bodyEncoder.partitionHealthCount(partitionHealthCount);
    if (partitionHealthCount > 0) {
        for (final Entry<Integer, PartitionHealthStatus> entry : partitionHealthStatuses.entrySet()) {
            partitionHealthEncoder.next().partitionId(entry.getKey()).healthStatus(entry.getValue());
        }
    }
}
Also used : AddressesEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.AddressesEncoder) PartitionLeaderTermsEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder) PartitionHealthStatus(io.camunda.zeebe.protocol.record.PartitionHealthStatus) PartitionRole(io.camunda.zeebe.protocol.record.PartitionRole) PartitionHealthEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionHealthEncoder) MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) PartitionRolesEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionRolesEncoder)

Example 3 with PartitionLeaderTermsEncoder

use of io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder in project zeebe by camunda.

the class BrokerInfo method write.

// TODO: This will be fixed in the https://github.com/zeebe-io/zeebe/issues/5640
@Override
public void write(final MutableDirectBuffer buffer, int offset) {
    headerEncoder.wrap(buffer, offset).blockLength(bodyEncoder.sbeBlockLength()).templateId(bodyEncoder.sbeTemplateId()).schemaId(bodyEncoder.sbeSchemaId()).version(bodyEncoder.sbeSchemaVersion());
    offset += headerEncoder.encodedLength();
    bodyEncoder.wrap(buffer, offset).nodeId(nodeId).partitionsCount(partitionsCount).clusterSize(clusterSize).replicationFactor(replicationFactor);
    final int addressesCount = addresses.size();
    final AddressesEncoder addressesEncoder = bodyEncoder.addressesCount(addressesCount);
    if (addressesCount > 0) {
        for (final Entry<DirectBuffer, DirectBuffer> entry : addresses.entrySet()) {
            final DirectBuffer apiName = entry.getKey();
            final DirectBuffer address = entry.getValue();
            addressesEncoder.next().putApiName(apiName, 0, apiName.capacity()).putAddress(address, 0, address.capacity());
        }
    }
    final int partitionRolesCount = partitionRoles.size();
    final PartitionRolesEncoder partitionRolesEncoder = bodyEncoder.partitionRolesCount(partitionRolesCount);
    if (partitionRolesCount > 0) {
        for (final Entry<Integer, PartitionRole> entry : partitionRoles.entrySet()) {
            partitionRolesEncoder.next().partitionId(entry.getKey()).role(entry.getValue());
        }
    }
    final int partitionLeaderTermsCount = partitionLeaderTerms.size();
    final PartitionLeaderTermsEncoder partitionLeaderTermsEncoder = bodyEncoder.partitionLeaderTermsCount(partitionLeaderTermsCount);
    if (partitionLeaderTermsCount > 0) {
        for (final Entry<Integer, Long> entry : partitionLeaderTerms.entrySet()) {
            partitionLeaderTermsEncoder.next().partitionId(entry.getKey()).term(entry.getValue());
        }
    }
    bodyEncoder.putVersion(version, 0, version.capacity());
    final int partitionHealthCount = partitionHealthStatuses.size();
    final PartitionHealthEncoder partitionHealthEncoder = bodyEncoder.partitionHealthCount(partitionHealthCount);
    if (partitionHealthCount > 0) {
        for (final Entry<Integer, PartitionHealthStatus> entry : partitionHealthStatuses.entrySet()) {
            partitionHealthEncoder.next().partitionId(entry.getKey()).healthStatus(entry.getValue());
        }
    }
}
Also used : AddressesEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.AddressesEncoder) PartitionLeaderTermsEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder) PartitionHealthStatus(io.camunda.zeebe.protocol.record.PartitionHealthStatus) PartitionRole(io.camunda.zeebe.protocol.record.PartitionRole) PartitionHealthEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionHealthEncoder) MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) PartitionRolesEncoder(io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionRolesEncoder)

Aggregations

AddressesEncoder (io.camunda.zeebe.protocol.record.BrokerInfoEncoder.AddressesEncoder)3 PartitionHealthEncoder (io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionHealthEncoder)3 PartitionLeaderTermsEncoder (io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionLeaderTermsEncoder)3 PartitionRolesEncoder (io.camunda.zeebe.protocol.record.BrokerInfoEncoder.PartitionRolesEncoder)3 PartitionHealthStatus (io.camunda.zeebe.protocol.record.PartitionHealthStatus)3 PartitionRole (io.camunda.zeebe.protocol.record.PartitionRole)3 DirectBuffer (org.agrona.DirectBuffer)3 MutableDirectBuffer (org.agrona.MutableDirectBuffer)3