Skip to content

Issue 897: un-bind zookeeper from bookkeeper admin#936

Closed
hellostreaming wants to merge 7 commits intoapache:masterfrom
hellostreaming:issue_897
Closed

Issue 897: un-bind zookeeper from bookkeeper admin#936
hellostreaming wants to merge 7 commits intoapache:masterfrom
hellostreaming:issue_897

Conversation

@hellostreaming
Copy link
Contributor

Descriptions of the changes in this PR:

  • remove zookeeper from LedgerLayout to make LedgerLayout as a pure layout object,
  • add LayoutManager, move zookeeper related utils into ZKLayoutManager for storing/reading/delete layout from zookeeper,
  • unbind zookeeper from LedgerManagerFactory, use LayoutManager instead,
  • unbind zookeeper from bookkeeperadmin.format,
  • fix compile and test errors.

Master Issue: #897


Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    <Issue # or BOOKKEEPER-#>: Description of pull request
    e.g. Issue 123: Description ...
    e.g. BOOKKEEPER-1234: Description ...
  • Make sure tests pass via mvn clean apache-rat:check install spotbugs:check.
  • Replace <Issue # or BOOKKEEPER-#> in the title with the actual Issue/JIRA number.

Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

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

@jiazhai overall change looks good to me. left some comments. I think it would be better to avoid constructing ZkLayoutManager if possible. You should construct RegistrationManager from reflection and initializing ledger manager factory by using the layout manager from registration manager.

LedgerManagerFactory mFactory = LedgerManagerFactory.newLedgerManagerFactory(bkConf, zk);
mFactory = LedgerManagerFactory.newLedgerManagerFactory(
bkConf,
new ZkLayoutManager(
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to avoid construct ZkLayoutManager directly.

A better way to do this:

try (RegistrationManager rm = ...) {
    try (LedgerManagerFactory mFactory = LedgerManagerFactory.newLedgerManagerFactory(.., rm.getLayoutManager()) {
       ...
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will try it.

mFactory = LedgerManagerFactory.newLedgerManagerFactory(bkConf, zk);
mFactory = LedgerManagerFactory.newLedgerManagerFactory(
bkConf,
new ZkLayoutManager(
Copy link
Member

Choose a reason for hiding this comment

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

try to avoid using ZkLayoutManager directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

numReqInLastForceWrite = 0;
}
}
numReqInLastForceWrite += req.process(shouldForceWrite);
Copy link
Member

Choose a reason for hiding this comment

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

I think the changes in this file are not needed. probably come from merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will change it, Seems it is from merge.

this.ledgerManagerFactory =
LedgerManagerFactory.newLedgerManagerFactory(conf, ((ZKRegistrationClient) regClient).getZk());
LedgerManagerFactory.newLedgerManagerFactory(conf, regClient.getLayoutManager());
} catch (KeeperException ke) {
Copy link
Member

Choose a reason for hiding this comment

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

if we remove zk, LedgerManagerFactory.newLedgerManagerFactory should not throw KeeperException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. will change 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.

right, will remove this.

zkAcls,
CreateMode.PERSISTENT);
}
try (RegistrationManager rm = new ZKRegistrationManager()) {
Copy link
Member

Choose a reason for hiding this comment

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

Better load registration manager from configuration rather than constructing directly from ZKRegistrationManager? Change format(ClientConfiguration ...) to format(ServerConfiguration ..), because registration manager is only available in ServerConfiguration. This format method is only called by BookieShell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

public GetLedgerMetaService(ServerConfiguration conf, ZooKeeper zk) {
protected LayoutManager layoutManager;
// TODO: remove zk?
public GetLedgerMetaService(ServerConfiguration conf, LayoutManager layoutManager) {
Copy link
Member

Choose a reason for hiding this comment

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

This service should just take LedgerManagerFactory from Bookie

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

protected LayoutManager layoutManager;

public ListLedgerService(ServerConfiguration conf, ZooKeeper zk) {
public ListLedgerService(ServerConfiguration conf, LayoutManager layoutManager) {
Copy link
Member

Choose a reason for hiding this comment

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

This service should just take LedgerManagerFactory from bookie.

protected LayoutManager layoutManager;

public ListUnderReplicatedLedgerService(ServerConfiguration conf, ZooKeeper zk) {
public ListUnderReplicatedLedgerService(ServerConfiguration conf, LayoutManager layoutManager) {
Copy link
Member

Choose a reason for hiding this comment

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

Take LedgerManagerFactory from AutoRecovery

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

LedgerManagerFactory
.newLedgerManagerFactory(
conf,
new ZkLayoutManager(
Copy link
Member

Choose a reason for hiding this comment

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

try to new layout manager from registration manager

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

Bookie.checkDirectoryStructure(curDir);

ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
conf.setJournalDirName(tmpDir.toString());
Copy link
Member

Choose a reason for hiding this comment

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

bad merge in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Nice work !

Left some comments

return newBookieAddrs;
}
@VisibleForTesting
public void setLayoutManager(LayoutManager layoutManager) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using powermock we can stop opening the internals to users with public methods

@sijie

.sessionTimeoutMs(bkConf.getZkTimeout())
.build();
mFactory = LedgerManagerFactory.newLedgerManagerFactory(bkConf, zk);
mFactory = LedgerManagerFactory.newLedgerManagerFactory(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are lacking some close().
You can considering even adding a close() method to LedgerManagerFactory and make it AutoCloseable in order to use try-with-resources

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, have thought do the changes. will do it.

@LimitedPrivate
@Evolving
public interface RegistrationManager extends AutoCloseable {
public interface RegistrationManager extends LayoutManager, AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a registration manager is a layoutmanager?
They are separate concepts, aren't they?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will remove the extend here.

if (null != zkc) {
zkc.close();
}
return rm.format(conf);
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't look appropriate to make 3 different calls here

rm.prepareFormat(conf)
bkc.ledgerManagerFactory.format(conf, bkc.regClient.getLayoutManager())
rm.format(conf)

is it not possible to abstract it out to single rm method call, probably with arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. ledger manager factory only manages ledger metadata, registration manager manages layout, cookies, instance id. so they are currently covering different metadata. so we need separate calls at this moment.
for end-user, they would still use the same format method, it doesn't change.

Copy link
Member

Choose a reason for hiding this comment

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

@reddycharan since this is a code/interface refactor, if you feel we can combine some some of the logics into one, how about do this in a separate PR? I think is better to keep an interface refactor simple rather than changing too much logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @sijie, I'm working on having new set of bookieshellcommands - nukeexistingcluster and initnewcluster (by splitting metaformat. but leave metaformat as it is). Waiting for this commit to go in. Will consider refactoring while rebasing my commit on the new code, since it touches all these calls. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

cool. thanks @reddycharan

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1 now it looks great !

Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

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

@jiazhai looks good now. left one comment there


try (LedgerManagerFactory mFactory = LedgerManagerFactory.newLedgerManagerFactory(
bkConf,
RegistrationManager.instantiateRegistrationManager(bkConf).getLayoutManager())) {
Copy link
Member

Choose a reason for hiding this comment

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

RegistrationManager will never be released. You need to do:

try (RegistrationManager rm = ...) {
    try (LedgerManagerFactory ...) {
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, leaked this change, will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants