Thank You
The current behavior when it runs only from coordinator is good enough.
I have modified you example to run the predicate on nodes to check for example 
some file existence .
I think it stateless but for sure not idempotent . 
See below it just returns nodes that has some file on the filesystem.
Hope it helps to understand it . Thank You

What I understand the flow is like that :
1. When deployed the service will run this to determine eligible nodes by 
looking for this file
2. My service healthcheck code will check periodically if this node is valid 
for running the service and do following :
        a. Delete file
        b. Cancel service
        c. Deploy the same service with same configuration and predicate
3. #1 will run again

Is it clear enough ? The current behavior when it runs only from coordinator is 
OK as I am using cluster singletons for my services.

 
Ignite ignite=
        IgnitionEx.start("examples/config/example-ignite.xml","ignite-1");
        Ignite ignite2=
        IgnitionEx.start("examples/config/example-ignite.xml","ignite-2");

        ClusterGroup cg=ignite2.cluster().forPredicate(new
        IgnitePredicate<ClusterNode>(){
        Ignite filterIgnite;

@Override public boolean apply(ClusterNode node){
        System.out.println("ignite: "+(isNull(filterIgnite)?null
        :filterIgnite.name()));
        if(filterIgnite!=null){
        return filterIgnite.compute(filterIgnite.cluster()
        .forNode(clusterNode))
        .apply(new IgniteClosure<String, Boolean>(){
        @Override
        public Boolean apply(String filename){
        File file=new File(filename);
            return file.exists();
            }
            },"/tmp/this_node_is_valid");
        }
        return false
        }

@IgniteInstanceResource
                void setFilterIgnite(Ignite filterIgnite){
                        this.filterIgnite=filterIgnite;
                        }});

                        // Deploy services only on server nodes.
                        ignite.services(cg).deploy(new ServiceConfiguration()
                        .setMaxPerNodeCount(1)
                        .setName("my-service")
                        .setService(new SimpleMapServiceImpl<>())
        );





On 5/29/18, 11:38, "aealexsandrov" <[email protected]> wrote:

    Hi,
    
    I checked next code:
    
            Ignite ignite =
    IgnitionEx.start("examples/config/example-ignite.xml", "ignite-1");
            Ignite ignite2 =
    IgnitionEx.start("examples/config/example-ignite.xml", "ignite-2");
    
            ClusterGroup cg = ignite2.cluster().forPredicate(new
    IgnitePredicate<ClusterNode>() {
                Ignite filterIgnite;
    
                @Override public boolean apply(ClusterNode node) {
                    System.out.println("ignite: " + (isNull(filterIgnite) ? null
    : filterIgnite.name()));
                    return true;
                }
    
                @IgniteInstanceResource
                void setFilterIgnite(Ignite filterIgnite) {
                    this.filterIgnite = filterIgnite;
                }});
    
            // Deploy services only on server nodes.
            ignite.services(cg).deploy(new ServiceConfiguration()
                .setMaxPerNodeCount(1)
                .setName("my-service")
                .setService(new SimpleMapServiceImpl<>())
            );
    
    It has the same behavior as nodeFilter predicate: it starts from the
    coordinator node. And looks like it should be stateless too because it used
    in ServiceConfiguration.
    
    ignite: ignite-1
    ignite: ignite-1
    Service was initialized: my-service
    Service was initialized: my-service
    Executing distributed service: my-service
    Executing distributed service: my-service
    ignite: ignite-1
    ignite: ignite-1
    ignite: ignite-1
    ignite: ignite-1
    
    Maybe I missed something. Could you please provide the code that you propose
    to use?
    
    BR,
    Andrei
    
    
    
    --
    Sent from: http://apache-ignite-users.70518.x6.nabble.com/
    

Reply via email to