java - Distributed Text Editor: multiple users editing a text file concurrently -


i working on distributed system project. required create program allow multiple users edit on same text file concurrently. have been looking around online relatively simple solution haven't found one. i've read blockingqueue doesn't make sense me. have talked ta , suggested each client have copy of text file, edit. sub-files merged main copy. however, problem won't able update sub-files while editing text file.

as understand want online text editor can modify files concurrently , updates should happen real-time possible.

here do:

  1. if user opens file receives copy of , user added list of users have opened file.
  2. after user makes change, wait x seconds accumulate further changes , send them server.
  3. the server processes change requests file 1 after other (different files can done in parallel of course , can done more intelligently splitting files chunks can processed independently in parallel too, @ least on server side [this partially true, 2 changes can processed in parallel if intersection of set of affected chunks in change , change b empty])
  4. a change request either acceppted , changes broadcastest user have file opened or change refused. can pretty complicated. easiest way keep track version number , refuse changes come older versions. (if have version number each chunk , size of chunks small, run rejections if 2 or more people working @ same location in document @ same time. quite work, consider have split/merge/delete/insert chunks if become big or small.)