Skip to content

Conversation

@rdhabalia
Copy link
Contributor

Motivation

After merging #394, broker will start storing managed-ledger data into binary format which can't be access by bin/pulsar zookeeper-shell anymore. So, incase of any data-corruption (eg. any human-error while accessing znode), we need a quick way to build a tool/script to access ml-data. therefore, adding python-admin tool which provides API and command-line tool access to access ml data.

Modifications

Added a tool which provides api to

  1. get managed-ledger info
  2. get managed-cursor info
  3. update markDelete of managed-cursor
  4. update ledger-list of ml

Result

No functional change.

@rdhabalia
Copy link
Contributor Author

We don't have doc for managed-ledger protobuf compilation instruction. If we think it will be helpful then I will create a separate PR to add ML-protobuf location, compilation and will add python protobuf generation instruction as well.??

Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

Change looks good and a very useful addition. Just few comment on minor naming stuff.

@@ -0,0 +1,342 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure to that the maven license plugin will ignore this, otherwise maven install will fail

@@ -0,0 +1,261 @@
#!/usr/bin/env python
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just place this scripts under bin/python/... ?
And include this in the src/bin distribution tgz.

At the same time, let's just use a similar naming as the other CLI tools. Eg:

bin/pulsar-managed-ledger-admin

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, license headers are missing

import argparse
import traceback

from kazoo.client import KazooClient
Copy link
Contributor

Choose a reason for hiding this comment

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

if importing kazoo fails, can we print something like:

You ned Kazoo ZK client library. Get it from: "pip install kazoo"

parser = argparse.ArgumentParser()
commandHelpText = 'Managed-ledger command: \n{}, {}, {}, {}'.format(printMlCommand, deleteMlLedgerIds, printCursorsCommands, updateMakDeleteCursor)
parser.add_argument("--zkServer", "-zk", required=True, help="ZooKeeperServer:port")
parser.add_argument("--command", "-cmd", required=True, help=commandHelpText)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of getting --command as an argument, to behave the same way as the other tools, can we get it as a positional parameter? eg:

ManagedLedgerAdminTool.py print-cursor --zkServer localhost:2181 \
       --mlPath sample/standalone/ns1/persistent/test --cursorName s1

commandHelpText = 'Managed-ledger command: \n{}, {}, {}, {}'.format(printMlCommand, deleteMlLedgerIds, printCursorsCommands, updateMakDeleteCursor)
parser.add_argument("--zkServer", "-zk", required=True, help="ZooKeeperServer:port")
parser.add_argument("--command", "-cmd", required=True, help=commandHelpText)
parser.add_argument("--mlPath", "-mlp", required=True, help="Managed-ledger path")
Copy link
Contributor

Choose a reason for hiding this comment

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

mlPath and ml in general is quite confusing for people not used to the context. Can we use managed-ledger instead?

@merlimat merlimat added the type/feature The PR added a new feature or issue requested a new feature label Jun 23, 2017
@merlimat merlimat added this to the 1.19 milestone Jun 23, 2017
# get managed-ledger info
mlData = zk.get(mlPath)[0]
mlInfo = MLDataFormats_pb2.ManagedLedgerInfo()
mlInfo.ParseFromString(mlData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this handling the protobuf text format as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, earlier I thought we will use this tool after merging PR which forces to write in Binary format. However, I have added Text support also.

@rdhabalia
Copy link
Contributor Author

@merlimat addressed all the changes.

@@ -0,0 +1,312 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be python instead of bash

Copy link
Contributor

Choose a reason for hiding this comment

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

We can just call it bin/pulsar-managed-ledger-admin, no need for py extension here.

try:
from kazoo.client import KazooClient
except Exception as missingLib:
print "You need Kazoo ZK client library. Get it from: pip install kazoo"
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to exit here with error code

Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

👍

@merlimat merlimat merged commit 76a73e3 into apache:master Jun 25, 2017
sschepens pushed a commit to sschepens/pulsar that referenced this pull request Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature The PR added a new feature or issue requested a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants