@SuppressWarnings("unchecked") @Test public void typical() throws Exception { PartitionReplica replica = new PartitionReplica(1, true, false, 3L, 2L, 4L, 5L, 1L); List<PartitionReplica> replicas = singletonList(replica); Topic topic = new Topic("topicName", Duration.ofMillis(2L), replicas); LogDir logDir = new LogDir("path", 1L, 3L, singletonList(topic)); List<LogDir> logDirs = singletonList(logDir); Broker broker = new Broker(0, "rack", logDirs); underTest.update(broker); Matcher<Iterable<? extends Tag>> diskTags = containsInAnyOrder(tag("broker", "0"), tag("logdir", "path"), tag("rack", "rack")); Matcher<Iterable<? extends Tag>> replicaTags = containsInAnyOrder(tag("broker", "0"), tag("logdir", "path"), tag("rack", "rack"), tag("topic", "topicName"), tag("partition", "1"), tag("leader", "true"), tag("inSync", "false")); assertMeter(registry.get("weighbridge_disk_free").meter(), diskTags, 1.0); assertMeter(registry.get("weighbridge_disk_total").meter(), diskTags, 3.0); assertMeter(registry.get("weighbridge_disk_used").meter(), diskTags, 2.0); assertMeter(registry.get("weighbridge_size_on_disk").meter(), replicaTags, 3.0); assertMeter(registry.get("weighbridge_log_size").meter(), replicaTags, 2.0); assertMeter(registry.get("weighbridge_beginning_offset").meter(), replicaTags, 4.0); assertMeter(registry.get("weighbridge_end_offset").meter(), replicaTags, 5.0); assertMeter(registry.get("weighbridge_record_count").meter(), replicaTags, 1.0); }
@SuppressWarnings("rawtypes") public void update(Broker broker) { List<Row> diskFreeRows = new ArrayList<>(); List<Row> diskTotalRows = new ArrayList<>(); List<Row> diskUsedRows = new ArrayList<>(); List<Row> sizeOnDiskRows = new ArrayList<>(); List<Row> logSizeRows = new ArrayList<>(); List<Row> beginningOffsetRows = new ArrayList<>(); List<Row> endOffsetRows = new ArrayList<>(); List<Row> recordCountRows = new ArrayList<>(); Tag brokerTag = Tag.of("broker", String.valueOf(broker.getId())); Tag rackTag = Tag.of("rack", broker.getRack()); for (LogDir logDir : broker.getLogDirs()) { Tag logDirTag = Tag.of("logdir", logDir.getPath()); Tags logDirTags = Tags.of(brokerTag, rackTag, logDirTag); diskFreeRows.add(Row.of(logDirTags, logDir.getDiskFree())); diskTotalRows.add(Row.of(logDirTags, logDir.getDiskTotal())); diskUsedRows.add(Row.of(logDirTags, logDir.getDiskTotal() - logDir.getDiskFree())); for (Topic topic : logDir.getTopics()) { Tag topicTag = Tag.of("topic", topic.getName()); for (PartitionReplica replica : topic.getPartitionReplicas()) { Tag partitionTag = Tag.of("partition", String.valueOf(replica.getPartition())); Tag leaderTag = Tag.of("leader", String.valueOf(replica.isLeader())); Tag inSyncTag = Tag.of("inSync", String.valueOf(replica.isInSync())); Tags replicaTags = Tags.of(brokerTag, rackTag, logDirTag, topicTag, partitionTag, leaderTag, inSyncTag); sizeOnDiskRows.add(Row.of(replicaTags, replica.getSizeOnDisk())); logSizeRows.add(Row.of(replicaTags, replica.getLogSize())); beginningOffsetRows.add(Row.of(replicaTags, replica.getBeginningOffset())); endOffsetRows.add(Row.of(replicaTags, replica.getEndOffset())); recordCountRows.add(Row.of(replicaTags, replica.getRecordCount())); } } } diskFree.register(diskFreeRows, true); diskTotal.register(diskTotalRows, true); diskUsed.register(diskUsedRows, true); sizeOnDisk.register(sizeOnDiskRows, true); logSize.register(logSizeRows, true); beginningOffset.register(beginningOffsetRows, true); endOffset.register(endOffsetRows, true); recordCount.register(recordCountRows, true); }
WeighBridgeMetrics { @SuppressWarnings("rawtypes") public void update(Broker broker) { List<Row> diskFreeRows = new ArrayList<>(); List<Row> diskTotalRows = new ArrayList<>(); List<Row> diskUsedRows = new ArrayList<>(); List<Row> sizeOnDiskRows = new ArrayList<>(); List<Row> logSizeRows = new ArrayList<>(); List<Row> beginningOffsetRows = new ArrayList<>(); List<Row> endOffsetRows = new ArrayList<>(); List<Row> recordCountRows = new ArrayList<>(); Tag brokerTag = Tag.of("broker", String.valueOf(broker.getId())); Tag rackTag = Tag.of("rack", broker.getRack()); for (LogDir logDir : broker.getLogDirs()) { Tag logDirTag = Tag.of("logdir", logDir.getPath()); Tags logDirTags = Tags.of(brokerTag, rackTag, logDirTag); diskFreeRows.add(Row.of(logDirTags, logDir.getDiskFree())); diskTotalRows.add(Row.of(logDirTags, logDir.getDiskTotal())); diskUsedRows.add(Row.of(logDirTags, logDir.getDiskTotal() - logDir.getDiskFree())); for (Topic topic : logDir.getTopics()) { Tag topicTag = Tag.of("topic", topic.getName()); for (PartitionReplica replica : topic.getPartitionReplicas()) { Tag partitionTag = Tag.of("partition", String.valueOf(replica.getPartition())); Tag leaderTag = Tag.of("leader", String.valueOf(replica.isLeader())); Tag inSyncTag = Tag.of("inSync", String.valueOf(replica.isInSync())); Tags replicaTags = Tags.of(brokerTag, rackTag, logDirTag, topicTag, partitionTag, leaderTag, inSyncTag); sizeOnDiskRows.add(Row.of(replicaTags, replica.getSizeOnDisk())); logSizeRows.add(Row.of(replicaTags, replica.getLogSize())); beginningOffsetRows.add(Row.of(replicaTags, replica.getBeginningOffset())); endOffsetRows.add(Row.of(replicaTags, replica.getEndOffset())); recordCountRows.add(Row.of(replicaTags, replica.getRecordCount())); } } } diskFree.register(diskFreeRows, true); diskTotal.register(diskTotalRows, true); diskUsed.register(diskUsedRows, true); sizeOnDisk.register(sizeOnDiskRows, true); logSize.register(logSizeRows, true); beginningOffset.register(beginningOffsetRows, true); endOffset.register(endOffsetRows, true); recordCount.register(recordCountRows, true); } }
WeighBridgeMetrics { @SuppressWarnings("rawtypes") public void update(Broker broker) { List<Row> diskFreeRows = new ArrayList<>(); List<Row> diskTotalRows = new ArrayList<>(); List<Row> diskUsedRows = new ArrayList<>(); List<Row> sizeOnDiskRows = new ArrayList<>(); List<Row> logSizeRows = new ArrayList<>(); List<Row> beginningOffsetRows = new ArrayList<>(); List<Row> endOffsetRows = new ArrayList<>(); List<Row> recordCountRows = new ArrayList<>(); Tag brokerTag = Tag.of("broker", String.valueOf(broker.getId())); Tag rackTag = Tag.of("rack", broker.getRack()); for (LogDir logDir : broker.getLogDirs()) { Tag logDirTag = Tag.of("logdir", logDir.getPath()); Tags logDirTags = Tags.of(brokerTag, rackTag, logDirTag); diskFreeRows.add(Row.of(logDirTags, logDir.getDiskFree())); diskTotalRows.add(Row.of(logDirTags, logDir.getDiskTotal())); diskUsedRows.add(Row.of(logDirTags, logDir.getDiskTotal() - logDir.getDiskFree())); for (Topic topic : logDir.getTopics()) { Tag topicTag = Tag.of("topic", topic.getName()); for (PartitionReplica replica : topic.getPartitionReplicas()) { Tag partitionTag = Tag.of("partition", String.valueOf(replica.getPartition())); Tag leaderTag = Tag.of("leader", String.valueOf(replica.isLeader())); Tag inSyncTag = Tag.of("inSync", String.valueOf(replica.isInSync())); Tags replicaTags = Tags.of(brokerTag, rackTag, logDirTag, topicTag, partitionTag, leaderTag, inSyncTag); sizeOnDiskRows.add(Row.of(replicaTags, replica.getSizeOnDisk())); logSizeRows.add(Row.of(replicaTags, replica.getLogSize())); beginningOffsetRows.add(Row.of(replicaTags, replica.getBeginningOffset())); endOffsetRows.add(Row.of(replicaTags, replica.getEndOffset())); recordCountRows.add(Row.of(replicaTags, replica.getRecordCount())); } } } diskFree.register(diskFreeRows, true); diskTotal.register(diskTotalRows, true); diskUsed.register(diskUsedRows, true); sizeOnDisk.register(sizeOnDiskRows, true); logSize.register(logSizeRows, true); beginningOffset.register(beginningOffsetRows, true); endOffset.register(endOffsetRows, true); recordCount.register(recordCountRows, true); } WeighBridgeMetrics(MeterRegistry registry); }
WeighBridgeMetrics { @SuppressWarnings("rawtypes") public void update(Broker broker) { List<Row> diskFreeRows = new ArrayList<>(); List<Row> diskTotalRows = new ArrayList<>(); List<Row> diskUsedRows = new ArrayList<>(); List<Row> sizeOnDiskRows = new ArrayList<>(); List<Row> logSizeRows = new ArrayList<>(); List<Row> beginningOffsetRows = new ArrayList<>(); List<Row> endOffsetRows = new ArrayList<>(); List<Row> recordCountRows = new ArrayList<>(); Tag brokerTag = Tag.of("broker", String.valueOf(broker.getId())); Tag rackTag = Tag.of("rack", broker.getRack()); for (LogDir logDir : broker.getLogDirs()) { Tag logDirTag = Tag.of("logdir", logDir.getPath()); Tags logDirTags = Tags.of(brokerTag, rackTag, logDirTag); diskFreeRows.add(Row.of(logDirTags, logDir.getDiskFree())); diskTotalRows.add(Row.of(logDirTags, logDir.getDiskTotal())); diskUsedRows.add(Row.of(logDirTags, logDir.getDiskTotal() - logDir.getDiskFree())); for (Topic topic : logDir.getTopics()) { Tag topicTag = Tag.of("topic", topic.getName()); for (PartitionReplica replica : topic.getPartitionReplicas()) { Tag partitionTag = Tag.of("partition", String.valueOf(replica.getPartition())); Tag leaderTag = Tag.of("leader", String.valueOf(replica.isLeader())); Tag inSyncTag = Tag.of("inSync", String.valueOf(replica.isInSync())); Tags replicaTags = Tags.of(brokerTag, rackTag, logDirTag, topicTag, partitionTag, leaderTag, inSyncTag); sizeOnDiskRows.add(Row.of(replicaTags, replica.getSizeOnDisk())); logSizeRows.add(Row.of(replicaTags, replica.getLogSize())); beginningOffsetRows.add(Row.of(replicaTags, replica.getBeginningOffset())); endOffsetRows.add(Row.of(replicaTags, replica.getEndOffset())); recordCountRows.add(Row.of(replicaTags, replica.getRecordCount())); } } } diskFree.register(diskFreeRows, true); diskTotal.register(diskTotalRows, true); diskUsed.register(diskUsedRows, true); sizeOnDisk.register(sizeOnDiskRows, true); logSize.register(logSizeRows, true); beginningOffset.register(beginningOffsetRows, true); endOffset.register(endOffsetRows, true); recordCount.register(recordCountRows, true); } WeighBridgeMetrics(MeterRegistry registry); @SuppressWarnings("rawtypes") void update(Broker broker); }
WeighBridgeMetrics { @SuppressWarnings("rawtypes") public void update(Broker broker) { List<Row> diskFreeRows = new ArrayList<>(); List<Row> diskTotalRows = new ArrayList<>(); List<Row> diskUsedRows = new ArrayList<>(); List<Row> sizeOnDiskRows = new ArrayList<>(); List<Row> logSizeRows = new ArrayList<>(); List<Row> beginningOffsetRows = new ArrayList<>(); List<Row> endOffsetRows = new ArrayList<>(); List<Row> recordCountRows = new ArrayList<>(); Tag brokerTag = Tag.of("broker", String.valueOf(broker.getId())); Tag rackTag = Tag.of("rack", broker.getRack()); for (LogDir logDir : broker.getLogDirs()) { Tag logDirTag = Tag.of("logdir", logDir.getPath()); Tags logDirTags = Tags.of(brokerTag, rackTag, logDirTag); diskFreeRows.add(Row.of(logDirTags, logDir.getDiskFree())); diskTotalRows.add(Row.of(logDirTags, logDir.getDiskTotal())); diskUsedRows.add(Row.of(logDirTags, logDir.getDiskTotal() - logDir.getDiskFree())); for (Topic topic : logDir.getTopics()) { Tag topicTag = Tag.of("topic", topic.getName()); for (PartitionReplica replica : topic.getPartitionReplicas()) { Tag partitionTag = Tag.of("partition", String.valueOf(replica.getPartition())); Tag leaderTag = Tag.of("leader", String.valueOf(replica.isLeader())); Tag inSyncTag = Tag.of("inSync", String.valueOf(replica.isInSync())); Tags replicaTags = Tags.of(brokerTag, rackTag, logDirTag, topicTag, partitionTag, leaderTag, inSyncTag); sizeOnDiskRows.add(Row.of(replicaTags, replica.getSizeOnDisk())); logSizeRows.add(Row.of(replicaTags, replica.getLogSize())); beginningOffsetRows.add(Row.of(replicaTags, replica.getBeginningOffset())); endOffsetRows.add(Row.of(replicaTags, replica.getEndOffset())); recordCountRows.add(Row.of(replicaTags, replica.getRecordCount())); } } } diskFree.register(diskFreeRows, true); diskTotal.register(diskTotalRows, true); diskUsed.register(diskUsedRows, true); sizeOnDisk.register(sizeOnDiskRows, true); logSize.register(logSizeRows, true); beginningOffset.register(beginningOffsetRows, true); endOffset.register(endOffsetRows, true); recordCount.register(recordCountRows, true); } WeighBridgeMetrics(MeterRegistry registry); @SuppressWarnings("rawtypes") void update(Broker broker);  }