def get_offset_topic_partition_count(kafka_config): """Given a kafka cluster configuration, return the number of partitions in the offset topic. It will raise an UnknownTopic exception if the topic cannot be found.""" metadata = get_topic_partition_metadata(kafka_config.broker_list) if CONSUMER_OFFSET_TOPIC not in metadata: raise UnknownTopic("Consumer offset topic is missing.") return len(metadata[CONSUMER_OFFSET_TOPIC])
def run_command(self): """Min_isr command, checks number of actual min-isr for each topic-partition with configuration for that topic.""" topics = get_topic_partition_metadata(self.cluster_config.broker_list) not_in_sync = _process_metadata_response( topics, self.zk, self.args.default_min_isr, ) errcode = status_code.OK if not not_in_sync else status_code.CRITICAL out = _prepare_output(not_in_sync, self.args.verbose, self.args.head) return errcode, out
def _get_under_replicated(broker_list): """Requests kafka-broker for metadata info for topics. Then checks if topic-partition is under replicated and there are not enough replicas in sync. Returns set of under replicated partitions. :param dictionary broker_list: dictionary with brokers information, broker_id is key :returns set: with under replicated partitions * set: { (topic, partition), ... } """ metadata = get_topic_partition_metadata(broker_list) return _process_topic_partition_metadata(metadata)
def run_command(self): """Min_isr command, checks number of actual min-isr for each topic-partition with configuration for that topic.""" topics = get_topic_partition_metadata(self.cluster_config.broker_list) not_in_sync = _process_metadata_response( topics, self.zk, self.args.default_min_isr, ) errcode = status_code.OK if not not_in_sync else status_code.CRITICAL out = _prepare_output(not_in_sync, self.args.verbose) return errcode, out
def run_command(self): """Replication factor command, checks replication factor settings and compare it with min.isr in the cluster.""" topics = get_topic_partition_metadata(self.cluster_config.broker_list) topics_with_wrong_rf = _find_topics_with_wrong_rp( topics, self.zk, self.args.default_min_isr, ) errcode = status_code.OK if not topics_with_wrong_rf else status_code.CRITICAL out = _prepare_output(topics_with_wrong_rf, self.args.verbose) return errcode, out
def run_command(self): """Min_isr command, checks number of actual min-isr for each topic-partition with configuration for that topic.""" topics = get_topic_partition_metadata(self.cluster_config.broker_list) not_in_sync = process_metadata_response( topics, self.zk, self.args.default_min_isr, self.args.verbose, ) if not_in_sync == 0: return status_code.OK, "All replicas in sync." else: msg = ("{0} partition(s) have the number of replicas in " "sync that is lower than the specified min ISR.").format(not_in_sync) return status_code.CRITICAL, msg