[
https://issues.apache.org/jira/browse/IGNITE-28243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nikolay Izhikov updated IGNITE-28243:
-------------------------------------
Fix Version/s: 2.18
> Error on deployed service invocation
> ------------------------------------
>
> Key: IGNITE-28243
> URL: https://issues.apache.org/jira/browse/IGNITE-28243
> Project: Ignite
> Issue Type: Bug
> Reporter: Nikolay Izhikov
> Assignee: Nikolay Izhikov
> Priority: Major
> Labels: ise
> Fix For: 2.18
>
>
> {noformat:java}
> package sandbox.ignite;
> import org.apache.ignite.Ignition;
> import org.apache.ignite.cluster.ClusterNode;
> import org.apache.ignite.configuration.IgniteConfiguration;
> import org.apache.ignite.lang.IgnitePredicate;
> import org.apache.ignite.services.Service;
> import org.apache.ignite.services.ServiceConfiguration;
> import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
> import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
> import org.junit.jupiter.api.Test;
> import java.util.Collections;
> import static org.junit.jupiter.api.Assertions.assertEquals;
> /**
> * Проблемы перехода с Ignite SE 16.1.1 на 17.0.0
> * (задача <a
> href="https://jira.sberbank.ru/browse/CFALL-35713">CFALL-35713</a>).
> */
> public class CfAll35713Test {
> private static final String SERVICE_NODE_NAME = "serviceNode";
> /**
> * Сервисный узел получает свой сервис из кластера при присоединении к
> кластеру.
> */
> @Test
> public void nodeGetsServiceFromCluster() throws InterruptedException {
> // Имеем кластер, в конфигурации которого задан сервис, который
> должен быть развёрнут только на узле c ID
> // "serviceNode". serviceNode пока не в кластере.
> final var serviceName = Greeter.class.getSimpleName();
> final var serviceConfig = new ServiceConfiguration()
> .setName(serviceName)
> .setService(new GreeterService())
> .setMaxPerNodeCount(1)
> .setNodeFilter(new ServiceNodeFilter());
> final var serverNodeConfig =
> getIgniteConfiguration("serverNode").setServiceConfiguration(serviceConfig);
> try (final var ignored = Ignition.start(serverNodeConfig)) {
> // Когда serviceNode с пустой конфигурацией входит в кластер
> final var serviceNodeConfig =
> getIgniteConfiguration(SERVICE_NODE_NAME).setClientMode(true);
> try (final var serviceNode = Ignition.start(serviceNodeConfig)) {
> // И через некоторое время (в реальности порядка 30 секунд)
> после входа вызывает сервис
> Thread.sleep(2_000);
> final var localNode = serviceNode.cluster().forLocal();
> final var greeter =
> serviceNode.services(localNode).serviceProxy(serviceName, Greeter.class,
> false);
> final var result = greeter.greet();
> // Тогда:
> // Ожидаемый и фактический результат на Ignite SE 16.1.3:
> вызов проходит успешно
> // Фактический результат на Ignite SE 17.0.0:
> IgniteException: Failed to find deployed service: Greeter
> assertEquals("Hello", result);
> }
> }
> }
> private static IgniteConfiguration getIgniteConfiguration(final String
> igniteName) {
> return new IgniteConfiguration()
> .setIgniteInstanceName(igniteName)
> .setConsistentId(igniteName)
> .setFailureDetectionTimeout(600_000)
> .setClientFailureDetectionTimeout(600_000)
> .setDiscoverySpi(
> new TcpDiscoverySpi()
> .setIpFinder(new
> TcpDiscoveryVmIpFinder().setAddresses(Collections.singleton("127.0.0.1:49500")))
> .setLocalPort(49500));
> }
> public interface Greeter {
> String greet();
> }
> private static class GreeterService implements Greeter, Service {
> @Override
> public String greet() {
> return "Hello";
> }
> }
> public static class ServiceNodeFilter implements
> IgnitePredicate<ClusterNode> {
> @Override
> public boolean apply(ClusterNode clusterNode) {
> return SERVICE_NODE_NAME.equals(clusterNode.consistentId());
> }
> }
> }
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)