@Test
//@Ignore
public void should_run_cluster()
try (Ignite ignite = Ignition.start("ignite2.xml"))
IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCacheName");
// Store keys in cache (values will end up on different cache nodes).
for (int i = 0; i < 10; i++)
cache.put(i, Integer.toString(i));
for (int i = 0; i < 10; i++)
System.out.println("Got [key=" + i + ", val=" + cache.get(i) + ']');
Depending on what I do, when running it out of IntelliJ, i seem to be able to talk to the Ignite node but it rejects the node joining the cluster.
I've tried exposing the ports (different port#'s, not exposed only internal, etc.) from the Java service but no luck.
If I try and attach my configuration to the Ignite service it completely does not work.
My end goal is to setup an environment using Docker-Compose that I can join locally for testing purposes but, eventually, move this to ECS/Fargate.
I am sure I am getting my configurations mixed up and any help would be appreciated...
----- UPDATE-----
So, i've been able to connect to Ignite from IntelliJ using localhost/127.0.0.1 and within the container network using the compose service name 'ignite.'
Is this the right way to do this? I cant see how I can use the same configuration, without using doing some token replacement (${port}), for each node because it seems I need to have a unique port value for the DiscoverySpi and the CommunicationSpi.
Also, when connecting from my client, in this case a JUnit, it takes forever to establish that initial connection.
So, my question now is if this is the right way to configure Ignite?
"Ignite" Service (in Compose):
ignite:
image: apacheignite/ignite
environment:
- IGNITE_QUIET=false
volumes:
- ./project/src/test/resources/ignite-main.xml:/opt/ignite/apache-ignite-fabric/config/default-config.xml
ports:
- 11211:11211
- 47100:47100
- 47500:47500
- 49112:49112
"Ignite" Service Configuration (ignite-main.xml):
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="localPort" value="47500"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<value>localhost</value>
<value>localhost:47500</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="47100"/>
</bean>
</property>
Client Ignite Configuration (ignite.xml):
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="localPort" value="47501"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<value>localhost</value>
<value>localhost:47500</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="47101"/>
</bean>
</property>
Client Ignite Test Case:
private static Ignite ignite;
@BeforeClass
public static void beforeAll()
ignite = Ignition.start("ignite.xml");
@AfterClass
public static void afterAll()
ignite.close();
@Test
public void should_prep_cluster()
IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCacheName");
// Store keys in cache (values will end up on different cache nodes).
for (int i = 0; i < 10; i++)
cache.put(i, Integer.toString(i));
for (int i = 0; i < 10; i++)
System.out.println("Got [key=" + i + ", val=" + cache.get(i) + ']');
As a supplement to @alamar's answer:
Since Docker Compose services launch in separate containers, you can not use localhost
or 127.0.0.1
to discover server node. You can link ignite service to be able to use DNS name ignite
.
Compose services:
# Ignite
ignite:
image: apacheignite/ignite
environment:
- IGNITE_QUIET=false
# volumes:
# - ./project/src/test/resources/ignite.xml:/opt/ignite/apache-ignite-fabric/config/default-config.xml
# It is not necessary to expose ports outside if they are only used inside docker-compose
# ports:
# - 11211:11211
# - 47100:47100
# - 47500:47500
# - 49112:49112
# Java Shell
java:
image: local/java
build:
context: .
command: /bin/bash
volumes:
- .:/project
links:
- ignite
ports:
- 8000:8000
- 8080:8080
- 1099:1099
Client Ignite Configuration (ignite.xml):
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<value>ignite:47500</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
–
So that you can run stand-alone Ignite node with any set of modules, and e.g. run SQL against it with sqlline
, or (while using peer class loading) do almost anything with connected Ignite clients to it. But then again, you can run Ignite nodes (client or server) directly from Maven projects, in this case you don't need binary distribution at all.
Yes. Aside from node properties or consistentId
which is not required, they may be identical.
It's hard to say. Can you provide logs? I think that people who understand containers can check it without logs, but I can't.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.