Repository navigation
Fallback to use v3 protocol for some types of requests if they are not implemented in v2 - #2085
Conversation
--- Fixes apache#2071 *Motivation* A bookkeeper should fallback to use v3 protocol for some types of requests if they are not implemented in v2 *Modifications* - Add a client pool use v3 wire protocol - Obtain client by version
sijie
left a comment
There was a problem hiding this comment.
Overall looks good. I made a few suggestions. PTAL
| */ | ||
| byte CURRENT_PROTOCOL_VERSION = 2; | ||
|
|
||
| /** |
There was a problem hiding this comment.
This file is only for v2 protocol. I would suggest not touching this file. You can use ProtocolVersion instead. ProtocolVersion already defines the version numbers from 1 to 3.
| */ | ||
| PerChannelBookieClient create(BookieSocketAddress address, | ||
| PerChannelBookieClientPool pcbcPool, SecurityHandlerFactory shFactory) throws SecurityException; | ||
| PerChannelBookieClient create(BookieSocketAddress address, PerChannelBookieClientPool pcbcPool, |
There was a problem hiding this comment.
I would suggest using ProtocolVersion in this method.
| * @param version | ||
| * get specify version channel from pool | ||
| */ | ||
| void obtain(GenericCallback<PerChannelBookieClient> callback, long key, int version); |
There was a problem hiding this comment.
| void obtain(GenericCallback<PerChannelBookieClient> callback, long key, int version); | |
| void obtain(GenericCallback<PerChannelBookieClient> callback, long key, ProtocolVersion version); |
| } | ||
| return new PerChannelBookieClient(conf, executor, eventLoopGroup, allocator, address, statsLoggerForPCBC, | ||
| authProviderFactory, registry, pcbcPool, shFactory); | ||
| ClientConfiguration clientConfiguration = conf; |
There was a problem hiding this comment.
Oh, you need to clone the clientConfiguration.
So I would suggest having a variable in BookieClientImpl v3Conf then use v3Conf if ProtocolVersion is V3.
if (v3Conf == null) {
v3Conf = new ClientConfiguration(conf);
v3Conf.setUseV2WriteProtocol(false);
}
There was a problem hiding this comment.
Yeah, that my mistake. I shouldn't copy it directly. Thanks, fix it later
|
run bookkeeper-server tls tests |
--- *Modifications* - If use protocol version directly will confuse people, so I use a boolean var to control whether or not use v3 protocol to connect server. - All operation of clients need operate v3 clients too
|
run integration tests |
|
@sijie All test is passed, PTAL |
| .getSecurityProviderFactory(conf.getTLSProviderFactoryClass()); | ||
| this.shFactory = SecurityProviderFactoryFactory.getSecurityProviderFactory(conf.getTLSProviderFactoryClass()); | ||
|
|
||
| this.clients = new PerChannelBookieClient[coreSize]; |
There was a problem hiding this comment.
Do we have to always create v2 clients even if I am using only v3 ?
There was a problem hiding this comment.
It doesn't. I should make it as optional. Fix it later
| public class BKStandaloneContainer<SelfT extends BKStandaloneContainer<SelfT>> extends ChaosContainer<SelfT> { | ||
|
|
||
| private static final int ZK_PORT = 2181; | ||
| public static final int ZK_PORT = 2181; |
There was a problem hiding this comment.
Why are you making this variable 'public'?
There was a problem hiding this comment.
Thanks for your review. oh, That's my mistake. I will fix it.
|
@eolivelli Fixed, PTAL |
|
|
||
| toSend.release(); | ||
| }, ledgerId); | ||
| }, ledgerId, conf.getUseV2WireProtocol()); |
There was a problem hiding this comment.
I don't think the value here should be conf.getUseV2WireProtocol(). It should be true /* forceUseV3 *, right?
| pcbc.readLac(ledgerId, cb, ctx); | ||
| } | ||
| }, ledgerId); | ||
| }, ledgerId, conf.getUseV2WireProtocol()); |
There was a problem hiding this comment.
I don't think the value here should be conf.getUseV2WireProtocol(). It should be true /* forceUseV3 *, right?
| pcbc.getBookieInfo(requested, cb, ctx); | ||
| } | ||
| }, requested); | ||
| }, requested, conf.getUseV2WireProtocol()); |
There was a problem hiding this comment.
I don't think the value here should be conf.getUseV2WireProtocol(). It should be true /* forceUseV3 *, right?
| final BookieSocketAddress address; | ||
|
|
||
| final PerChannelBookieClient[] clients; | ||
| final PerChannelBookieClient[] clientsV3; |
There was a problem hiding this comment.
It is better to call it clientsV3Enforced. otherwise it becomes a bit confused, because clients can be v3 as well.
| this.clientsV3[i] = factory.create(address, this, shFactory, true); | ||
| } | ||
| } else { | ||
| this.clientsV3 = null; |
There was a problem hiding this comment.
assign clients to clientsV3 here. try to avoid having a field to be null.
| public void checkTimeoutOnPendingOperations() { | ||
| for (int i = 0; i < clients.length; i++) { | ||
| clients[i].checkTimeoutOnPendingOperations(); | ||
| if (null != clientsV3) { |
There was a problem hiding this comment.
| if (null != clientsV3) { | |
| if (clients != clientsV3) { |
| pcbc.disconnect(wait); | ||
| for (int i = 0; i < clients.length; i++) { | ||
| clients[i].disconnect(); | ||
| if (null != clientsV3) { |
There was a problem hiding this comment.
| if (null != clientsV3) { | |
| if (clients != clientsV3) { |
| pcbc.close(wait); | ||
| for (int i = 0; i < clients.length; i++) { | ||
| clients[i].close(wait); | ||
| if (null != clientsV3) { |
There was a problem hiding this comment.
| if (null != clientsV3) { | |
| if (clients != clientsV3) { |
| for (PerChannelBookieClient pcbc : clients) { | ||
| numPending += pcbc.getNumPendingCompletionRequests(); | ||
| } | ||
| if (null != clientsV3) { |
There was a problem hiding this comment.
| if (null != clientsV3) { | |
| if (clients != clientsV3) { |
|
@sijie @eolivelli I do some changes PTAL. :) |
|
run bookkeeper-server replication tests |
Descriptions of the changes in this PR:
Motivation
#2071
Changes
writeLacandreadLacMaster Issue: #2071