Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/metadata_viewer: Refactor metadata_viewer and add transaction metadata support #5294

Merged
merged 6 commits into from
Jul 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tools/offline_log_viewer/storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
from enum import Enum
import os

import struct
Expand Down Expand Up @@ -104,6 +105,36 @@ def __next__(self):
headers)


class BatchType(Enum):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good -- controller.py already has some of these magic numbers in, so maybe those could be replaced with references to this class at the same time as adding it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I did some sanity testing on my local controller log and kvstore data and things seem ok.

"""Keep this in sync with model/record_batch_types.h"""
raft_data = 1
raft_configuration = 2
controller = 3
kvstore = 4
checkpoint = 5
topic_management_cmd = 6
ghost_batch = 7
id_allocator = 8
tx_prepare = 9
tx_fence = 10
tm_update = 11
user_management_cmd = 12
acl_management_cmd = 13
group_prepare_tx = 14
group_commit_tx = 15
group_abort_tx = 16
node_management_cmd = 17
data_policy_management_cmd = 18
archival_metadata = 19
cluster_config_cmd = 20
feature_update = 21
unknown = -1

@classmethod
def _missing_(e, value):
return e.unknown


class Batch:
class CompressionType(Enum):
none = 0
Expand Down Expand Up @@ -141,6 +172,7 @@ def __init__(self, index, header, records):
def header_dict(self):
header = self.header._asdict()
attrs = header['attrs']
header["type_name"] = BatchType(header["type"]).name
header['expanded_attrs'] = {
'compression':
Batch.CompressionType(attrs & Batch.compression_mask).name,
Expand Down