简体   繁体   中英

Implementation consistent replica in peer-to-peer application

So Im working on a school project with distributed systems in java, on a simple peer to peer project where Restaurants can update their dishes of the day and clients could search for a certain retaurant to see its dish of the day.

Among other things, we are asked to add redundancy in the system.Meaning all data stored in the network must be replicated by a customizable factor. We need to do that for two reasons :

  • When searching for data in the ring, it will help us accelerate the research: if the current peer possesses a replicated version of the the data we are searching for, it may refer to it directly and stop the search.

  • In the case where a peer dies suddenly, we would like to reinject in the network the data that the peer had before it died from their replicas.

plus we need to keep the replicas up to date like the original copies by implementing a consistency protocol.

Im just searching for a code example that could help me undrestand how I can implement consistent replicas of data to achieve consistence and fault-tolerance in a peer-to-peer application. Thank you.

Replicating data in a reliable and consistent manner is what database management systems are good at (clustering, master-slave, master-hot standby, etc.). But setting this up can be complex. Instead, have each peer maintain a local ( HSQLDB or H2 ) database, view all other peers as "remote databases" and use the simple algorithm outlined in this answer to make replicas and keep data updated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM