<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><!-- generator="wordpress/2.1" --><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>miceda</title>
	<link>http://weblog.miceda.org</link>
	<description />
	<pubDate>Thu, 21 May 2009 04:05:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Miceda" type="application/rss+xml" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>rinterface: a pure Ruby client to talk to Erlang</title>
		<link>http://weblog.miceda.org/2009/05/20/rinterface-a-pure-ruby-client-to-talk-to-erlang/</link>
		<comments>http://weblog.miceda.org/2009/05/20/rinterface-a-pure-ruby-client-to-talk-to-erlang/#comments</comments>
		<pubDate>Thu, 21 May 2009 04:00:01 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2009/05/20/rinterface-a-pure-ruby-client-to-talk-to-erlang/</guid>
		<description><![CDATA[After digging through the jinterface code for the past couple of evenings I finally have a working Ruby client that can make RPC calls to an Erlang node.  Although the code is a bit rough right now, it works. 
I&#8217;m hoping to evolve it into a full Ruby node with capabilities similar to jinterface [...]]]></description>
			<content:encoded><![CDATA[<p>After digging through the <a href="http://erlang.org/doc/apps/jinterface/index.html">jinterface</a> code for the past couple of evenings I finally have a working Ruby client that can make RPC calls to an Erlang node.  Although the code is a bit rough right now, it works. </p>
<p>I&#8217;m hoping to evolve it into a full Ruby node with capabilities similar to jinterface (the java implementation included with the Erlang). </p>
<p>The current implementation has a few limitations:</p>
<ol>
<li>The Erlang node and Ruby client must be running on the same machine. This will not be hard to change</li>
<li>The Erlang process must have a registered name</li>
</ol>
<p>Essentially right now it works a lot like the native rpc:call in Erlang.  </p>
<p>Here&#8217;s an example of a Ruby client calling a Erlang process called &#8216;math&#8217;:</p>
<pre>
<code>
EM.run do
  # Connect to epmd to get the port of 'math'.
  # 'math' is the -sname of the erlang node
  epmd = EpmdConnection.lookup_node("math")
  epmd.callback do |port|
    puts "got the port #{port}"

    # make the rpc call to 'math' on port for
    # mod 'math_server' on fun 'add' with args
    node = Node.rpc_call("math",port.to_i,
                                  "math_server",
                                  "add",[10,20])
    node.callback{ |result|
      puts "Sum is: #{result}"
      EM.stop
    }

    node.errback{ |err|
      puts "Error: #{err}"
      EM.stop
    }
  end

  epmd.errback do |err|
    puts "Error: #{err}"
    EM.stop
  end
end
</code>
</pre>
<p>You can check out the code here: <a href="http://github.com/davebryson/rinterface/tree/master">rinterface</a></p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2009/05/20/rinterface-a-pure-ruby-client-to-talk-to-erlang/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting started with BeepBeep</title>
		<link>http://weblog.miceda.org/2009/05/14/getting-started-with-beepbeep/</link>
		<comments>http://weblog.miceda.org/2009/05/14/getting-started-with-beepbeep/#comments</comments>
		<pubDate>Thu, 14 May 2009 20:43:33 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2009/05/14/getting-started-with-beepbeep/</guid>
		<description><![CDATA[I&#8217;ve finally had a little time to work on BeepBeep.  With this time, I&#8217;ve updated some of the docs included with source code, updated the Blog demo app to the latest code base, and moved the demo app into the code base versus a separate project.  I also wrote up a little tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally had a little time to work on <a href="http://github.com/davebryson/beepbeep/tree">BeepBeep</a>.  With this time, I&#8217;ve updated some of the docs included with source code, updated the Blog demo app to the latest code base, and moved the demo app into the code base versus a separate project.  I also wrote up a little tutorial to get you started:</p>
<p>This is a quick tutorial of creating a web application with BeepBeep.  For more details on BeepBeep see the documention and a complete blog example included with the source code.</p>
<p>The tutorial covers:</p>
<ul>
<li>How to create a new application</li>
<li>How to implement a controller</li>
<li>How to create a template</li>
</ul>
<p><a href="http://wiki.github.com/davebryson/beepbeep">Read more here&#8230;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2009/05/14/getting-started-with-beepbeep/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Connecting to Erlang’s epmd from Ruby</title>
		<link>http://weblog.miceda.org/2009/04/24/connecting-to-erlangs-epmd-from-ruby/</link>
		<comments>http://weblog.miceda.org/2009/04/24/connecting-to-erlangs-epmd-from-ruby/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 17:37:21 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2009/04/24/connecting-to-erlangs-epmd-from-ruby/</guid>
		<description><![CDATA[Lately I&#8217;ve been experimenting with creating a pure Ruby library to communicate with Erlang nodes similar to the capabilities offered by the jinterface included with Erlang.  Using a combination of the Java source code for jinterface and the documention, I&#8217;ve had moderate success getting my code to talk to epmd (Erlang Port Mapping Daemon) and [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been experimenting with creating a pure Ruby library to communicate with Erlang nodes similar to the capabilities offered by the <a href="http://erlang.org/doc/apps/jinterface/part_frame.html" title="jinterface">jinterface</a> included with Erlang.  Using a combination of the Java source code for jinterface and the documention, I&#8217;ve had moderate success getting my code to talk to epmd (Erlang Port Mapping Daemon) and pass the intial Erlang &#8220;secret&#8221; <a href="http://erlang.org/doc/apps/erts/erl_dist_protocol.html#9">handshake</a>.</p>
<p>If you&#8217;re not familiar with epmd, it&#8217;s job is to essentially help nodes find one another.  When you start an Erlang node it&#8217;ll automatically pass some information about itself to epmd so other nodes can find it. The epmd runs by default on port 4369 and is started automatically when you run an Erlang application (if it&#8217;s not running already). There are basically two important requests a node makes to epmd: 1) register itself with epmd and 2) given a name of another node, lookup it&#8217;s port.  The format of the requests are documented <a href="http://erlang.org/doc/apps/erts/erl_dist_protocol.html#9.1">here.</a></p>
<p>To look up the port of another Erlang node from Ruby (or any other language).  Here&#8217;s what you need to do:</p>
<p>1. Make a TCP connection to epmd on port 4369</p>
<p>2. Send the port lookup request in the following format</p>
<pre>
n = name of the node we're interested in
| 2 bytes | 1 byte | nodename.size |
----------------------------------------------------
| n + 1    |  122    |           n            |
Where 122 is the tag for port lookup</pre>
<p>3. Read the response from epmd. It&#8217;ll be in this format</p>
<pre>
| 1 byte | 1 byte | 2 bytes |
--------------------------------------
|  119   | result   |  port#   |

Where:119 is the response tag
result &gt; 0 means we were successful
port# is the port number of the node
There's more information after the port, but we'll ignore
that for now.</pre>
<p>Finally here&#8217;s some code to try it out (requires the excellent <a href="http://rubyeventmachine.com/">eventmachine</a>):</p>
<p><a href="http://gist.github.com/101187">ruby_2_epmd.rb</a></p>
<p>To run the example:</p>
<p>1. Start an erlang node in one terminal &#8220;erl -sname hello&#8221;<br />
2. In another terminal run the ruby code.</p>
<p>If sucessful you should get back the port number of the &#8220;hello&#8221; node.</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2009/04/24/connecting-to-erlangs-epmd-from-ruby/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BeepBeep obligatory blog demo</title>
		<link>http://weblog.miceda.org/2008/12/12/beepbeep-obligatory-blog-demo/</link>
		<comments>http://weblog.miceda.org/2008/12/12/beepbeep-obligatory-blog-demo/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 21:37:24 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/12/12/beepbeep-obligatory-blog-demo/</guid>
		<description><![CDATA[This code shows how to build a simple application with BeepBeep. It demonstrates a simple application flow and the use of filters for authentication.
* UPDATE *  The blog demo is not included with the beepbeep source code
Download it here: Blog Demo
It&#8217;s completely standalone, so all you need is Erlang and some curiousity.
Setup
- Download the [...]]]></description>
			<content:encoded><![CDATA[<p>This code shows how to build a simple application with BeepBeep. It demonstrates a simple application flow and the use of filters for authentication.</p>
<p><strong>* UPDATE *</strong>  The blog demo is not included with the beepbeep source code</p>
<p>Download it here: <a href='https://github.com/davebryson/beepbeep/tree'>Blog Demo</a></p>
<p>It&#8217;s completely standalone, so all you need is Erlang and some curiousity.</p>
<p>Setup</p>
<p>- Download the code<br />
- CD into the beebeep_blog_example directory<br />
- run make<br />
- run ./start-server.sh<br />
- point your browser to http://localhost:8000</p>
<p>Since BeepBeep generates the core code and structure for you, the only code I needed to write for this app was:</p>
<p>- src/main_controller.erl – The controller for displaying and creating posts<br />
- src/login_controller.erl – The controller for handling login<br />
- the templates for the app, located in the template directory<br />
- Oh, and the simple blog_db, used to store blog entries in-memory</p>
<p>Go on&#8230;give it a try!</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/12/12/beepbeep-obligatory-blog-demo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BeepBeep: A Rails like framework for Mochiweb</title>
		<link>http://weblog.miceda.org/2008/12/12/beepbeep-a-rails-like-framework-for-mochiweb/</link>
		<comments>http://weblog.miceda.org/2008/12/12/beepbeep-a-rails-like-framework-for-mochiweb/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 17:31:21 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/12/12/beepbeep-a-rails-like-framework-for-mochiweb/</guid>
		<description><![CDATA[BeepBeep is a simple web application framework for Erlang inspired by Rails and Merb. It follows the principle of convention over configuration - meaning if you follow the code structure layout and a few rules when building your app, it&#8217;ll require no extra work on you behalf to map Url requests to your Controllers and [...]]]></description>
			<content:encoded><![CDATA[<p>BeepBeep is a simple web application framework for Erlang inspired by Rails and Merb. It follows the principle of convention over configuration - meaning if you follow the code structure layout and a few rules when building your app, it&#8217;ll require no extra work on you behalf to map Url requests to your Controllers and Views.</p>
<p>BeepBeep is built on <a href='http://code.google.com/p/mochiweb'>Mochiweb</a> and <a href='http://code.google.com/p/erlydtl'>erlyDTL</a>, providing a super fast web server and the ability to define your templates with the Django template language.</p>
<p>Features:</p>
<ul>
<li>A Script to generate a new web application (based on mochiweb&#8217;s approach)</li>
<li>Session Server to store your application state</li>
<li>Before filter on your controllers for things like authentication</li>
<li>Django templates for the view</li>
</ul>
<p>Getting Started:</p>
<ol>
<li>download the code here: <a href="http://github.com/davebryson/beepbeep/tree/master">BeepBeep</a></li>
<li>CD into the beepbeep directory</li>
<li>run make</li>
<li>generate a new web application by running  ./script/new_beep.erl YouAppName &#8220;DestinationDirectory</li>
</ol>
<p>This will create a web app with everything you need. It includes a sample controller (main_controller.erl).</p>
<p>To run the sample:</p>
<ol>
<li>Cd into the new application&#8217;s directory you created above and start the server: ./start-server.sh</li>
<li>Open a browser and visit &#8220;http://localhost:8000&#8243;</li>
</ol>
<p>How it works:</p>
<p>You write a controller similar to how you&#8217;d write a &#8220;gen_server&#8221; based app, but in our case you use the included &#8220;gen_controller&#8221; behavior. In the controller you define the functions you want to expose to requests.  BeepBeep will automatically map Url requests to controller and functions (or actions). For example a request to &#8220;/hello/show&#8221; would map to the &#8220;hello_controller&#8221; and invoke the &#8220;show&#8221; function. </p>
<p>Here&#8217;s a controller example:</p>
<pre>
%% hello_controller.erl
-module(hello_controller).

-export([show/1]).
-export([handle_request/2, before_filter/1]).

-behaviour(gen_controller).
-include("beepbeep.hrl").

show(Params) ->
    gen_controller:call(?MODULE,index,Params).

%% Callback for show
handle_request(show,Params) ->
    {render, "hello/show.html",[{name,"BeepBeep"}],Params}.

%% Callback filter for things like authentication (not using it here)
before_filter(Params) ->
    {ok}.
</pre>
<p>From &#8220;handle_request&#8221; we return a tuple that tells the framework what template to use. Templates are located in the template directory. In our example we&#8217;ll use the template located in the subdirectory &#8220;hello&#8221; and the file &#8220;show.html&#8221;</p>
<p>Here&#8217;s an example of the &#8220;show.html&#8221; template:</p>
<pre>
 &lt;h2&gt;Hello from {{ name }} &lt;/h2&gt;
</pre>
<p>Which will result in:</p>
<p>&lt;h2&gt;Hello from BeepBeep&lt;/h2&gt;</p>
<p>The &#8220;name&#8221; key set in the controller is passed to the template and expanded using the Django format via erlyDTL.</p>
<p>This BeepBeep approach provides a clean separation of the erlang logic in the controller and the html code in the template.</p>
<p>More to come&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/12/12/beepbeep-a-rails-like-framework-for-mochiweb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Erlang init.d script in Ubuntu</title>
		<link>http://weblog.miceda.org/2008/11/25/erlang-initd-script-in-ubuntu/</link>
		<comments>http://weblog.miceda.org/2008/11/25/erlang-initd-script-in-ubuntu/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 17:21:14 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/11/25/erlang-initd-script-in-ubuntu/</guid>
		<description><![CDATA[Problem
You&#8217;ve created an init.d script for your Erlang application. When logged in the script works and starts the app, however it&#8217;s not working on boot.
Solution

Make sure /usr/local/bin/ is recognized in the profile
export HOME in you init.d script that points to the directory with your erlang cookie

]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>You&#8217;ve created an init.d script for your Erlang application. When logged in the script works and starts the app, however it&#8217;s not working on boot.</p>
<h2>Solution</h2>
<ol>
<li>Make sure /usr/local/bin/ is recognized in the profile</li>
<li>export HOME in you init.d script that points to the directory with your erlang cookie</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/11/25/erlang-initd-script-in-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>VMWare Ubuntu copy can’t find network</title>
		<link>http://weblog.miceda.org/2008/11/25/vmware-ubuntu-copy-cant-find-network/</link>
		<comments>http://weblog.miceda.org/2008/11/25/vmware-ubuntu-copy-cant-find-network/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 17:15:39 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/11/25/vmware-ubuntu-copy-cant-find-network/</guid>
		<description><![CDATA[Problem
You created an Ubuntu VMWare appliance and copied to another location.  When booting up the copy the network interfaces are not recognized. Well really you only get the local interface.
Solution
The problem is the mac address is different than the one in the vmx file. Quick fix is to simply delete the file:
/etc/udev/rules.d/70-persistent-net-rules 
in the [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>You created an Ubuntu VMWare appliance and copied to another location.  When booting up the copy the network interfaces are not recognized. Well really you only get the local interface.</p>
<h2>Solution</h2>
<p>The problem is the mac address is different than the one in the vmx file. Quick fix is to simply delete the file:</p>
<p>/etc/udev/rules.d/70-persistent-net-rules </p>
<p>in the original OS *before* copying it. So delete the file, shutdown the OS, then copy it over.  On the first boot in the copy, Ubuntu will generate the file above with the correct mac address and all should be working.</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/11/25/vmware-ubuntu-copy-cant-find-network/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Create a signature of your data with Erlang</title>
		<link>http://weblog.miceda.org/2008/10/27/creating-a-signature-of-your-data-with-erlang/</link>
		<comments>http://weblog.miceda.org/2008/10/27/creating-a-signature-of-your-data-with-erlang/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 13:57:33 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/10/27/creating-a-signature-of-your-data-with-erlang/</guid>
		<description><![CDATA[
-module(signit.erl).
-export(start/0,sha_sign/0).

start() -> application:start(crypto).

%% Sign the data using SHA.
%% This will return a 20 byte key for the data
sha_sign(Data) ->
    Sha_data = crypto:sha(Data),
    Sha_list = binary_to_list(Sha_data),
    lists:flatten(list_to_hex(Sha_list)).

%% Crypto doesn't have a hexdigest method. I found the code below
%% here
%% Convert Integer from the SHA to Hex
list_to_hex(L)->
  [...]]]></description>
			<content:encoded><![CDATA[<pre>
-module(signit.erl).
-export(start/0,sha_sign/0).

start() -> application:start(crypto).

%% Sign the data using SHA.
%% This will return a 20 byte key for the data
sha_sign(Data) ->
    Sha_data = crypto:sha(Data),
    Sha_list = binary_to_list(Sha_data),
    lists:flatten(list_to_hex(Sha_list)).

%% Crypto doesn't have a hexdigest method. I found the code below
%% <a href="http://sacharya.com/?p=22">here</a>
%% Convert Integer from the SHA to Hex
list_to_hex(L)->
       lists:map(fun(X) -> int_to_hex(X) end, L).

int_to_hex(N) when N < 256 ->
       [hex(N div 16), hex(N rem 16)].

hex(N) when N < 10 ->
       $0+N;
hex(N) when N >= 10, N < 16 ->
       $a + (N-10).
</pre>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/10/27/creating-a-signature-of-your-data-with-erlang/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mochiweb to Scalaris example</title>
		<link>http://weblog.miceda.org/2008/07/26/mochiweb-to-scalaris-example/</link>
		<comments>http://weblog.miceda.org/2008/07/26/mochiweb-to-scalaris-example/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 05:33:34 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<category><![CDATA[scalaris]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/07/26/mochiweb-to-scalaris-example/</guid>
		<description><![CDATA[I&#8217;ve created a simple HTTP interface with MochiWeb that allows you to read and write key/Value pairs to Scalaris. The REST &#8220;like&#8221; interface is very simple:
To write, send a request to: &#8220;http://localhost:8002/scalaris/write&#8221; with the parameters key=&#8221;your_key&#8221;, value=&#8221;your_value&#8221;
To read, &#8220;http://localhost:8002/scalaris/read&#8221; with the parameters key=&#8221;your_key&#8221;
The code uses a gen_server process that makes an rpc:call to the Scalaris [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created a simple HTTP interface with MochiWeb that allows you to read and write key/Value pairs to Scalaris. The REST &#8220;like&#8221; interface is very simple:</p>
<p>To write, send a request to: &#8220;http://localhost:8002/scalaris/write&#8221; with the parameters key=&#8221;your_key&#8221;, value=&#8221;your_value&#8221;</p>
<p>To read, &#8220;http://localhost:8002/scalaris/read&#8221; with the parameters key=&#8221;your_key&#8221;</p>
<p>The code uses a gen_server process that makes an rpc:call to the Scalaris API.</p>
<p>You can check out the code here: <a href="http://github.com/davebryson/mochiweb_scalaris/tree/master">mochiweb-scalaris</a></p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/07/26/mochiweb-to-scalaris-example/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How Scalaris stores your data</title>
		<link>http://weblog.miceda.org/2008/07/26/how-scalaris-stores-your-data/</link>
		<comments>http://weblog.miceda.org/2008/07/26/how-scalaris-stores-your-data/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 21:29:53 +0000</pubDate>
		<dc:creator>daveb</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<category><![CDATA[scalaris]]></category>

		<guid isPermaLink="false">http://weblog.miceda.org/2008/07/26/how-scalaris-stores-your-data/</guid>
		<description><![CDATA[After installing Scalaris, running a few nodes, and playing with the API, I wanted to figure out how it actually stores the data. Using this diagram: supervisor.pdf I tracked down the source in the file cs_db_otp.erl ( the db was the obvious clue). 
The database is a gen_server that wraps calls to the underlying storage [...]]]></description>
			<content:encoded><![CDATA[<p>After installing Scalaris, running a few nodes, and playing with the API, I wanted to figure out how it actually stores the data. Using this diagram: <a href="http://code.google.com/p/scalaris/source/browse/trunk/user-dev-guide/supervision.pdf">supervisor.pdf</a> I tracked down the source <a href="http://code.google.com/p/scalaris/source/browse/trunk/src/cs_db_otp.erl">in the file cs_db_otp.erl</a> ( the db was the obvious clue). </p>
<p>The database is a gen_server that wraps calls to the underlying storage - an Erlang <a href="http://erlang.org/doc/man/gb_trees.html">gb_tree</a>. What this means is the data is <i>not actually saved to disk</i>, but rather lives in memory. It appears the each chordnode has its own database.</p>
<p>When you store a Key - Value pair, the database actually records a structure like this in the gb_tree: </p>
<pre>
 Key,{Value,WriteLock,ReadLock,Version}
</pre>
<p>On a write, &#8220;WriteLock&#8221; is set to true and the Version is incremented. On a read, &#8220;ReadLock&#8221; is set to true.  Most of this logic appears to be controlled through the transaction layer.</p>
<h3>Other stuff</h3>
<ul>
<li>Search? There appears to be the ability to search for keys within a given range via a &#8220;get_range&#8221;. But I haven&#8217;t yet found how to call that from the transaction_api</li>
<li>No delete. As I mentioned in my earlier write up on using the API, there is no way to actually &#8220;delete&#8221; a key once it&#8217;s set. But hey, the code is open-source and since gb_tree has a delete method, it should be possible to add.</li>
</ul>
<p>One other thing of note,  if you&#8217;ve implemented any distributed Erlang you know it&#8217;s not recommended to run a cluster of Erlang nodes around the Internet using the built in code.  Scalaris implements its own TCP layer (the authors mention this in their Videos) for the nodes to communicate.  Check out the comm_layer in the source for some ideas if you need to write your own.  </p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.miceda.org/2008/07/26/how-scalaris-stores-your-data/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
