小编典典

Apache Ignite通过Spring-Boot加载两次?

spring-boot

我正在使用Spring-Boot 1.2.7.RELEASE和Apache Ignite 1.4.0进行原型设计,发现有些奇怪,也许这只是一个日志记录配置。

看起来Apache
Ignite尝试从Spring启动两次?如果我注释掉SpringApplication.run行,那么它似乎只启动一次。也许我没有将Spring与Apache
Ignite正确使用?

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>IgniteDemo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <ignite.version>1.4.0</ignite.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-core</artifactId>
            <version>${ignite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-spring</artifactId>
            <version>${ignite.version}</version>
        </dependency>       
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

IgniteDemoApplication

package com.example;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class IgniteDemoApplication {

    public static void main(String[] args) throws IgniteException {

        //
        // If I comment out this line then it only outputs one time.
        // But then how would I have access to my application context?
        // 
        SpringApplication.run(IgniteDemoApplication.class, args);


        try(Ignite ignite = Ignition.start("C:\\opt\\apache-ignite-fabric-1.4.0-bin\\examples\\config\\example-ignite.xml")){
            ignite.compute().broadcast(() -> System.out.println("Hello World!"));
        }
    }
}

输出量

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.7.RELEASE)

2015-11-01 21:19:56.182  INFO 7024 --- [           main] com.example.IgniteDemoApplication        : Starting IgniteDemoApplication on User-PC with PID 7024 (C:\Users\User\Documents\workspace-sts-3.7.0.RELEASE\IgniteDemo\target\classes started by User in C:\Users\User\Documents\workspace-sts-3.7.0.RELEASE\IgniteDemo)
2015-11-01 21:19:56.223  INFO 7024 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@306279ee: startup date [Sun Nov 01 21:19:56 EST 2015]; root of context hierarchy
2015-11-01 21:19:56.963  INFO 7024 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2015-11-01 21:19:56.973  INFO 7024 --- [           main] com.example.IgniteDemoApplication        : Started IgniteDemoApplication in 0.981 seconds (JVM running for 1.505)
2015-11-01 21:19:57.044  INFO 7024 --- [           main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from URL [file:/C:/opt/apache-ignite-fabric-1.4.0-bin/examples/config/example-ignite.xml]
2015-11-01 21:19:57.164  INFO 7024 --- [           main] o.s.c.support.GenericApplicationContext  : Refreshing org.springframework.context.support.GenericApplicationContext@6f6745d6: startup date [Sun Nov 01 21:19:57 EST 2015]; root of context hierarchy
2015-11-01 21:19:57.264 ERROR 7024 --- [           main]                                          : Failed to resolve default logging config file: config/java.util.logging.properties
Console logging handler is not configured.
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  :

>>>    __________  ________________  
>>>   /  _/ ___/ |/ /  _/_  __/ __/  
>>>  _/ // (7 7    // /  / / / _/    
>>> /___/\___/_/|_/___/ /_/ /___/   
>>> 
>>> ver. 1.4.0#20150924-sha1:c2def5f6
>>> 2015 Copyright(C) Apache Software Foundation
>>> 
>>> Ignite documentation: http://ignite.apache.org

[21:19:57]    __________  ________________ 
[21:19:57]   /  _/ ___/ |/ /  _/_  __/ __/ 
[21:19:57]  _/ // (7 7    // /  / / / _/   
[21:19:57] /___/\___/_/|_/___/ /_/ /___/  
[21:19:57] 
[21:19:57] ver. 1.4.0#20150924-sha1:c2def5f6
[21:19:57] 2015 Copyright(C) Apache Software Foundation
[21:19:57] 
[21:19:57] Ignite documentation: http://ignite.apache.org
[21:19:57] 
[21:19:57] Quiet mode.
[21:19:57]   ^-- To see **FULL** console log here add -DIGNITE_QUIET=false or "-v" to ignite.{sh|bat}
[21:19:57] 
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Config URL: file:/C:/opt/apache-ignite-fabric-1.4.0-bin/examples/config/example-ignite.xml
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Daemon mode: off
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : OS: Windows 7 6.1 amd64
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : OS user: User
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Language runtime: Java Platform API Specification ver. 1.8
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : VM information: Java(TM) SE Runtime Environment 1.8.0_60-b27 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.60-b23
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : VM total memory: 2.7GB
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Remote Management [restart: off, REST: on, JMX (remote: on, port: 31718, auth: off, ssl: off)]
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : IGNITE_HOME=null
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : VM arguments: [-Dcom.sun.management.jmxremote, -Dcom.sun.management.jmxremote.port=31718, -Dcom.sun.management.jmxremote.authenticate=false, -Dcom.sun.management.jmxremote.ssl=false, -Dspring.liveBeansView.mbeanDomain, -Dspring.application.admin.enabled=true, -Dfile.encoding=UTF-8]
2015-11-01 21:19:57.325  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Configured caches ['ignite-marshaller-sys-cache', 'ignite-sys-cache', 'ignite-atomics-sys-cache']
2015-11-01 21:19:57.325  WARN 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Peer class loading is enabled (disable it in production for performance and deployment consistency reasons)
2015-11-01 21:19:57.335  WARN 7024 --- [te-#4%pub-null%] o.apache.ignite.internal.GridDiagnostic  : Initial heap size is 192MB (should be no less than 512MB, use -Xms512m -Xmx512m).
[21:19:57] Initial heap size is 192MB (should be no less than 512MB, use -Xms512m -Xmx512m).
2015-11-01 21:19:58.601  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Non-loopback local IPs: 192.168.1.136, fe80:0:0:0:0:5efe:c0a8:188%net3, fe80:0:0:0:7942:8350:33cb:857e%eth3
2015-11-01 21:19:58.601  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Enabled local MACs: 00000000000000E0, 00248C37A502
[21:19:58] Configured plugins:
2015-11-01 21:19:58.601  INFO 7024 --- [           main] o.a.i.i.p.plugin.IgnitePluginProcessor   : Configured plugins:
[21:19:58]   ^-- None
2015-11-01 21:19:58.601  INFO 7024 --- [           main] o.a.i.i.p.plugin.IgnitePluginProcessor   :   ^-- None
[21:19:58] 
2015-11-01 21:19:58.601  INFO 7024 --- [           main] o.a.i.i.p.plugin.IgnitePluginProcessor   : 
2015-11-01 21:19:58.802  INFO 7024 --- [           main] o.a.i.s.c.tcp.TcpCommunicationSpi        : Successfully bound to TCP port [port=47101, locHost=0.0.0.0/0.0.0.0]
2015-11-01 21:19:59.872  WARN 7024 --- [           main] o.a.i.s.c.noop.NoopCheckpointSpi         : Checkpoints are disabled (to enable configure any GridCheckpointSpi implementation)
2015-11-01 21:19:59.913  WARN 7024 --- [           main] o.a.i.i.m.c.GridCollisionManager         : Collision resolution is disabled (all jobs will be activated upon arrival).
2015-11-01 21:19:59.913  WARN 7024 --- [           main] o.a.i.s.swapspace.noop.NoopSwapSpaceSpi  : Swap space is disabled. To enable use FileSwapSpaceSpi.
[21:19:59] Security status [authentication=off, communication encryption=off]
2015-11-01 21:19:59.913  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Security status [authentication=off, communication encryption=off]
2015-11-01 21:20:00.083  INFO 7024 --- [           main] o.a.i.i.p.r.p.tcp.GridTcpRestProtocol    : Command protocol successfully started [name=TCP binary, host=0.0.0.0/0.0.0.0, port=11212]
2015-11-01 21:20:00.133  INFO 7024 --- [           main] o.a.i.spi.discovery.tcp.TcpDiscoverySpi  : Successfully bound to TCP port [port=47501, localHost=0.0.0.0/0.0.0.0]
2015-11-01 21:20:03.071  INFO 7024 --- [           main] o.a.i.i.p.cache.GridCacheProcessor       : Started cache [name=ignite-sys-cache, mode=REPLICATED]
2015-11-01 21:20:03.084  INFO 7024 --- [           main] o.a.i.i.p.cache.GridCacheProcessor       : Started cache [name=ignite-atomics-sys-cache, mode=PARTITIONED]
2015-11-01 21:20:03.098  INFO 7024 --- [           main] o.a.i.i.p.cache.GridCacheProcessor       : Started cache [name=ignite-marshaller-sys-cache, mode=REPLICATED]
2015-11-01 21:20:03.224  INFO 7024 --- [           main] o.a.i.i.p.c.d.d.p.GridDhtPreloader       : <ignite-sys-cache> Starting rebalancing in SYNC mode: ignite-sys-cache
2015-11-01 21:20:03.225  INFO 7024 --- [           main] o.a.i.i.p.c.d.d.p.GridDhtPreloader       : <ignite-atomics-sys-cache> Starting rebalancing in SYNC mode: ignite-atomics-sys-cache
2015-11-01 21:20:03.225  INFO 7024 --- [           main] o.a.i.i.p.c.d.d.p.GridDhtPreloader       : <ignite-marshaller-sys-cache> Starting rebalancing in SYNC mode: ignite-marshaller-sys-cache
2015-11-01 21:20:03.281  INFO 7024 --- [orker-#58%null%] o.a.i.i.p.c.d.d.p.GridDhtPreloader       : <ignite-marshaller-sys-cache> Completed rebalancing in SYNC mode [cache=ignite-marshaller-sys-cache, time=50 ms]
2015-11-01 21:20:03.290  INFO 7024 --- [orker-#51%null%] o.a.i.i.p.c.d.d.p.GridDhtPreloader       : <ignite-sys-cache> Completed rebalancing in SYNC mode [cache=ignite-sys-cache, time=70 ms]
2015-11-01 21:20:03.302  INFO 7024 --- [orker-#55%null%] o.a.i.i.p.c.d.d.p.GridDhtPreloader       : <ignite-atomics-sys-cache> Completed rebalancing in SYNC mode [cache=ignite-atomics-sys-cache, time=70 ms]
[21:20:03] Performance suggestions for grid  (fix if possible)
2015-11-01 21:20:03.349  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : Performance suggestions for grid  (fix if possible)
[21:20:03] To disable, set -DIGNITE_PERFORMANCE_SUGGESTIONS_DISABLED=true
2015-11-01 21:20:03.349  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : To disable, set -DIGNITE_PERFORMANCE_SUGGESTIONS_DISABLED=true
[21:20:03]   ^-- Disable peer class loading (set 'peerClassLoadingEnabled' to false)
2015-11-01 21:20:03.349  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  :   ^-- Disable peer class loading (set 'peerClassLoadingEnabled' to false)
[21:20:03]   ^-- Disable grid events (remove 'includeEventTypes' from configuration)
2015-11-01 21:20:03.349  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  :   ^-- Disable grid events (remove 'includeEventTypes' from configuration)
[21:20:03] 
2015-11-01 21:20:03.349  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : 
[21:20:03] To start Console Management & Monitoring run ignitevisorcmd.{sh|bat}
2015-11-01 21:20:03.350  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : To start Console Management & Monitoring run ignitevisorcmd.{sh|bat}
[21:20:03] 
[21:20:03] Ignite node started OK (id=a4028962)
2015-11-01 21:20:03.350  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  : 
2015-11-01 21:20:03.351  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  :

>>> +----------------------------------------------------------------------+
>>> Ignite ver. 1.4.0#20150924-sha1:c2def5f647e410e9f25383d3e74f393e4d1348a5
>>> +----------------------------------------------------------------------+
>>> OS name: Windows 7 6.1 amd64
>>> CPU(s): 8
>>> Heap: 2.7GB
>>> VM name: 7024@User-PC
>>> Grid name: null
>>> Local node [ID=A4028962-807E-4011-BA64-B923B57DD8EA, order=14, clientMode=false]
>>> Local node addresses: [User-PC.cable.rcn.com/0:0:0:0:0:0:0:1, /127.0.0.1, /192.168.1.136]
>>> Local ports: TCP:11212 TCP:47101 UDP:47400 TCP:47501

[21:20:03] Topology snapshot [ver=14, servers=2, clients=0, CPUs=8, heap=3.7GB]
2015-11-01 21:20:03.352  INFO 7024 --- [           main] o.a.i.i.m.d.GridDiscoveryManager         : Topology snapshot [ver=14, servers=2, clients=0, CPUs=8, heap=3.7GB]
2015-11-01 21:20:03.359  INFO 7024 --- [           main] o.a.i.i.m.d.GridDeploymentLocalStore     : Class locally deployed: class com.example.IgniteDemoApplication
Hello World!
2015-11-01 21:20:03.442  INFO 7024 --- [           main] o.a.i.i.p.r.p.tcp.GridTcpRestProtocol    : Command protocol successfully stopped: TCP binary
2015-11-01 21:20:03.459  WARN 7024 --- [-reader-#9%null] o.a.i.spi.discovery.tcp.TcpDiscoverySpi  : Unknown connection detected (is some other software connecting to this Ignite port? missing SSL configuration on remote node?) [rmtAddr=/0:0:0:0:0:0:0:1]
[21:20:03] Unknown connection detected (is some other software connecting to this Ignite port? missing SSL configuration on remote node?) [rmtAddr=/0:0:0:0:0:0:0:1]
2015-11-01 21:20:03.466  INFO 7024 --- [           main] o.a.i.i.p.cache.GridCacheProcessor       : Stopped cache: ignite-marshaller-sys-cache
2015-11-01 21:20:03.472  INFO 7024 --- [           main] o.a.i.i.p.cache.GridCacheProcessor       : Stopped cache: ignite-sys-cache
2015-11-01 21:20:03.473  INFO 7024 --- [           main] o.a.i.i.p.cache.GridCacheProcessor       : Stopped cache: ignite-atomics-sys-cache
2015-11-01 21:20:03.475  INFO 7024 --- [           main] o.a.i.i.m.d.GridDeploymentLocalStore     : Removed undeployed class: GridDeployment [ts=1446430803215, depMode=SHARED, clsLdr=sun.misc.Launcher$AppClassLoader@18b4aac2, clsLdrId=ab87ef5c051-a4028962-807e-4011-ba64-b923b57dd8ea, userVer=0, loc=true, sampleClsName=org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap, pendingUndeploy=false, undeployed=true, usage=0]
[21:20:03] Ignite node stopped OK [uptime=00:00:00:132]
2015-11-01 21:20:03.482  INFO 7024 --- [           main] org.apache.ignite.internal.IgniteKernal  :

>>> +---------------------------------------------------------------------------------+
>>> Ignite ver. 1.4.0#20150924-sha1:c2def5f647e410e9f25383d3e74f393e4d1348a5 stopped OK
>>> +---------------------------------------------------------------------------------+
>>> Grid name: null
>>> Grid uptime: 00:00:00:132


2015-11-01 21:20:03.600  INFO 7024 --- [       Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@306279ee: startup date [Sun Nov 01 21:19:56 EST 2015]; root of context hierarchy
2015-11-01 21:20:03.601  INFO 7024 --- [       Thread-1] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

阅读 387

收藏
2020-05-30

共1个答案

小编典典

实际上,两种情况下,Ignite都会启动一次(带有注释和未注释的SpringApplication.run行)。每个Ignite节点都会打印出当前的拓扑快照,但是我在日志中仅看到一行内容:

Topology snapshot [ver=14, servers=2, clients=0, CPUs=8, heap=3.7GB]
2020-05-30