/
lintrace
/
apache_ignite_service_test
Обзор
Документация
Войти
/
lintrace
/
apache_ignite_service_test
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/org/alex/ServiceTest.java
47 строк
2 KB
Alex
First commit
04 июн 2023, 14:31
04 июн 2023, 14:31
ff39aa1
Код
Авторство
О чём код?
package org.alex; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteServices; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder; import java.util.Collections; public class ServiceTest { public static void main(String[] args) { // If you are having problems connecting the client node to the cluster, // you probably need to check these ports in the firewall settings: // 10800/tcp 47500/udp 47500/tcp 11211/tcp 47100/tcp TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder(); ipFinder.setAddresses(Collections.singletonList("localhost:47500")); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setClientMode(true); cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); //cfg.setPeerClassLoadingEnabled(true); // must be enabled both server and client nodes Ignite ignite = Ignition.start(cfg); // If you want to start service at node startup // you need to add this in server node configuration and put class on nodes // <property name="serviceConfiguration"> // <list> // <bean class="org.apache.ignite.services.ServiceConfiguration"> // <property name="name" value="MyService"/> // <property name="maxPerNodeCount" value="1"/> // <property name="totalCount" value="1"/> // <property name="service"> // <bean class="org.alex.MyService"/> // </property> // </bean> // </list> // </property> IgniteServices service = ignite.services(); service.deployClusterSingleton("MyService", new MyService()); ignite.close(); } }