Я пытаюсь использовать Spring boot (2.1.0.RELEASE) для запуска ignite.compute. Поскольку spring boot + lombok использует логбэк по умолчанию, следующие коды всегда вызывают исключения (2020-05-28 07: 00: 48.979 WARN 8460 --- [p2p- # 49] oaiimdGridDeploymentCommunication: не удалось разрешить класс: ch.qos.logback ). Результат (28) можно вернуть. Кажется, мы видим log4j и log4j2 на официальном сайте. Поддерживает ли ignite логбэк?
пом. xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
default-config. xml
<?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: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://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="igniteCfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="clientMode" value="true"/>
<property name="peerClassLoadingEnabled" value="true"/>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="localPort" value="48500"/>
<property name="localPortRange" value="20"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:48500..48520</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="48100"/>
</bean>
</property>
</bean>
</beans>
java код:
@Configuration
@ImportResource(locations={"classpath:default-config.xml"})
public class IgniteConfig {
@Bean
public Ignite ignite(IgniteConfiguration igniteConfiguration) {
Ignite ignite = Ignition.start(igniteConfiguration);
Ignition.setClientMode(true);
return ignite;
}
}
@Slf4j
@RestController
public class WebController {
@Autowired
private Ignite ignite;
@GetMapping("/compute")
public void compute() {
Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
// Iterate through all the words in the sentence and create Callable jobs.
for (final String word : "Count characters using callable".split(" "))
calls.add(word::length);
// Execute collection of Callables on the grid.
Collection<Integer> res = ignite.compute().call(calls);
// Add up all the results.
int sum = res.stream().mapToInt(Integer::intValue).sum();
log.info("Total number of characters is '" + sum + "'.");
}
}
Исключение:
2020-05-28 07:00:48.786 INFO 8460 --- [nio-8080-exec-1] o.a.i.i.m.d.GridDeploymentLocalStore : Class locally deployed: class com.sonic.sample.springboot.controller.WebController
2020-05-28 07:00:48.890 WARN 8460 --- [ p2p-#49] o.a.i.i.m.d.GridDeploymentCommunication : Failed to resolve class: ch.qos.logback
java.lang.ClassNotFoundException: ch.qos.logback
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_121]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_121]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.processResourceRequest(GridDeploymentCommunication.java:216) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.processDeploymentRequest(GridDeploymentCommunication.java:152) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.access$000(GridDeploymentCommunication.java:55) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication$1.onMessage(GridDeploymentCommunication.java:88) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1843) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager.access$5100(GridIoManager.java:229) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager$8.run(GridIoManager.java:1325) [ignite-core-2.8.0.jar:2.8.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
2020-05-28 07:00:49.000 WARN 8460 --- [ p2p-#50] o.a.i.i.m.d.GridDeploymentCommunication : Failed to resolve class: ch.qos.logback
java.lang.ClassNotFoundException: ch.qos.logback
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_121]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_121]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.processResourceRequest(GridDeploymentCommunication.java:216) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.processDeploymentRequest(GridDeploymentCommunication.java:152) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.access$000(GridDeploymentCommunication.java:55) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication$1.onMessage(GridDeploymentCommunication.java:88) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1843) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager.access$5100(GridIoManager.java:229) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager$8.run(GridIoManager.java:1325) [ignite-core-2.8.0.jar:2.8.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
2020-05-28 07:00:49.000 WARN 8460 --- [ p2p-#50] o.a.i.i.m.d.GridDeploymentCommunication : Failed to resolve class: ch.qos.logback
java.lang.ClassNotFoundException: ch.qos.logback
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_121]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_121]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.processResourceRequest(GridDeploymentCommunication.java:216) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.processDeploymentRequest(GridDeploymentCommunication.java:152) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication.access$000(GridDeploymentCommunication.java:55) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.deployment.GridDeploymentCommunication$1.onMessage(GridDeploymentCommunication.java:88) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1843) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager.access$5100(GridIoManager.java:229) [ignite-core-2.8.0.jar:2.8.0]
at org.apache.ignite.internal.managers.communication.GridIoManager$8.run(GridIoManager.java:1325) [ignite-core-2.8.0.jar:2.8.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
2020-05-28 07:00:49.025 INFO 8460 --- [nio-8080-exec-1] c.s.s.s.controller.WebController : Total number of characters is '28'.