digitalmars.D.learn - weighted round robin
- vino (20/20) Oct 08 2016 Hi,
- Marc =?UTF-8?B?U2Now7x0eg==?= (6/24) Oct 10 2016 auto r = roundRobin(a.cycle, b.cycle);
- vino (20/48) Oct 10 2016 Hi Marc,
- Erikvv (3/24) Oct 12 2016 In your first post you mention it should be weighted, but I see
- vino (7/35) Oct 18 2016 Hi Marc,
- Marc =?UTF-8?B?U2Now7x0eg==?= (2/11) Oct 19 2016 Note that I'm not the one you wrote the above comment ;-)
Hi, Can some one guide me on how to implement the weighted round robin, below is what i tried or any other better ways to do it Main Requirement : Incoming socket connection has to be sent to 3 servers in the weighted round robin fashion. Prog:1 import std.stdio; import std.range; import std.range.primitives; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5]; // E.g: Socket Array auto r = roundRobin(a, b); writeln(r); } OUTPUT : [1, 1, 2, 2, 3, 3, 4, 5] Requirement : [1, 1, 2, 2, 3, 3,1,4,2,5] From, Vino
Oct 08 2016
On Saturday, 8 October 2016 at 22:48:53 UTC, vino wrote:Hi, Can some one guide me on how to implement the weighted round robin, below is what i tried or any other better ways to do it Main Requirement : Incoming socket connection has to be sent to 3 servers in the weighted round robin fashion. Prog:1 import std.stdio; import std.range; import std.range.primitives; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5]; // E.g: Socket Array auto r = roundRobin(a, b); writeln(r); } OUTPUT : [1, 1, 2, 2, 3, 3, 4, 5] Requirement : [1, 1, 2, 2, 3, 3,1,4,2,5]auto r = roundRobin(a.cycle, b.cycle); Beware though that this yields an infinite range. If you just need one round, you can use: import std.algorithm.comparison : max; writeln(r.take(max(a.length, b.length)));
Oct 10 2016
On Monday, 10 October 2016 at 09:18:16 UTC, Marc Schütz wrote:On Saturday, 8 October 2016 at 22:48:53 UTC, vino wrote:Hi Marc, Thank you, I have made a small update as the Server Array is fixed length and the Socket array would be dynamic so made the below changes as now it is working as expected Prog:1 import std.stdio; import std.range; import std.range.primitives; import std.algorithm.comparison : max; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5,6,7,8,9,10,11,12]; // E.g: Socket Array auto r = roundRobin(a.cycle, b.cycle); writeln(r.take(max(a.length, b.length * 2))); } From, Vino.BHi, Can some one guide me on how to implement the weighted round robin, below is what i tried or any other better ways to do it Main Requirement : Incoming socket connection has to be sent to 3 servers in the weighted round robin fashion. Prog:1 import std.stdio; import std.range; import std.range.primitives; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5]; // E.g: Socket Array auto r = roundRobin(a, b); writeln(r); } OUTPUT : [1, 1, 2, 2, 3, 3, 4, 5] Requirement : [1, 1, 2, 2, 3, 3,1,4,2,5]auto r = roundRobin(a.cycle, b.cycle); Beware though that this yields an infinite range. If you just need one round, you can use: import std.algorithm.comparison : max; writeln(r.take(max(a.length, b.length)));
Oct 10 2016
On Tuesday, 11 October 2016 at 06:28:10 UTC, vino wrote:On Monday, 10 October 2016 at 09:18:16 UTC, Marc Schütz wrote:In your first post you mention it should be weighted, but I see no weights anywhere.[...]Hi Marc, Thank you, I have made a small update as the Server Array is fixed length and the Socket array would be dynamic so made the below changes as now it is working as expected Prog:1 import std.stdio; import std.range; import std.range.primitives; import std.algorithm.comparison : max; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5,6,7,8,9,10,11,12]; // E.g: Socket Array auto r = roundRobin(a.cycle, b.cycle); writeln(r.take(max(a.length, b.length * 2))); } From, Vino.B
Oct 12 2016
On Wednesday, 12 October 2016 at 13:44:59 UTC, Erikvv wrote:On Tuesday, 11 October 2016 at 06:28:10 UTC, vino wrote:Hi Marc, I am at the initial stage of implementing the round robin algorithm and still not reached the next part of weighted , if you have the code then please send me at present i am trying to implement this algorithm in my Server socket program and i would require few more days to complete it.On Monday, 10 October 2016 at 09:18:16 UTC, Marc Schütz wrote:In your first post you mention it should be weighted, but I see no weights anywhere.[...]Hi Marc, Thank you, I have made a small update as the Server Array is fixed length and the Socket array would be dynamic so made the below changes as now it is working as expected Prog:1 import std.stdio; import std.range; import std.range.primitives; import std.algorithm.comparison : max; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5,6,7,8,9,10,11,12]; // E.g: Socket Array auto r = roundRobin(a.cycle, b.cycle); writeln(r.take(max(a.length, b.length * 2))); } From, Vino.B
Oct 18 2016
On Tuesday, 18 October 2016 at 16:43:19 UTC, vino wrote:On Wednesday, 12 October 2016 at 13:44:59 UTC, Erikvv wrote:Note that I'm not the one you wrote the above comment ;-)In your first post you mention it should be weighted, but I see no weights anywhere.Hi Marc, I am at the initial stage of implementing the round robin algorithm and still not reached the next part of weighted , if you have the code then please send me at present i am trying to implement this algorithm in my Server socket program and i would require few more days to complete it.
Oct 19 2016