Spring data @定位器应用程序启动,然后立即停止
一切似乎都创建得很好,但一旦完成初始化,一切就停止了Spring data @定位器应用程序启动,然后立即停止,spring-data,spring-data-gemfire,Spring Data,Spring Data Gemfire,一切似乎都创建得很好,但一旦完成初始化,一切就停止了 @SpringBootApplication @LocatorApplication public class ServerApplication { public static void main(String[] args) { SpringApplication.run(ServerApplication.class, args); } } 日志: 2020-08-03 10:59:18.250信息7712---[m
@SpringBootApplication
@LocatorApplication
public class ServerApplication {
public static void main(String[] args) {
SpringApplication.run(ServerApplication.class, args);
}
}
日志:
2020-08-03 10:59:18.250信息7712---[main]o.a.g.d.i.InternalLocator:定位器于10.25.209.139开始[8081]
2020-08-03 10:59:18.250信息7712---[main]o.a.g.d.i.InternalLocator:LB183054.dmn1.fmr.com[8081]上分发定位器的启动服务器位置
2020-08-03 10:59:18.383信息7712---[main]c.f.g.l.LocatorSpringApplication:在8.496秒内启动LocatorSpringApplication(JVM运行9.318)
2020-08-03 10:59:18.385信息7712---[m shutdown hook]o.a.g.d.i.内部分布式系统:虚拟机正在退出-关闭分布式系统
2020-08-03 10:59:18.395信息7712---[m shutdown hook]o.a.g.i.c.GemFireCacheImpl:GemFireCache[id=1329087972;isclose=true;isshutdownl=false;created=Mon-Aug 03 10:59:15 EDT 2020;server=false;copyOnRead=false;lockLease=120;lockTimeout=60]:现在关闭。
2020-08-03 10:59:18.416信息7712--o.a.g.d.i.ClusterDistributionManager:关闭DistributionManager 10.25.209.139(定位器1:7712:定位器):41000。
2020-08-03 10:59:18.517信息7712--o.a.g.d.i.ClusterDistributionManager:现在关闭10.25.209.139的分发(locator 1:7712:locator):41000
2020-08-03 10:59:18.518信息7712---[m shutdown hook]o.a.g.d.i.m.g.服务:停止会员服务
2020-08-03 10:59:18.518信息7712---[ip视图创建者]o.a.g.d.i.m.g.Services:视图创建者线程正在退出
2020-08-03 10:59:18.520信息7712---[服务器线程1]o.a.g.d.i.m.g.服务:GMSHealthMonitor服务器线程退出
2020-08-03 10:59:18.536信息7712---[m关机挂钩]o.a.g.d.i.群集DistributionManager:DistributionManager在120毫秒内停止。
2020-08-03 10:59:18.537信息7712---[m关机挂钩]o.a.g.d.i.集群分发管理器:标记分发管理器10.25.209.139(定位器1:7712:定位器):41000为关闭状态。
是的,这是预期的行为,OOTB
大多数Apache Geode进程(客户端(即ClientCache
)、Locators
、管理器和集群/分布式系统的“对等”Cache
节点/成员)只创建守护进程线程(即非阻塞线程)。因此,ApacheGeodeJVM进程将启动、初始化自己,然后立即关闭
只有Apache GeodeCacheServer
进程(具有侦听客户端连接的CacheServer
组件的“对等方”Cache
进程)启动并继续运行。这是因为用于侦听客户端Socket
连接的ServerSocket
是在非守护进程线程(即阻塞线程)上创建的,这会阻止JVM进程关闭。否则,CacheServer
也会直接崩溃
您可能会想,Gfsh如何防止定位器
(即使用启动定位器
命令)和“服务器”(即使用启动服务器
命令)关闭
注意:默认情况下,当使用start server
命令启动GemFire/Geode服务器时,Gfsh会创建一个CacheServer
实例。通过在启动服务器
命令中指定--disable default server
选项,可以禁用“服务器”的CacheServer
组件。在这种情况下,此“服务器”将无法为客户端提供服务。对等节点/成员仍将继续运行,但不需要额外的帮助。有关start server
Gfsh命令的更多详细信息,请参阅
那么,Gfsh如何防止流程失败呢
在幕后,Gfsh使用和类来配置和分叉JVM进程,分别启动定位器和服务器
举例来说,是Gfsh的start locator
命令使用LocatorLauncher
类。从技术上讲,它使用从LocatorLauncher
类实例到(特别是)用于(特别是)单独JVM进程的java
命令行的配置
但是,这里的关键是启动定位器
时传递给定位器启动器
类的特定“命令”,即启动
命令()
在LocatorLauncher
类中,我们可以看到START
命令执行以下操作:从,到,Locator
,然后(使用)
如果不等待,定位器
将在您体验时直接掉落
您可以使用以下代码模拟相同的效果(即“直线下落”),该代码使用ApacheGeodeAPI来配置和启动定位器(过程中)
这个简单的小程序将直接通过。但是,如果取消注释locatorLaucncher.waitOnLocator()
,则JVM进程将阻塞
这与SDG的类(见)实际上正在做的事情没有什么不同。它也使用LocatorLauncher
类来配置和引导进程中的Locator
。LocatorFactoryBean
是在@SpringBootApplication
类上声明SDG@LocatorApplication
注释时用于配置和引导定位器的类
然而,我确实认为在这方面还有改进的余地。因此,我已提出申请
同时,作为一种解决方法,您可以通过查看ApacheGeode
(SBDG)项目的Spring Boot for ApacheGeode(Spring Boot for ApacheGeode)中相同的烟雾测试来实现阻塞定位器的相同效果。看
然而,在DATAGEODE-361完成后,ext
2020-08-03 10:59:18.250 INFO 7712 --- [ main] o.a.g.d.i.InternalLocator : Locator started on 10.25.209.139[8081]
2020-08-03 10:59:18.250 INFO 7712 --- [ main] o.a.g.d.i.InternalLocator : Starting server location for Distribution Locator on LB183054.dmn1.fmr.com[8081]
2020-08-03 10:59:18.383 INFO 7712 --- [ main] c.f.g.l.LocatorSpringApplication : Started LocatorSpringApplication in 8.496 seconds (JVM running for 9.318)
2020-08-03 10:59:18.385 INFO 7712 --- [m shutdown hook] o.a.g.d.i.InternalDistributedSystem : VM is exiting - shutting down distributed system
2020-08-03 10:59:18.395 INFO 7712 --- [m shutdown hook] o.a.g.i.c.GemFireCacheImpl : GemFireCache[id = 1329087972; isClosing = true; isShutDownAll = false; created = Mon Aug 03 10:59:15 EDT 2020; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.
2020-08-03 10:59:18.416 INFO 7712 --- [m shutdown hook] o.a.g.d.i.ClusterDistributionManager : Shutting down DistributionManager 10.25.209.139(locator1:7712:locator)<ec><v0>:41000.
2020-08-03 10:59:18.517 INFO 7712 --- [m shutdown hook] o.a.g.d.i.ClusterDistributionManager : Now closing distribution for 10.25.209.139(locator1:7712:locator)<ec><v0>:41000
2020-08-03 10:59:18.518 INFO 7712 --- [m shutdown hook] o.a.g.d.i.m.g.Services : Stopping membership services
2020-08-03 10:59:18.518 INFO 7712 --- [ip View Creator] o.a.g.d.i.m.g.Services : View Creator thread is exiting
2020-08-03 10:59:18.520 INFO 7712 --- [Server thread 1] o.a.g.d.i.m.g.Services : GMSHealthMonitor server thread exiting
2020-08-03 10:59:18.536 INFO 7712 --- [m shutdown hook] o.a.g.d.i.ClusterDistributionManager : DistributionManager stopped in 120ms.
2020-08-03 10:59:18.537 INFO 7712 --- [m shutdown hook] o.a.g.d.i.ClusterDistributionManager : Marking DistributionManager 10.25.209.139(locator1:7712:locator)<ec><v0>:41000 as closed.
public class ApacheGeodeLocatorApplication {
public static void main(String[] args) {
LocatorLauncher locatorLauncher = new LocatorLauncher.Builder()
.set("jmx-manager", "true")
.set("jmx-manager-port", "0")
.set("jmx-manager-start", "true")
.setMemberName("ApacheGeodeBasedLocator")
.setPort(0)
.build();
locatorLauncher.start();
//locatorLauncher.waitOnLocator();
}
}