ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zshamrock <aliaksandr.kaz...@gmail.com>
Subject Strange collocated distributed set behavior
Date Wed, 15 Jun 2016 10:49:10 GMT
Here is the sample code:

package experiments.ignite;

import java.util.Arrays;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSet;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.CollectionConfiguration;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;

public class DistributedSetDemo {
    public static void main(final String[] args) {
        final Ignite ignite = Ignition.start();
        final CollectionConfiguration collectionConfiguration = new
CollectionConfiguration();
        collectionConfiguration.setCollocated(true); // 1
//        collectionConfiguration.setBackups(1); // 2
        System.out.printf("Started node %s\n",
ignite.cluster().localNode().id());
        IgniteSet<Long> numbers = ignite.set("numbers", null);
        if (numbers == null) {
            numbers = ignite.set("numbers", collectionConfiguration);
        }
        System.out.printf("[local] Size of the numbers distributed set is
%d, and items are %s\n",
                numbers.size(),
                Arrays.toString(numbers.toArray(new Long[numbers.size()])));
        System.out.printf("[local] Is collocated? %b\n",
numbers.collocated());
        System.out.printf("[local] numbers contains 42? %b\n",
numbers.contains(42L));
        numbers.affinityRun(new IgniteRunnable() {
            @IgniteInstanceResource
            private Ignite ignite;

            @LoggerResource
            private IgniteLogger logger;

            @Override
            public void run() {
                System.out.println(String.format("[affinity] Running on %s
node", ignite.cluster().localNode().id()));
                final IgniteSet<Long> affinityNumbers =
ignite.set("numbers", null);
                System.out.printf("[affinity] Size of the numbers
distributed set is %d, and items are %s\n",
                        affinityNumbers.size(),
                        Arrays.toString(affinityNumbers.toArray(new
Long[affinityNumbers.size()])));
                System.out.printf("[affinity] Is collocated? %b\n",
affinityNumbers.collocated());
                System.out.printf("[affinity] numbers contains 42? %b\n",
affinityNumbers.contains(42L));
            }
        });
        numbers.add(42L);
    }
}


or here https://gist.github.com/zshamrock/ac5e907bf1b091ad05570f77ae1ba69f.

Below are different scenarios with the actual and expected behavior.

Scenario #1

 - Run first instance 
Started node 54e59a6c-dc40-4038-b225-b7f8a0a343cf
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? false
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 0, and items are []
[affinity] Is collocated? true
[affinity] numbers contains 42? false

- Run second instance
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from second instance console)
Started node 83429a51-0e6f-48d3-a991-b0fbbe6ac58e
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? true

- Run third instance
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from third instance console)
Started node e844d3fc-e9c2-4bb3-8dab-efe44281c96f
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? true

- Stop first instance

- Run fourth instance
(from third instance console)
[affinity] Running on e844d3fc-e9c2-4bb3-8dab-efe44281c96f node
[affinity] Size of the numbers distributed set is 0, and items are []
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from fourth instance console)
Started node b3aff359-80eb-4a26-aa3a-f8ba16d248ee
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? true

*Actual behavior*
See above

*Expected behavior*
1. As there is no backup configured, I have not expected Set ownership to be
taken by 3rd instance.

2. Even, if 3rd instance took the ownership of the Set, the output from the
affinity run is strange, as comparing to the original affinity output from
the 1st instance (which reports the correct size, and toArray()), 3rd
instance only reports "contains", but empty for size() and toArray(). Which
is weird.

3. I still have expected "local" access to the distributed set would return
proper size and toArray(). Which it doesn't. Also strange to see although
"contains" reports true for all the cases.

Scenario #2 (with backups enabled)

Same behavior as for the Scenario #1

Scenario #3

(do not know how to reproduce it all the time, but saw it multiple times)

- Run first instance
Started node 54e59a6c-dc40-4038-b225-b7f8a0a343cf
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? false
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 0, and items are []
[affinity] Is collocated? true
[affinity] numbers contains 42? false

- Run second instance
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from second instance console)
Started node 83429a51-0e6f-48d3-a991-b0fbbe6ac58e
*[local] Size of the numbers distributed set is 1, and items are [42]*!!!
[local] Is collocated? true
[local] numbers contains 42? true

- Run third instance 
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from third instance console)
Started node e844d3fc-e9c2-4bb3-8dab-efe44281c96f
*[local] Size of the numbers distributed set is 0, and items are []*!!!
[local] Is collocated? true
[local] numbers contains 42? true

*Actual behavior*
See above

*Expected behavior*
Strange to see 2nd instance has reported the correct size and toArray()
(again it is not always happening), while the 3rd instance goes back to
report nothing (0 for the size, and empty toArray()).



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message