New mnesia events

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

New mnesia events

chandru
I think it will be useful if mnesia could issue the following events.
 
{table_created, Table}
{table_deleted, Table}
{table_available, Table} - This would be like an asynchronous version of
mnesia:wait_for_tables(Tables, Timeout). Right now, I have some very big
tables and a process which uses them doesn't know when they will be
available. But it can't wait forever in mnesia:wait_for_tables - the way to
do it now would be to have a timer to periodically check if the required
table is available. Would be easier if my process could just subscribe for
an event.
 
The first two would be useful in a case where tables are created/deleted
dynamically in an application. The way to do it now would be to use
mnesia:report_event - but it would be nice to have a standard way of knowing
when a table has been created/deleted.
 
The table event {delete, {Tab, Key}, ActivityId} is not issued for each key
when a table is deleted - which is sensible - but {table_deleted, Table}
would nicely fill the gap.
 
cheers,
Chandru
 



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




Reply | Threaded
Open this post in threaded view
|

New mnesia events

Dan Gudmundsson-4

Sounds nice, if I got the time I'll add it in the R8 release..

/Dan

Chandrashekhar Mullaparthi writes:
 > I think it will be useful if mnesia could issue the following events.
 >  
 > {table_created, Table}
 > {table_deleted, Table}
 > {table_available, Table} - This would be like an asynchronous version of
 > mnesia:wait_for_tables(Tables, Timeout). Right now, I have some very big
 > tables and a process which uses them doesn't know when they will be
 > available. But it can't wait forever in mnesia:wait_for_tables - the way to
 > do it now would be to have a timer to periodically check if the required
 > table is available. Would be easier if my process could just subscribe for
 > an event.
 >  
 > The first two would be useful in a case where tables are created/deleted
 > dynamically in an application. The way to do it now would be to use
 > mnesia:report_event - but it would be nice to have a standard way of knowing
 > when a table has been created/deleted.
 >  
 > The table event {delete, {Tab, Key}, ActivityId} is not issued for each key
 > when a table is deleted - which is sensible - but {table_deleted, Table}
 > would nicely fill the gap.
 >  
 > cheers,
 > Chandru
 >  


Reply | Threaded
Open this post in threaded view
|

New mnesia events

Håkan Mattsson-6
In reply to this post by chandru
On Fri, 9 Mar 2001, Chandrashekhar Mullaparthi wrote:

Chandrashekhar> I think it will be useful if mnesia could issue the following events.
Chandrashekhar>  
Chandrashekhar> {table_created, Table}
Chandrashekhar> {table_deleted, Table}

Don't you like mnesia:subscribe({table, schema})?

Chandrashekhar> {table_available, Table} - This would be like an asynchronous version of
Chandrashekhar> mnesia:wait_for_tables(Tables, Timeout). Right now, I have some very big
Chandrashekhar> tables and a process which uses them doesn't know when they will be
Chandrashekhar> available. But it can't wait forever in mnesia:wait_for_tables - the way to
Chandrashekhar> do it now would be to have a timer to periodically check if the required
Chandrashekhar> table is available. Would be easier if my process could just subscribe for
Chandrashekhar> an event.
Chandrashekhar>  
Chandrashekhar> The first two would be useful in a case where tables are created/deleted
Chandrashekhar> dynamically in an application. The way to do it now would be to use
Chandrashekhar> mnesia:report_event - but it would be nice to have a standard way of knowing
Chandrashekhar> when a table has been created/deleted.

You always have the option of spawning a separate process in order
to perform the monitoring of when tables gets loaded, but my original
idea was to handle thos via the event mechanism.

Chandrashekhar> The table event {delete, {Tab, Key}, ActivityId} is not issued for each key
Chandrashekhar> when a table is deleted - which is sensible - but {table_deleted, Table}
Chandrashekhar> would nicely fill the gap.

As mentioned above, use the mnesia:subscribe/1 function.

/H?kan

---
H?kan Mattsson
Ericsson
Computer Science Laboratory
http://www.ericsson.se/cslab/~hakan


--- CUT --- CUT --- CUT --- CUT --- CUT --- CUT --- CUT --- CUT --
unix> erl
Erlang (BEAM) emulator version 5.0.2 [threads]

Eshell V5.0.2  (abort with ^G)
1> mnesia:start().
ok
2> mnesia:subscribe({table, schema}).
{ok,nonode}
3> mnesia:create_table(a_brand_new_table, []).
{atomic,ok}
4> flush().
Shell got {mnesia_table_event,{write,{schema,
                                         a_brand_new_table,
                                         [{name,a_brand_new_table},
                                          {type,set},
                                          {ram_copies,[nonode]},
                                          {disc_copies,[]},
                                          {disc_only_copies,[]},
                                          {load_order,0},
                                          {access_mode,read_write},
                                          {index,[]},
                                          {snmp,[]},
                                          {local_content,false},
                                          {record_name,a_brand_new_table},
                                          {attributes,[key,val]},
                                          {user_properties,[]},
                                          {frag_properties,[]},
                                          {cookie,
                                              {{984,134919,30740},
                                               nonode}},
                                          {version,{{2,0},[]}}]},
                                     {tid,3,<0.63.0>}}}
Shell got {mnesia_table_event,{write,{schema,
                                         a_brand_new_table,
                                         [{name,a_brand_new_table},
                                          {type,set},
                                          {ram_copies,[nonode]},
                                          {disc_copies,[]},
                                          {disc_only_copies,[]},
                                          {load_order,0},
                                          {access_mode,read_write},
                                          {index,[]},
                                          {snmp,[]},
                                          {local_content,false},
                                          {record_name,a_brand_new_table},
                                          {attributes,[key,val]},
                                          {user_properties,[]},
                                          {frag_properties,[]},
                                          {cookie,
                                              {{984,134919,30740},
                                               nonode}},
                                          {version,{{2,0},[]}}]},
                                     {tid,3,<0.63.0>}}}
5> mnesia:delete_table(a_brand_new_table).
{atomic,ok}
6> flush().
Shell got {mnesia_table_event,{delete,{schema,
                                          a_brand_new_table,
                                          [{name,a_brand_new_table},
                                           {type,set},
                                           {ram_copies,[nonode]},
                                           {disc_copies,[]},
                                           {disc_only_copies,[]},
                                           {load_order,0},
                                           {access_mode,read_write},
                                           {index,[]},
                                           {snmp,[]},
                                           {local_content,false},
                                           {record_name,a_brand_new_table},
                                           {attributes,[key,val]},
                                           {user_properties,[]},
                                           {frag_properties,[]},
                                           {cookie,
                                               {{984,135646,22951},
                                                nonode}},
                                           {version,{{2,0},[]}}]},
                                      {tid,4,<0.66.0>}}}
ok
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution7>
unix>