Re: sample code for customised Partition logic
Hi, It is look like correct implementation. How do you come to conclusion, which something wrong? On Mon, Oct 17, 2016 at 6:29 AM, minisoft_rmwrote: > Hi Val, > the reason is that "assignPartitions()" returns same > "List " usually even I start two ignite nodes. > > last Friday, I refactor it as below:[ > > @Override > public List
assignPartitions(final > AffinityFunctionContext affCtx) > { > final List nodes = affCtx. > currentTopologySnapshot(); > int tmpi = 0; > final List
assignments = new > ArrayList<>(2); > for (int i = 0; i < 2; i++) > { > final List partAssignment = new > ArrayList(); > > partAssignment.add(nodes.get(tmpi)); > > if (tmpi < nodes.size() - 1) > { > tmpi++; > } > > assignments.add(partAssignment); > > } > return assignments; > } > ] > > and it return result like: > list[0] -> node1; > list[1] -> node2. > > it is what I want. > > I don't think the original "assignPartitions()" has bug. (there are > lots > of people use it without error, right?) > but why "assignPartitions()" returns to me the same node# List ? > > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/sample-code-for-customised-Partition- > logic-tp8270p8317.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. > -- Vladislav Pyatkov
Re: sample code for customised Partition logic
Hi Val, the reason is that "assignPartitions()" returns same "List>" usually even I start two ignite nodes. last Friday, I refactor it as below:[ @Override public List > assignPartitions(final AffinityFunctionContext affCtx) { final List nodes = affCtx.currentTopologySnapshot(); int tmpi = 0; final List > assignments = new ArrayList<>(2); for (int i = 0; i < 2; i++) { final List partAssignment = new ArrayList(); partAssignment.add(nodes.get(tmpi)); if (tmpi < nodes.size() - 1) { tmpi++; } assignments.add(partAssignment); } return assignments; } ] and it return result like: list[0] -> node1; list[1] -> node2. it is what I want. I don't think the original "assignPartitions()" has bug. (there are lots of people use it without error, right?) but why "assignPartitions()" returns to me the same node# List ? -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/sample-code-for-customised-Partition-logic-tp8270p8317.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: sample code for customised Partition logic
Hi, What exactly are you trying to achieve? Modifying the affinity function can be a challenging task and is generally needed only for very rare specific use cases. -Val -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/sample-code-for-customised-Partition-logic-tp8270p8277.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.