Hi,
i have a Portal Crane which serves many Servers. At the Moment a Product is picked up by the Crane, it checks the destination (stored in a Label) and if that destinated Server is free, the crane will bring the product to the Server. Otherwise it will put the Product to a Queue. No problem so far.
My Problem : the crane picks up a Product from the queue, it will check the availability of the destinated server... if that server is not available the crane will put the product back to the same queue. I don't want the crane to pick up atoms from the queue that cannot be send to an open server. I am looking for a kind of queue discipline that puts that product first which designated server is open. so that the crane will only pick up those products that can be send to an server. right now i am using random for the queue but that doesn't work well.
i hope somebody can help me
Problem with Portal Crane and Queue
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Problem with Portal Crane and Queue
Ha,
This will need just a bit more then only a queue discipline. I've created a small example model, but tried to make the code scalable, so it should work with 20 servers (or more) as well.
First (since I have only 2 servers) I don't want more then 2 of products that can be processed by the severs in both the different servers and the crane. After all I can't predict where the next product has to go, so pre-loading the crane is dangerous. So I check how many products are currently being handled on the OnExit trigger of the queue. When there are 2, I close the output of the queue, using:
When a product leaves a server, I again reopen the queue (OnExit code of the servers), using:
Then on the Input Strategy I check if there are
And that is about it. I hope it helps you further. I also included a small example model, so you can see what I did exactly.
Regards,
Harry
This will need just a bit more then only a queue discipline. I've created a small example model, but tried to make the code scalable, so it should work with 20 servers (or more) as well.
First (since I have only 2 servers) I don't want more then 2 of products that can be processed by the severs in both the different servers and the crane. After all I can't predict where the next product has to go, so pre-loading the crane is dangerous. So I check how many products are currently being handled on the OnExit trigger of the queue. When there are 2, I close the output of the queue, using:
Code: Select all
CloseOutput(c)
When a product leaves a server, I again reopen the queue (OnExit code of the servers), using:
Code: Select all
OpenOutput(reference to the queue)
Then on the Input Strategy I check if there are
- products waiting in the queue
- is there a server free (I loop over the outgoing channels of the crane and count the content. If that is less then the number of servers the crane is connected to, I know there must be space)
- If there is space, I loop over the products and check which is destined to go to that particular server and place that in front of the queue.
Code: Select all
Do(
{Input strategy of crane.}
var([atmQueue], vbAtom, in(1, c)),
If(
And(
Content(atmQueue) > 0,
Sum(NrOc(c), Content(out(count, c))) < NrOc(c)
),
SetRank(
1,
Rank(
IndexMatchRank(
Content(atmQueue),
ICOpen(1, Out(Label([Dest], Rank(count, atmQueue)), c)),
1,
1
),
atmQueue
)
)
),
openallic(c)
)
Regards,
Harry
Re: Problem with Portal Crane and Queue
Thank you for your answer Harry,
it took me a while to understand what you did but now i got it.
I have to see if and how i can adjust the code to my model because it is quite a bit different. but now i have some new ideas. thank you
it took me a while to understand what you did but now i got it.
I have to see if and how i can adjust the code to my model because it is quite a bit different. but now i have some new ideas. thank you