Issue 897: un-bind zookeeper from bookkeeper admin#936
Issue 897: un-bind zookeeper from bookkeeper admin#936hellostreaming wants to merge 7 commits intoapache:masterfrom
Conversation
sijie
left a comment
There was a problem hiding this comment.
@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( |
There was a problem hiding this comment.
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()) {
...
}
}
There was a problem hiding this comment.
Thanks, will try it.
| mFactory = LedgerManagerFactory.newLedgerManagerFactory(bkConf, zk); | ||
| mFactory = LedgerManagerFactory.newLedgerManagerFactory( | ||
| bkConf, | ||
| new ZkLayoutManager( |
There was a problem hiding this comment.
try to avoid using ZkLayoutManager directly
There was a problem hiding this comment.
Thanks, will change it.
| numReqInLastForceWrite = 0; | ||
| } | ||
| } | ||
| numReqInLastForceWrite += req.process(shouldForceWrite); |
There was a problem hiding this comment.
I think the changes in this file are not needed. probably come from merge?
There was a problem hiding this comment.
will change it, Seems it is from merge.
| this.ledgerManagerFactory = | ||
| LedgerManagerFactory.newLedgerManagerFactory(conf, ((ZKRegistrationClient) regClient).getZk()); | ||
| LedgerManagerFactory.newLedgerManagerFactory(conf, regClient.getLayoutManager()); | ||
| } catch (KeeperException ke) { |
There was a problem hiding this comment.
if we remove zk, LedgerManagerFactory.newLedgerManagerFactory should not throw KeeperException.
There was a problem hiding this comment.
thanks. will change it.
There was a problem hiding this comment.
right, will remove this.
| zkAcls, | ||
| CreateMode.PERSISTENT); | ||
| } | ||
| try (RegistrationManager rm = new ZKRegistrationManager()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thanks, will change it.
| public GetLedgerMetaService(ServerConfiguration conf, ZooKeeper zk) { | ||
| protected LayoutManager layoutManager; | ||
| // TODO: remove zk? | ||
| public GetLedgerMetaService(ServerConfiguration conf, LayoutManager layoutManager) { |
There was a problem hiding this comment.
This service should just take LedgerManagerFactory from Bookie
There was a problem hiding this comment.
Thanks, will change it.
| protected LayoutManager layoutManager; | ||
|
|
||
| public ListLedgerService(ServerConfiguration conf, ZooKeeper zk) { | ||
| public ListLedgerService(ServerConfiguration conf, LayoutManager layoutManager) { |
There was a problem hiding this comment.
This service should just take LedgerManagerFactory from bookie.
| protected LayoutManager layoutManager; | ||
|
|
||
| public ListUnderReplicatedLedgerService(ServerConfiguration conf, ZooKeeper zk) { | ||
| public ListUnderReplicatedLedgerService(ServerConfiguration conf, LayoutManager layoutManager) { |
There was a problem hiding this comment.
Take LedgerManagerFactory from AutoRecovery
There was a problem hiding this comment.
Thanks, will change it.
| LedgerManagerFactory | ||
| .newLedgerManagerFactory( | ||
| conf, | ||
| new ZkLayoutManager( |
There was a problem hiding this comment.
try to new layout manager from registration manager
There was a problem hiding this comment.
Thanks, will change it.
| Bookie.checkDirectoryStructure(curDir); | ||
|
|
||
| ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); | ||
| conf.setJournalDirName(tmpDir.toString()); |
There was a problem hiding this comment.
Thanks, will change it.
28fd782 to
bc7eb03
Compare
eolivelli
left a comment
There was a problem hiding this comment.
Nice work !
Left some comments
| return newBookieAddrs; | ||
| } | ||
| @VisibleForTesting | ||
| public void setLayoutManager(LayoutManager layoutManager) { |
There was a problem hiding this comment.
Using powermock we can stop opening the internals to users with public methods
| .sessionTimeoutMs(bkConf.getZkTimeout()) | ||
| .build(); | ||
| mFactory = LedgerManagerFactory.newLedgerManagerFactory(bkConf, zk); | ||
| mFactory = LedgerManagerFactory.newLedgerManagerFactory( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Yes, have thought do the changes. will do it.
| @LimitedPrivate | ||
| @Evolving | ||
| public interface RegistrationManager extends AutoCloseable { | ||
| public interface RegistrationManager extends LayoutManager, AutoCloseable { |
There was a problem hiding this comment.
Why a registration manager is a layoutmanager?
They are separate concepts, aren't they?
There was a problem hiding this comment.
Thanks, will remove the extend here.
| if (null != zkc) { | ||
| zkc.close(); | ||
| } | ||
| return rm.format(conf); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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.
eolivelli
left a comment
There was a problem hiding this comment.
+1 now it looks great !
|
|
||
| try (LedgerManagerFactory mFactory = LedgerManagerFactory.newLedgerManagerFactory( | ||
| bkConf, | ||
| RegistrationManager.instantiateRegistrationManager(bkConf).getLayoutManager())) { |
There was a problem hiding this comment.
RegistrationManager will never be released. You need to do:
try (RegistrationManager rm = ...) {
try (LedgerManagerFactory ...) {
}
}
There was a problem hiding this comment.
Thanks, leaked this change, will fix it.
2f29949 to
3c9c1c6
Compare
Descriptions of the changes in this PR:
Master Issue: #897