Home > other >  Embedded Ignite with spring never calls custom SegmentationResolver
Embedded Ignite with spring never calls custom SegmentationResolver

Time:04-28

I try to manage network segmentation in a Ignite cluster that is embedded in a tomcat webapp. I create a custom segmentationResolver that ping database server.

So I configure Ignite with spring context

<beans:bean id="segmentationResolver" />
<beans:bean id="ignite.cfg" >
    <beans:property name="gridLogger">
        <beans:bean />
    </beans:property>
    <beans:property name="workDirectory" value="#{systemProperties[igniteTmpDir]}"/>
    <beans:property name="segmentationResolvers" ref="segmentationResolver" />
    <beans:property name="segmentCheckFrequency" value="10000" />
    <beans:property name="segmentationPolicy" value="NOOP" />
    <beans:property name="waitForSegmentOnStart" value="true" />
    <beans:property name="communicationSpi">....

Constructor of my JdbcPingSegmentationResolver is call by spring but its method isValidSegment() is never calls. Even if I start / stop another Ignite node (it has to be called when cluster topology change).

 @Override
    public boolean isValidSegment() throws IgniteCheckedException {
        var reachable = false;
        try {
            Process exec = Runtime.getRuntime().exec("ping "   hostname);
            //0 - normal termination
            reachable = exec.waitFor(1, TimeUnit.SECONDS);
        } catch (IOException | InterruptedException e) {
            LOGGER.error("segmentation network : {}", e.getMessage(), e);
        }
        LOGGER.debug("check segmentation network status : {}", reachable);
        return reachable;
    }

CodePudding user response:

Segmentation resolvers are called by a GridSegmentationProcessor. The default processor is org.apache.ignite.internal.processors.segmentation.os.GridOsSegmentationProcessor which is noop in fact. GridGain Enterprise Edition (it's a vendor-supported delivery of Apache Ignite) specifies a processor that handles resolvers properly.

I believe that the machinery that's being called on topology changes (node left, join etc) is topology validator.

  • Related