use of org.apache.kafka.common.metadata.FenceBrokerRecord in project kafka by apache.
the class ReplicationControlManager method handleBrokerFenced.
/**
* Generate the appropriate records to handle a broker being fenced.
*
* First, we remove this broker from any non-singleton ISR. Then we generate a
* FenceBrokerRecord.
*
* @param brokerId The broker id.
* @param records The record list to append to.
*/
void handleBrokerFenced(int brokerId, List<ApiMessageAndVersion> records) {
BrokerRegistration brokerRegistration = clusterControl.brokerRegistrations().get(brokerId);
if (brokerRegistration == null) {
throw new RuntimeException("Can't find broker registration for broker " + brokerId);
}
generateLeaderAndIsrUpdates("handleBrokerFenced", brokerId, NO_LEADER, records, brokersToIsrs.partitionsWithBrokerInIsr(brokerId));
records.add(new ApiMessageAndVersion(new FenceBrokerRecord().setId(brokerId).setEpoch(brokerRegistration.epoch()), FENCE_BROKER_RECORD.highestSupportedVersion()));
}
use of org.apache.kafka.common.metadata.FenceBrokerRecord in project kafka by apache.
the class MetadataNodeManagerTest method testUnfenceBrokerRecordAndFenceBrokerRecord.
@Test
public void testUnfenceBrokerRecordAndFenceBrokerRecord() {
RegisterBrokerRecord record = new RegisterBrokerRecord().setBrokerId(1).setBrokerEpoch(2);
metadataNodeManager.handleMessage(record);
assertEquals("true", metadataNodeManager.getData().root().directory("brokers", "1").file("isFenced").contents());
UnfenceBrokerRecord unfenceBrokerRecord = new UnfenceBrokerRecord().setId(1).setEpoch(2);
metadataNodeManager.handleMessage(unfenceBrokerRecord);
assertEquals("false", metadataNodeManager.getData().root().directory("brokers", "1").file("isFenced").contents());
FenceBrokerRecord fenceBrokerRecord = new FenceBrokerRecord().setId(1).setEpoch(2);
metadataNodeManager.handleMessage(fenceBrokerRecord);
assertEquals("true", metadataNodeManager.getData().root().directory("brokers", "1").file("isFenced").contents());
}
Aggregations