• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to implement "buffering"

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,

I have a little problem of implementation of a buffer in my project. There is a distributed system, where there are a Boss and a fixed number of Servants.
Servants have to do tasks(implemented by the "sleep" function).
The Boss has to send a "CHECKPOINT"request to the Servants. After Servants has received that message from the Boss, they have to memorize their own state (the number of tasks) in stable storage. While doing that, no message has to be send. So if a Servant gets a CHeCKPOINT message from the Boss, then it has to buffer the task(s) it was doing, and save its own state in memory.

Now the question is: how can I implement the buffer?

At the moment, every servant has an input LinkedList for the incoming messages, and an output LinkedList for the outgoing messages. When it has to do a task, the servants read the first taask to do from the incoming linkedList. So if it is doing task and in the meanwhile a CHECKpoint-request comes, it has to be able to buffer the task and reply to the CHECKPOINT REQUEST.

Any suggestion?

Thank you for your attention and for your answers!

veronica
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand your problem correctly, you might try one of the following:


The stack would work well to push the current tasks down on the stack you create. When the servant is done, they would just need to pop them back off the stack.
java.util.Stack

Implementing one of the following interfaces may be something you want to look at as well.

java.util.Queue
java.util.Deque

Check your java docs for more info.

Hope it helps.
reply
    Bookmark Topic Watch Topic
  • New Topic