Dear All, I can not find sample code for how customise partition... and I
could almost finish it by myself.

however, the most wired thing is it work occasionally !!?? most of time it
doesn't work....

my code is:[
public class UCSRendezvousAffinityFunction extends
RendezvousAffinityFunction
{
        public int partitions()
        {
                return 2; //only test 2 partitions :-)
        }

        public int partition(final Object key)
        {
                ...........
                return xxx % 2;
        }

        //this API is...correct??
         public List<List&lt;ClusterNode>> assignPartitions(final
AffinityFunctionContext affCtx)
        {

                final List<List&lt;ClusterNode>> assignments = new
ArrayList<>(partitions());

                final boolean exclNeighbors = false;

                final Map<UUID, Collection&lt;ClusterNode>> neighborhoodCache =
exclNeighbors
                                ? 
GridCacheUtils.neighbors(affCtx.currentTopologySnapshot()) : null;

                for (int i = 0; i < partitions(); i++)
                {
                        final List<ClusterNode> partAssignment = 
assignPartition(i,
affCtx.currentTopologySnapshot(), affCtx.backups(),
                                        neighborhoodCache);

                        assignments.add(partAssignment);
                }

                return assignments;

        }

}

]


So as I said... it works from time to time....why.....

and could you show me if my API of "assignPartitions()" is right or maybe do
me a favour what is your code? thanks a lot.



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/sample-code-for-customised-Partition-logic-tp8270.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to