<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jorge Alegre Blog &#187; octopus</title>
	<atom:link href="http://www.jorgealegre.com/tag/octopus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jorgealegre.com</link>
	<description>Internet Startups, Technology, My Music and Me</description>
	<lastBuildDate>Sat, 19 Jun 2010 09:04:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Design of BerkeleyDB Client/Sever OctopusDbm</title>
		<link>http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/</link>
		<comments>http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 00:09:16 +0000</pubDate>
		<dc:creator>Jorge Alegre</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[berkeletdb]]></category>
		<category><![CDATA[octopus]]></category>

		<guid isPermaLink="false">http://www.jorgealegre.com/?p=272</guid>
		<description><![CDATA[
			
				
			
		
Last weekend I worked on the design of the new modules for OctopusDbm and looks like nice features are coming in soon. The first release was built, 0.6 and soon I will start documenting the current modules and design.
Community
Any open source project needs a community or group of people that like the technology and contribute [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jorgealegre.com%2F2010%2F02%2Fdesign-of-berkeleydb-clientsever-octopusdbm%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jorgealegre.com%2F2010%2F02%2Fdesign-of-berkeleydb-clientsever-octopusdbm%2F&amp;source=jalegre&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Last weekend I worked on the design of the new modules for OctopusDbm and looks like nice features are coming in soon. The first release was built, 0.6 and soon I will start documenting the current modules and design.</p>
<p><strong>Community</strong></p>
<p>Any open source project needs a community or group of people that like the technology and contribute with ideas, code, testing, analysis, etc&#8230; It will be a nice experience for me to learn how to do this. So the following weeks I will start promoting the project and trying to attract lovers for this project. Spread the word if you read this, this tech can be pretty cool.</p>
<p><strong>Dbm</strong></p>
<p>The client/server implementation works in such a way that the code change for applications already running BerkeleyDB software local is minimal. Almost all API methods are implemented in remote server.</p>
<p>Curently you may have:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code4'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2724"><td class="code" id="p272code4"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> bsddb3 <span style="color: #ff7700;font-weight:bold;">import</span> db
Dbm = db.<span style="color: black;">DB</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
Dbm.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>sPath, db.<span style="color: black;">DB_BTREE</span>, db.<span style="color: black;">DB_CREATE</span><span style="color: black;">&#41;</span>
Dbm.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Name'</span>, <span style="color: #483d8b;">'Jorge'</span><span style="color: black;">&#41;</span>
Dbm.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>And with OctopusDbm:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code5'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2725"><td class="code" id="p272code5"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> octopusdbm <span style="color: #ff7700;font-weight:bold;">import</span> Dbm
<span style="color: #dc143c;">dbm</span> = Dbm<span style="color: black;">&#40;</span>hostName, <span style="color: #dc143c;">user</span>, password<span style="color: black;">&#41;</span>
<span style="color: #dc143c;">dbm</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>sPath, db.<span style="color: black;">DB_BTREE</span>, db.<span style="color: black;">DB_CREATE</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">dbm</span>.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Name'</span>, <span style="color: #483d8b;">'Jorge'</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">dbm</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>So you basicly can open, put, create cursor, get, get table information, etc&#8230; same as you do in local. Keep in mind that for every database methods there is a call to the server. So server connections for open, put and close. If you need better performance we have direct operations where open and close are integrated, like getDirect(), getLIstDirect(), as well as bulk operations like getList() and putList() with tables opened.</p>
<p><span id="more-272"></span><strong>No Db Sessions</strong></p>
<p>One of the design points of OctopusDbm is that you don&#8217;t need to open connections to database or create sessions before processing operations in database. The idea is that getting and putting data is as simple as getting an HTML page, so simply a request is performed and you get result. This way is easier to connect to 10 or 20 cloud images without pool of connection, etc&#8230; Imagine having a pool of 3 connections to 100 cloud images, that would be 300 database connection to manage for every node needing database connectivity to the cloud.</p>
<p>This is of course open to discussion, so place your ideas, etc&#8230;</p>
<p><strong>DbmCloud</strong></p>
<p>We introduce this object for access to the cloud. The distribution has been designed so far to e horizontal. That is, table 1 goes to cloud image 1, table 2 to cloud image2, &#8230;., table 11 to cloud image 1 when having a cloud with 10 images or virtual machines. This object also manages partitions in horizontal way and while you have an integer primary key or index. So tables being in the cloud must have integers if you want to partition them. If they have string indexes they will not be partitioned so far. I think this is ok for first versions. You can allways pass this DbmCloud, implement your own, participate in the project with your own dessign of cloud distributions and partitions, etc&#8230;</p>
<p>It has been decided so far to have an XML file with all schemas, tables, defining number of partitions, number of cloud images organized by domain and application name. For very big systems, they could have different domains and application inside each one with a cloud design. Small apps would have 1 domain and 1 app.</p>
<p>One cool aspect of DbmCloud is that any database object, that is, data table, index file, foreign key will be distributed and queries running on them executed in different cloud images therefore boosting performance, even more when smart partitioning in place.</p>
<p><strong>Models</strong></p>
<p>In order for OctopusDbm be an alternative to SQL databases like MySQL we need a model design that will:</p>
<ul>
<li>Allow us to have tabulated data in columns</li>
<li>Design to make it easy to implement persistent subsystems like Hibernate, JPA, etc&#8230;</li>
</ul>
<p>We thought to do this inside Python similar to Django models, where you define class attributes with classes relative to types and using dictionary class attributes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code6'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2726"><td class="code" id="p272code6"><pre class="python" style="font-family:monospace;">oClient = Client<span style="color: black;">&#40;</span>Name=<span style="color: #483d8b;">'Jorge'</span>, Place=<span style="color: #483d8b;">'Madrid'</span><span style="color: black;">&#41;</span>
oClient.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
oClient = Client.<span style="color: black;">get</span><span style="color: black;">&#40;</span>Name=<span style="color: #483d8b;">'Jorge'</span><span style="color: black;">&#41;</span>
oClient.<span style="color: black;">Place</span> = <span style="color: #483d8b;">'Madrid'</span>
oClient.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>First one creates an object in database system and writes to database in a lazy mode. Second one updates the client object in database. I think the models would support cloud distribution and partitions. You define in the class the attribute types, index names, physical names, etc,&#8230;.</p>
<p>The primary key in tables can be an id or other value. There will be a type IdGenerator that will generate auto ids for rows, but you could define you own primary key values. When support for cloud and partitions we need an integer primary key for partitions.</p>
<p>First versions will probably lack foreign keys, but later on we can implement foreign keys with model integrity. I thought of Links between tables besides ForeignKey types to execute soft links for example to get literal of an id in a parametric table.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm+http://www.jorgealegre.com/?p=272" title="Post to Twitter"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm+http://www.jorgealegre.com/?p=272" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://plurk.com/?status=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm+http://www.jorgealegre.com/?p=272" title="Post to Plurk"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-plurk.png" alt="Post to Plurk" /></a> <a class="tt" href="http://plurk.com/?status=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm+http://www.jorgealegre.com/?p=272" title="Post to Plurk">Plurk This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/&amp;title=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm" title="Post to Digg"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/&amp;title=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://ping.fm/ref/?method=microblog&amp;title=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm&amp;link=http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/" title="Post to Ping.fm"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-ping.png" alt="Post to Ping.fm" /></a> <a class="tt" href="http://ping.fm/ref/?method=microblog&amp;title=Design+of+BerkeleyDB+Client%2FSever+OctopusDbm&amp;link=http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/" title="Post to Ping.fm">Ping This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jorgealegre.com/2010/02/design-of-berkeleydb-clientsever-octopusdbm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
