static BrokerMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException { byte version = buffer.get(); if (version > METRIC_VERSION) { throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". " + "Current version is " + METRIC_VERSION); } RawMetricType rawMetricType = RawMetricType.forId(buffer.get()); long time = buffer.getLong(); int brokerId = buffer.getInt(); double value = buffer.getDouble(); return new BrokerMetric(rawMetricType, time, brokerId, value); }
static TopicMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException { byte version = buffer.get(); if (version > METRIC_VERSION) { throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". " + "Current version is " + METRIC_VERSION); } RawMetricType rawMetricType = RawMetricType.forId(buffer.get()); long time = buffer.getLong(); int brokerId = buffer.getInt(); int topicLength = buffer.getInt(); String topic = new String(buffer.array(), buffer.arrayOffset() + buffer.position(), topicLength, StandardCharsets.UTF_8); buffer.position(buffer.position() + topicLength); double value = buffer.getDouble(); return new TopicMetric(rawMetricType, time, brokerId, topic, value); }
static PartitionMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException { byte version = buffer.get(); if (version > METRIC_VERSION) { throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". " + "Current version is " + METRIC_VERSION); } RawMetricType rawMetricType = RawMetricType.forId(buffer.get()); long time = buffer.getLong(); int brokerId = buffer.getInt(); int topicLength = buffer.getInt(); String topic = new String(buffer.array(), buffer.arrayOffset() + buffer.position(), topicLength, StandardCharsets.UTF_8); buffer.position(buffer.position() + topicLength); int partition = buffer.getInt(); double value = buffer.getDouble(); return new PartitionMetric(rawMetricType, time, brokerId, topic, partition, value); }
static BrokerMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException { byte version = buffer.get(); if (version > METRIC_VERSION) { throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". " + "Current version is " + METRIC_VERSION); } RawMetricType rawMetricType = RawMetricType.forId(buffer.get()); long time = buffer.getLong(); int brokerId = buffer.getInt(); double value = buffer.getDouble(); return new BrokerMetric(rawMetricType, time, brokerId, value); }
static TopicMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException { byte version = buffer.get(); if (version > METRIC_VERSION) { throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". " + "Current version is " + METRIC_VERSION); } RawMetricType rawMetricType = RawMetricType.forId(buffer.get()); long time = buffer.getLong(); int brokerId = buffer.getInt(); int topicLength = buffer.getInt(); String topic = new String(buffer.array(), buffer.arrayOffset() + buffer.position(), topicLength, StandardCharsets.UTF_8); buffer.position(buffer.position() + topicLength); double value = buffer.getDouble(); return new TopicMetric(rawMetricType, time, brokerId, topic, value); }
static PartitionMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException { byte version = buffer.get(); if (version > METRIC_VERSION) { throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". " + "Current version is " + METRIC_VERSION); } RawMetricType rawMetricType = RawMetricType.forId(buffer.get()); long time = buffer.getLong(); int brokerId = buffer.getInt(); int topicLength = buffer.getInt(); String topic = new String(buffer.array(), buffer.arrayOffset() + buffer.position(), topicLength, StandardCharsets.UTF_8); buffer.position(buffer.position() + topicLength); int partition = buffer.getInt(); double value = buffer.getDouble(); return new PartitionMetric(rawMetricType, time, brokerId, topic, partition, value); }