ApacheIgnite不会将正在执行的闭包分发给计算网格中新生成的节点

ApacheIgnite不会将正在执行的闭包分发给计算网格中新生成的节点,ignite,Ignite,Apache Ignite版本为:2.1.0 我正在使用客户端和服务器的默认配置。以下是客户端配置。服务器配置没有“clientMode”属性 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schem

Apache Ignite版本为:2.1.0

我正在使用客户端和服务器的默认配置。以下是客户端配置。服务器配置没有“clientMode”属性

<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 abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <!-- Set to true to enable distributed class loading for examples, default is false. -->
        <property name="peerClassLoadingEnabled" value="true"/>
        <property name="clientMode" value="true"/>

        <!-- Enable task execution events for examples. -->
        <property name="includeEventTypes">
            <list>
                <!--Task execution events-->
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>

                <!--Cache events -->
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>

            </list>
        </property>

        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <!--
                        Ignite provides several options for automatic discovery that can be used
                        instead os static IP based discovery. For information on all options refer
                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
                    -->
                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
                    <!-- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">  -->
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <!-- In distributed environment, replace with actual host IP address. -->
                                <value>xxx.1y4.1zz.91:47500..47509</value>
                                <value>xxx.1y4.1zz.92:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

xxx.1y4.1zz.91:47500..47509
xxx.1y4.1zz.92:47500..47509
按照预期在网格中的服务器节点上执行闭包

当我们在执行闭包期间通过执行以下命令向网格添加新节点时

\ignite.bat..\examples\config\example ignite.xml

现有节点确认网格中新节点的添加,但闭包不会分配给新添加的节点

是否有任何配置可用于对在闭包执行期间添加的节点执行闭包

编辑1:

下面是IgniteClose实现类:

public class SimpleInterestClosure implements IgniteClosure<SimpleInterestParam, AccruedSimpleInterest> {

private static final long serialVersionUID = -5542687183747797356L;

private static final BigInteger HUNDRED = new BigInteger("100".getBytes());

private static Logger log = Logger.getLogger("SimpleInterestClosure");

@Override
public AccruedSimpleInterest apply(SimpleInterestParam e) {
    BigInteger si = e.getPrincipal().multiply(new BigInteger(e.getDurationInYears().toString().getBytes())).
            multiply(new BigInteger(e.getInterestRate().toString().getBytes())).divide(SimpleInterestClosure.HUNDRED);
    log.info("Calculated SI for id=" + e.getId());
    return  new AccruedSimpleInterest(e, si);
}

}
public类SimpleInterestClosure实现了SimpleInterestClosure{
私有静态最终长serialVersionUID=-5542687183747797356L;
私有静态final BigInteger一百=新的BigInteger(“100”.getBytes());
私有静态记录器log=Logger.getLogger(“SimpleInterestClosure”);
@凌驾
公共应计SimpleInterest应用(SimpleInterest参数e){
BigInteger si=e.getPrincipal().multiply(新的BigInteger(e.getDurationInYears().toString().getBytes())。
乘法(新的BigInteger(例如getInterestRate().toString().getBytes()).divide(SimpleInterestClosure.hund);
log.info(“id的计算SI=“+e.getId());
返回新的应计简单利息(e,si);
}
}
编辑2:

下面是调用IgniteClose实现的方法

public void method() throws IgniteException, IOException {

    Factory<SimpleInterestClosure> siClosureFactory = FactoryBuilder.singletonfactoryOf( new SimpleInterestClosure());

    ClassPathResource ress = new ClassPathResource("example-ignite.xml");
    File file = new File(ress.getPath());

    try (Ignite ignite = Ignition.start(file.getPath())) {
        log.info("Started Ignite Cluster");
        IgniteFuture<Collection<AccruedSimpleInterest>> igniteFuture = ignite.compute()
                .applyAsync(siClosureFactory.create(), createParamCollection());
        Collection<AccruedSimpleInterest> res = igniteFuture.get();
    }

}
public void方法()引发异常,IOException{
Factory sClosureFactory=FactoryBuilder.singletonfactoryOf(新的SimpleInterestClosure());
ClassPathResource ress=新的ClassPathResource(“example ignite.xml”);
File File=新文件(ress.getPath());
try(Ignite=Ignition.start(file.getPath())){
log.info(“启动点火群集”);
IgniteFuture=ignite.compute()
.applyAsync(siClosureFactory.create(),createParamCollection());
Collection res=igniteFuture.get();
}
}

这听起来像是你在找工作偷盗:


尽管它目前有一个bug,在这种特殊情况下可能是一个问题:

您能提供更多关于该用例的详细信息吗?你在做广播吗?为什么需要在新节点上执行此关闭?@ValentinKulichenko-我不是在做广播。网格正被几个闭包实现所使用。如果需要一个节点来等待闭包,或者在另一种情况下,如果一个节点死亡,我们生成一个新节点来补偿失败的节点。对不起,我很困惑。你能一步一步地描述这个场景吗?最有可能的情况是,你正在找工作。在您的情况下,它可能需要此修复:@ValentinKulichenko-我无法编辑我以前的评论,因此添加一个新的评论。我不是在做广播。网格正被几个闭包实现所使用,我的用例是为已经运行的闭包提供额外的节点。我相信你在上一次评论中提供的信息会有所帮助。好的,添加此作为回复。Hello@valentin我在启用工作盗窃方面面临一些问题。我发布了另一个问题。请看一看