Ignite远程服务器线程不退出,最终导致内存不足

时间:2016-11-14 11:06:01

标签: ignite

当我启动远程计算作业时,调用()或affinityCall()。远程服务器将创建 6个线程,这些线程永远不会退出。就像下面的VisualVM所示:

view VisualVM snapshot

从“utility-#153%null%”到“marshaller-cache-#14i%null%”的线程名称永远不会结束。 如果客户端反复运行,服务器节点上的线程数将迅速增加。结果,服务器节点内存不足。

如何在客户端关闭时关闭此线程。 可能是我不以当前的方式运行客户端。

客户代码

String cacheKey = "jobIds";
String cname = "myCacheName";
ClusterGroup rmts = getIgnite().cluster().forRemotes();
IgniteCache<String, List<String>> cache = getIgnite().getOrCreateCache(cname);
List<String> jobList = cache.get(cacheKey);
Collection<String> res = ignite.compute(rmts).apply(
        new IgniteClosure<String, String>() {
            @Override
            public String apply(String word) {
                return word;
            }
        },
        jobList
    );
getIgnite().close();
System.out.println("ignite Closed");

if (res == null) {
    System.out.println("Error: Result is null");
    return;
}

res.forEach(s -> {
    System.out.println(s);
});
System.out.println("Finished!");

getIgnite(),获取Ignite的实例。

public static Ignite getIgnite() {
    if (ignite == null) {
        System.out.println("RETURN INSTANCE ..........");
        Ignition.setClientMode(true);
        ignite = Ignition.start(confCache);
        ignite.configuration().setDeploymentMode(DeploymentMode.CONTINUOUS);
    }

    return ignite;
}

服务器配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">
        <!--
        Alter configuration below as needed.
        -->
        <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
            <property name="peerClassLoadingEnabled" value="true"/>
            <property name="peerClassLoadingMissedResourcesCacheSize" value="0"/>
            <property name="publicThreadPoolSize" value="64"/>

            <property name="discoverySpi">
                <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                    <property name="ipFinder">
                        <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                            <property name="addresses">
                                <list>
                                    <value>172.22.1.72:47500..47509</value>
                                    <value>172.22.1.100:47500..47509</value>
                                </list>
                            </property>
                        </bean>
                    </property>
                </bean>
            </property>

            <property name="cacheConfiguration">
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="cacheMode" value="PARTITIONED"/>
                    <property name="memoryMode" value="ONHEAP_TIERED"/>
                    <property name="backups" value="0"/>
                    <property name="offHeapMaxMemory" value="0"/>
                    <property name="swapEnabled" value="false"/>
                </bean>
            </property>
        </bean>
</beans>

2 个答案:

答案 0 :(得分:1)

这些线程池是静态的,它们中的线程数决不依赖于负载(执行的操作数,作业数等)。话虽如此,我并不认为它们是OOME的原因,除非你以某种方式在同一个JVM中为每个执行的作业启动一个新节点。

我还建议始终重用已在JVM中启动的现有节点。开始一个新工作并为每个工作关闭它是一个不好的做法。

答案 1 :(得分:0)

线程在线程池中创建,因此您可以在IgniteConfigurationsetUtilityCachePoolSize(int)setMarshallerCachePoolSize(int)中为Ignite 1.5设置其大小,为setMarshallerCacheThreadPoolSize(int)为Ignite 1.7设置其他大小。

相关问题