ptupitsyn commented on code in PR #10110:
URL: https://github.com/apache/ignite/pull/10110#discussion_r907038662


##########
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java:
##########
@@ -527,10 +527,23 @@ private void onChannelFailure(ClientChannelHolder hld, 
ClientChannel ch) {
         rollCurrentChannel(hld);
 
         // For partiton awareness it's already initializing asynchronously in 
#onTopologyChanged.
-        if (scheduledChannelsReinit.get() && !partitionAwarenessEnabled)
+        if (addressChanged() || (scheduledChannelsReinit.get() && 
!partitionAwarenessEnabled))
             channelsInit();
     }
 
+    /**
+     * check ip address whether changed,after pod restart
+     */
+    private boolean addressChanged(){

Review Comment:
   ```suggestion
       private boolean addressFinderAddressesChanged() {
   ```



##########
modules/kubernetes/src/test/java/org/apache/ignite/kubernetes/discovery/TestClusterClientConnection.java:
##########
@@ -49,4 +49,44 @@ public void testClientConnectsToCluster() throws Exception {
         cache.put(1, 2);
         assertEquals(2, cache.get(1));
     }
+
+    @Test
+    public void testClientReConnectsToClusterAfterPodIpChange() throws 
Exception {
+        mockServerResponse();
+
+        IgniteConfiguration cfg = 
getConfiguration(getTestIgniteInstanceName(), false);
+
+        IgniteEx crd = startGrid(cfg);
+        String crdAddr = crd.localNode().addresses().iterator().next();
+
+        mockServerResponse(crdAddr);
+
+        ClientConfiguration ccfg = new ClientConfiguration();
+        ccfg.setAddressesFinder(new 
ThinClientKubernetesAddressFinder(prepareConfiguration()));
+        IgniteClient client = Ignition.startClient(ccfg);
+
+        ClientCache cache = client.createCache("cache");
+        cache.put(1, 2);
+        assertEquals(2, cache.get(1));
+
+        //stop node and change port still can connect
+        Ignition.stop(crd.name(), true);
+        int newPort = 10801;
+        ccfg.setAddressesFinder(new 
ThinClientKubernetesAddressFinder(prepareConfiguration(),newPort));
+        mockServerResponse(5,crdAddr);
+
+        cfg = getConfiguration(getTestIgniteInstanceName(), false);
+        cfg.setSqlConnectorConfiguration(new 
SqlConnectorConfiguration().setPort(newPort));

Review Comment:
   `setSqlConnectorConfiguration` is deprecated, please use 
`setClientConnectorConfiguration` instead.



##########
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java:
##########
@@ -527,10 +527,23 @@ private void onChannelFailure(ClientChannelHolder hld, 
ClientChannel ch) {
         rollCurrentChannel(hld);
 
         // For partiton awareness it's already initializing asynchronously in 
#onTopologyChanged.
-        if (scheduledChannelsReinit.get() && !partitionAwarenessEnabled)
+        if (addressChanged() || (scheduledChannelsReinit.get() && 
!partitionAwarenessEnabled))
             channelsInit();
     }
 
+    /**
+     * check ip address whether changed,after pod restart
+     */
+    private boolean addressChanged(){
+        if (clientCfg.getAddressesFinder() != null) {
+            String[] hostAddrs = clientCfg.getAddressesFinder().getAddresses();
+            if(!Arrays.equals(hostAddrs, prevHostAddrs)){
+                return true;
+            }

Review Comment:
   ```suggestion
               return !Arrays.equals(hostAddrs, prevHostAddrs);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to