|
|
| Author |
Message |
< Erlang ~ Joe's robust_bank_client |
| iWantToKeepAnon |
Posted: Tue Sep 25, 2007 5:34 pm |
|
|
|
User
Joined: 31 Jul 2007
Posts: 14
Location: Dallas, TX
|
At http://www.sics.se/~joe/tutorials/robust_server/robust_server.html
Joe's tutorial shows a bank client that will try server1 and roll to server2 if server1 isn't available.
Quote:
Restart server one and query the balance
Code:
6> robust_bank_client:balance("joe").
trying to connect to server 1
sending to server 1
server 1 replied
{ok,{server1,{atomic,{ok,17}}}}
Server one replies with 17 units well done server one.
When server one was restarted - the two servers synced their data and the changes made to server two were propagated to server one.
My question is how server1 gets propagated data? Each server uses a seperate mnesia database (right?).
I see where tags are stored with cached values, but those are deleted everytime the client gets its reply. So how does server1 ever recover from a crash?
Does the tcp module somehow garuntee delivery of messages once server1 is back online? I wouldn't think so. Is mnesia doing this?
Can you help
--
Confused |
|
|
| Back to top |
|
| michal |
Posted: Tue Sep 25, 2007 6:23 pm |
|
|
|
User
Joined: 20 Jul 2006
Posts: 44
Location: London
|
In robust_bank_manager module Joe creates the database schema as mnesia:create_schema(db_nodes()). This means that mnesia will be running in a distributed mode on several (in our case two) nodes. Later he creates table calling mnesia:create_table/2 function and also passes on a list of nodes on which the tables should be distributed. Once the mnesia schema and tables have been created that way, it is up to mnesia to propagate changes aplied on one node to the other one.
Michal |
_________________ http://www.erlang-consulting.com |
|
| Back to top |
|
| iWantToKeepAnon |
Posted: Tue Sep 25, 2007 10:03 pm |
|
|
|
User
Joined: 31 Jul 2007
Posts: 14
Location: Dallas, TX
|
michal wrote: In robust_bank_manager module Joe creates the database schema as mnesia:create_schema(db_nodes()). This means that mnesia will be running in a distributed mode on several (in our case two) nodes. Later he creates table calling mnesia:create_table/2 function and also passes on a list of nodes on which the tables should be distributed. Once the mnesia schema and tables have been created that way, it is up to mnesia to propagate changes aplied on one node to the other one.
Thanks for the post. I am still learning Erlang and haven't dug into the mnesia side yet. I saw the schema call, I wasn't sure if it just took that node list in order to create multiple schema's in one call or if it in fact linked them together somehow.
Thanks for the info. |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|