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
IGNITE-13204 Add Java thin client Kubernetes auto discovery #8206
IGNITE-13204 Add Java thin client Kubernetes auto discovery #8206
Conversation
timoninmaxim
commented
Sep 1, 2020
- ReliableChannel now works with dynamic list of server addresses;
- ClientConfiguration can be configured with addressFinder;
- Provide Kubernetes addressFinder.
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelHolder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelHolder.java
Outdated
Show resolved
Hide resolved
...s/kubernetes/src/main/java/org/apache/ignite/kubernetes/KubernetesConnectorConfigurator.java
Outdated
Show resolved
Hide resolved
...g/apache/ignite/spi/discovery/tcp/ipfinder/kubernetes/ThinClientKubernetesAddressFinder.java
Outdated
Show resolved
Hide resolved
...g/apache/ignite/spi/discovery/tcp/ipfinder/kubernetes/ThinClientKubernetesAddressFinder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got an impression that provided solution has a lot of non-necessary parts, like a lot of different holders and wrappers, and their purpose is unclean. Can you add a detailed description for new classes which explains why are they needed?
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelHolder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelHolder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
...les/kubernetes/src/main/java/org/apache/ignite/client/ThinClientKubernetesAddressFinder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
...les/kubernetes/src/main/java/org/apache/ignite/client/ThinClientKubernetesAddressFinder.java
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/ignite/internal/client/thin/ThinClientPartitionAwarenessDiscoveryTest.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/ignite/internal/client/thin/ThinClientPartitionAwarenessDiscoveryTest.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/ignite/internal/client/thin/ThinClientPartitionAwarenessDiscoveryTest.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/ignite/internal/client/thin/ThinClientPartitionAwarenessDiscoveryTest.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/ignite/internal/client/thin/ThinClientPartitionAwarenessDiscoveryTest.java
Show resolved
Hide resolved
aea28f1
to
cbd0dde
Compare
141524c
to
beebf80
Compare
beebf80
to
55f56c1
Compare
@ptupitsyn hi! I've merge your changes related to async thin client API. I leverage on introduced by me Could you please review my changes again. |
modules/core/src/test/java/org/apache/ignite/internal/client/thin/ReliableChannelTest.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/client/ClientAddressFinder.java
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/client/ClientAddressFinder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/client/ClientAddressFinder.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/client/ClientAddressFinder.java
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
Show resolved
Hide resolved
chAndAttempts = applyOnDefaultChannel(channel -> channel, attemptsLimit); | ||
|
||
} catch (Throwable ex) { | ||
fut.completeExceptionally(ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if failure
already not null here? We will lose this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
.serviceAsync(op, payloadWriter, payloadReader) | ||
.handle((res, err) -> { | ||
if (err == null) { | ||
fut.complete(res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you mean "Redundant NL"? Will fIx it this way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see in next comments. There is already NL, will not change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean missing empty line between fut.complete(res);
and onChannelFailure(ch);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't see this case.
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Outdated
Show resolved
Hide resolved
if (scheduledChannelsReinit.get()) | ||
channelsInit(true); | ||
else | ||
rollCurrentChannel(hld); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we skip rollCurrentChannel if scheduledChannelsReinit? I think we should roll channel in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if channel fails and there is scheduled reinit, there are chances that reinitialization will fix the issue (reinitialization may assign new default channel).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are chances if some dynamic address finder is used, but by default, you just check current address twice and skip one channel. In both cases (dynamic and static address finder) there is nothing bad happens if we roll current channel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if new default channel is assigned by channelsInit()
, than rollCurrentChannel(hld)
will do no-op, since hld
already not a default channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there is an invokation sequence for default case: channelsInit -> applyOnDefaultChannel
to establish connection with default channel (that checks that connection is OK). So rolling is not required too. Also rolling at least acquires lock so it is not free.
So, there is a matrix of cases for channel failure:
- Fixed addreses, topology changes -> Channel is rolled with
channelsInit -> applyOnDefaultChannel
; - Fixed addresses, topology does not change ->
rollCurrentChannel
; - Dynamic address, topology changes -> channels are reinited twice, rolls with
applyOnDefaultChannel
; - Dynamic address, topology does not change ->
rollCurrentChannel
.
So, there is an issue with double initialization for dynamic addresses only. I will fix it by skipping second initialization as describe in other comment.
* for every configured server. Otherwise only default channel is connected. | ||
*/ | ||
void channelsInit(boolean force) { | ||
if (!force && channels != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, flag force
is useless (at least for production code, but perhaps for test code too). There are 3 calls of this method from production code, first - right after constructor (when channels == null
), two other calls with force == true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Show resolved
Hide resolved
} | ||
chFailLsnrs.forEach(Runnable::run); | ||
|
||
if (scheduledChannelsReinit.get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps && !partitionAwarenessEnabled
should be added here (to avoid double reinit for partition awareness, first time here and second time in async thread). WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is a correct optimization. But I will add this condition inside if block to avoid additional rolling of current channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
...a/org/apache/ignite/internal/kubernetes/connection/KubernetesServiceAddressResolverTest.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Show resolved
Hide resolved
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
Show resolved
Hide resolved
modules/kubernetes/src/test/java/org/apache/ignite/client/TestClusterClientConnection.java
Outdated
Show resolved
Hide resolved
...a/org/apache/ignite/internal/kubernetes/connection/KubernetesServiceAddressResolverTest.java
Outdated
Show resolved
Hide resolved
...a/org/apache/ignite/internal/kubernetes/connection/KubernetesServiceAddressResolverTest.java
Show resolved
Hide resolved
…rnetes_thin_client