Hello,

1. Client sends requests to random known server node for load balancing.
2. Client uses the provided address as entry point and gets
information about other nodes from the server. If you don't need such
functionality, you can set property
ClientConfiguration.ClusterDiscoveryEnabled to false.
3. It's not quite correct to rely on the ClusterNode.isLocal flag on
the client side. Nodes list is cached on client side and, I think,
there can be cases when this flag is inconsistent (for example, there
can be more than one node with this flag).

ср, 3 июл. 2024 г. в 23:31, Murat ÖZDEMİR <mozde...@bimetri.com>:
>
> Hi,
>
> I setup a Ignite cluster on docker desktop with the commands and  
> default-config.xml provided below;
>
> for ignite-1 node
> docker --context desktop-linux run --name ignite-1 -p 10800:10800 -p 
> 11211:11211 -p 47100:47100 -p 47500:47500 -p 49112:49112 -p 8080:8080 -d 
> apacheignite/ignite:latest
> (docker container ip: 172.17.0.2)
>
> default-config.xml for ignite-1 node;
> <?xml version="1.0" encoding="utf-8"?> <beans 
> xmlns="http://www.springframework.org/schema/beans"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns:spring="http://camel.apache.org/schema/spring"; 
> xmlns:util="http://www.springframework.org/schema/util"; 
> xsi:schemaLocation="http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans.xsd 
> http://camel.apache.org/schema/spring 
> http://camel.apache.org/schema/spring/camel-spring.xsd 
> http://www.springframework.org/schema/util 
> https://www.springframework.org/schema/util/spring-util.xsd";> <bean 
> class="org.apache.ignite.configuration.IgniteConfiguration"> <property 
> name="consistentId" value="ILETISIM1" /> <property name="workDirectory" 
> value="/opt/ignite" /> <property name="peerClassLoadingEnabled" value="true" 
> /> <property name="includeEventTypes"> <list> <util:constant 
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" /> 
> <util:constant 
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" /> 
> <util:constant 
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" /> 
> </list> </property> <property name="cacheConfiguration"> <list>...</list> 
> </property> <property name="clientMode" value="false" /> <property 
> name="clientConnectorConfiguration"> <bean 
> class="org.apache.ignite.configuration.ClientConnectorConfiguration"> <!-- 
> port of client --> <property name="port" value="10800" /> </bean> </property> 
> <property name="discoverySpi"> <bean 
> class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <!-- Set local 
> port and port range --> <property name="localPort" value="47500" /> <property 
> name="localPortRange" value="1" /> <property name="ipFinder"> <bean 
> class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
>  <property name="addresses"> <list> <value>localhost:47500</value> 
> <value>172.17.0.7:47501</value> </list> </property> </bean> </property> 
> </bean> </property> </bean> </beans>
>
> for ignite-2 node
> docker --context desktop-linux run --name ignite-2 -p 10801:10800 -p 
> 11212:11211 -p 47101:47100 -p 47501:47500 -p 49113:49112 -p 8081:8080 -d 
> apacheignite/ignite:latest
> (docker container ip: 172.17.0.7)
>
> default-config.xml for ignite-2 node;
> <?xml version="1.0" encoding="utf-8"?> <beans 
> xmlns="http://www.springframework.org/schema/beans"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns:spring="http://camel.apache.org/schema/spring"; 
> xmlns:util="http://www.springframework.org/schema/util"; 
> xsi:schemaLocation="http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans.xsd 
> http://camel.apache.org/schema/spring 
> http://camel.apache.org/schema/spring/camel-spring.xsd 
> http://www.springframework.org/schema/util 
> https://www.springframework.org/schema/util/spring-util.xsd";> <bean 
> class="org.apache.ignite.configuration.IgniteConfiguration"> <property 
> name="consistentId" value="ILETISIM2" /> <property name="workDirectory" 
> value="/opt/ignite" /> <property name="peerClassLoadingEnabled" value="true" 
> /> <property name="includeEventTypes"> <list> <util:constant 
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" /> 
> <util:constant 
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" /> 
> <util:constant 
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" /> 
> </list> </property> <property name="cacheConfiguration"> <list>...</list> 
> </property> <property name="clientMode" value="false" /> <property 
> name="clientConnectorConfiguration"> <bean 
> class="org.apache.ignite.configuration.ClientConnectorConfiguration"> <!-- 
> port of client --> <property name="port" value="10800" /> </bean> </property> 
> <property name="discoverySpi"> <bean 
> class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <!-- Set local 
> port and port range --> <property name="localPort" value="47500" /> <property 
> name="localPortRange" value="1" /> <property name="ipFinder"> <bean 
> class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
>  <property name="addresses"> <list> <value>localhost:47500</value> 
> <value>172.17.0.2:47500</value> </list> </property> </bean> </property> 
> </bean> </property> </bean> </beans>
>
>
>
> I have a Java code below to test cluster and thin clients.
>
> public class IgniteClusterTest {
>     public static void main(String[] args) {
>         IgniteClient client1 = null;
>         IgniteClient client2 = null;
>         try {
>             ApplicationContext clientConfiguration = new 
> ClassPathXmlApplicationContext("ignite-config.xml");
>             client1 = Ignition.startClient((ClientConfiguration) 
> clientConfiguration.getBean("clientConfiguration.cfg"));
>             client2 = Ignition.startClient((ClientConfiguration) 
> clientConfiguration.getBean("clientConfiguration2.cfg"));
>
>             System.out.println("nodesFromClient1: " + 
> Arrays.toString(client1.cluster().nodes().stream().map(node - > 
> node.id().toString()).sorted().toArray()));
>             Optional < ClusterNode > client1Local = 
> client1.cluster().nodes().stream().filter(ClusterNode::isLocal).findFirst();
>             client1Local.ifPresent(clusterNode - > 
> System.out.println("client1NodeId: " + clusterNode.id()));
>
>             List < String > nodesFromClient2 = 
> client2.cluster().nodes().stream().map(node - > 
> node.id().toString()).sorted().collect(Collectors.toList());
>             System.out.println("nodesFromClient2: " + 
> Arrays.toString(nodesFromClient2.toArray()));
>             Optional < ClusterNode > client2Local = 
> client2.cluster().nodes().stream().filter(ClusterNode::isLocal).findFirst();
>             client2Local.ifPresent(clusterNode - > 
> System.out.println("client2NodeId: " + clusterNode.id()));
>
>             //client1.close();
>             //client2.close();
>         } catch (Exception e) {
>             e.printStackTrace();
>         } finally {
>             if (client1 != null)
>                 client1.close();
>
>             if (client2 != null)
>                 client2.close();
>         }
>     }
> }
>
>
>
> And ignite-config.xml is given below;
>
> <beans xmlns="http://www.springframework.org/schema/beans"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xsi:schemaLocation="http://www.springframework.org/schema/beans 
> classpath:META-INF/spring/sch-loc/spring-beans.xsd">
>   <description>Main Spring file for ignite configuration.</description>
> <!-- Example of bean definition with given configuration. -->
>   <bean id="clientConfiguration.cfg" 
> class="org.apache.ignite.configuration.ClientConfiguration">
>     <property name="addresses" value="localhost:10800" />
>   </bean>
>   <bean id="clientConfiguration2.cfg" 
> class="org.apache.ignite.configuration.ClientConfiguration">
>     <property name="addresses" value="localhost:10801" />
>   </bean>
> </beans
>
>
> The problem is console log output is like below;
> nodesFromClient1: [1a58aed8-b014-4dd2-9fb8-92dedf3b5c17, 
> a8e3d238-caee-45c3-81ea-cbbb2c6a204e]
> client1NodeId: 1a58aed8-b014-4dd2-9fb8-92dedf3b5c17
> nodesFromClient2: [1a58aed8-b014-4dd2-9fb8-92dedf3b5c17, 
> a8e3d238-caee-45c3-81ea-cbbb2c6a204e]
> client2NodeId: 1a58aed8-b014-4dd2-9fb8-92dedf3b5c17
>
> I was expecting client node IDs would be different! Why are they the same?
>
> Best regards,
> Murat Ozdemir
>
>
>
>
> Bu e-posta işbu bağlantıyı kullanarak erişebileceğiniz koşullara tabidir:
> http://www.bimetri.com/eposta-hukuki-sartlari

Reply via email to