<?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>Source Allies Blog</title>
	<atom:link href="http://blogs.sourceallies.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.sourceallies.com</link>
	<description>Technical and process thinking from Source Allies employees</description>
	<lastBuildDate>Thu, 19 Aug 2010 18:35:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Would you start mocking me?</title>
		<link>http://blogs.sourceallies.com/2010/08/would-you-start-mocking-me/</link>
		<comments>http://blogs.sourceallies.com/2010/08/would-you-start-mocking-me/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 14:54:39 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[Mockito]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1545</guid>
		<description><![CDATA[ ]]></description>
			<content:encoded><![CDATA[<p>One of the primary principles of <a href="http://en.wikipedia.org/wiki/Unit_testing">unit testing</a> is to test a small piece of functionality in isolation.  In order to achieve this, <a href="http://en.wikipedia.org/wiki/Mock_object">mock objects</a> are often necessary.  Historically using mocks could be quite painful.  After using several mock frameworks, my favorite by far is <a href="http://mockito.org">Mockito</a>.</p>
<h1>Tutorial</h1>
<p>In this tutorial we will walk through examples of the most common features of Mockito. My sample project can be downloaded <a href="http://github.com/kesslerdn/mockito-learning">here</a>.</p>
<h2>Interfaces and Implementation</h2>
<p>Some mocking frameworks only supported mocking interfaces.  As a result our projects became bloated with useless interfaces that were only used for testing.  Mockito creates mock objects with interfaces or classes.<br />
<span id="more-1545"></span><br />
<code><br />
interface Person{<br />
List getChildren();<br />
Boolean isCitizen();<br />
Integer getAge();<br />
Map getSchedule();<br />
void haveChild();<br />
}</code></p>
<p><code><br />
class PersonImpl implements Person{<br />
public List getChildren() { return null; }<br />
public Boolean isCitizen() { return null; }<br />
public Integer getAge() { return null; }<br />
public Map getSchedule() { return null; }<br />
public void haveChild() { }<br />
}<br />
</code></p>
<p><code><br />
assertNotNull(Mockito.mock(Person.class));<br />
assertNotNull(Mockito.mock(PersonImpl.class));<br />
</code></p>
<h2>Default Values</h2>
<p>Mockito provides stub implementations for all of the methods on the interface/class.  It also provides several common sense defaults out of the box.</p>
<p><code><br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
assertNotNull(mockPerson.getChildren());<br />
assertEquals(0, mockPerson.getChildren().size());<br />
assertFalse(mockPerson.isCitizen());<br />
assertEquals(new Integer(0), mockPerson.getAge());<br />
assertNotNull(mockPerson.getSchedule());<br />
</code><br />
Mockito returns empty Lists and Maps to prevent NPE&#8217;s in your test code.  It defaults to false for Boolean return values.  By default Zero is returned for Integer, Long and Double.  Notice that even though PersonImpl returns null for all of its methods the Mockito version returns reasonable default values.</p>
<h2>Changing Behavior</h2>
<p><code><br />
Person mockPerson = mock(PersonImpl.class);<br />
Mockito.when(mockPerson.getAge()).thenReturn(35);<br />
assertEquals(new Integer(35), mockPerson.getAge());<br />
</code></p>
<p>Mockito.when() takes a mock and a method call that returns a value.  Mockito&#8217;s thenReturn() method takes the return value that Mockito will provide to all matching calls.  By default the method getAge() returns Zero, within Mockito, but now it returns 35.  This ability to control behavior is the key to testing functionality in isolation.</p>
<h2>Verifying Method Calls</h2>
<p><code><br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
mockPerson.getAge();<br />
Mockito.verify(mockPerson).getAge();<br />
</code></p>
<p>Mockito.verify() takes a mock object and verifies that the following method is called.</p>
<p><code><br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
mockPerson.getAge();<br />
mockPerson.getAge();<br />
Mockito.verify(mockPerson, Mockito.times(2)).getAge();<br />
</code></p>
<p>This is the same verify as before except a second parameter is passed to the verify() method telling it how many times the trailing method should be called.</p>
<p><code><br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
mockPerson.getAge();<br />
mockPerson.getAge();<br />
Mockito.verify(mockPerson, Mockito.atLeastOnce()).getAge();<br />
</code></p>
<p>Sometimes it is not important how many times a method is called as long as it is called at least once.  Mockito.atLeastOnce() method provides this flexibility.</p>
<h2>No More Interactions</h2>
<p><code><br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
mockPerson.getAge();<br />
Mockito.verify(mockPerson).getAge();<br />
Mockito.verifyNoMoreInteractions(mockPerson);<br />
</code></p>
<p>Mockito.verifyNoMoreInteractions() ensures that no other methods have been called on the PersonImpl class.  Since Mockito is very helpful in stubbing out all of the methods for a class or interface there is no control over which methods have been called.  Only methods that have been explicitly verified are checked for specific calls.</p>
<h2>Throw Exception</h2>
<p><code><br />
@Test(expected = RuntimeException.class)<br />
public void testThenThrow(){<br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
Mockito.when(mockPerson.getAge()).thenThrow(new RuntimeException("test exception"));<br />
mockPerson.getAge();<br />
}<br />
</code></p>
<p>The thenThrow() method prepares the method defined in when() to throw an Exception.  While I am not attempting to provide a tutorial on JUnit4 features, I feel it necessary to point out the Annotation verifies that a RuntimeException is thrown in the test.</p>
<p><code><br />
@Test(expected = RuntimeException.class)<br />
public void testDoThrow(){<br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
Mockito.doThrow(new RuntimeException("test exception")).when(mockPerson).haveChild();<br />
mockPerson.haveChild();<br />
}<br />
</code></p>
<p>The doThrow() syntax is necessary to throw an Exception for a void method.  The previous example threw an exception for Person.getAge() which is not a void method.  In this example Person.haveChild() is void and requires this alternate syntax in order to compile.</p>
<h2>TDD with Mockito</h2>
<p>Let&#8217;s drive a small class that we will call Bouncer.  This class will check if a Person is old enough to drink.  First let&#8217;s write a test.</p>
<p><code><br />
@Test<br />
public void testCheckAgeOf_UnderAge(){<br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
Mockito.when(mockPerson.getAge()).thenReturn(20);<br />
Bouncer bouncer = new Bouncer();<br />
assertFalse(bouncer.checkAgeOf(mockPerson));<br />
}<br />
</code></p>
<p>Of coarse this does not even compile.  We need to create a Bouncer class with the checkAgeOf() method.  And here is the amazing class</p>
<p><code><br />
class Bouncer{<br />
public boolean checkAgeOf(Person customer){<br />
return false;<br />
}<br />
}<br />
</code></p>
<p>So why did I return false.  Well the test does not require anything more than this to pass.  TDD is about doing the simplest thing that works and then refactor the code.  This is the simplest thing that works.  Now let&#8217;s write another test.</p>
<p><code><br />
@Test<br />
public void testCheckAgeOf_OfAge(){<br />
Person mockPerson = Mockito.mock(PersonImpl.class);<br />
Mockito.when(mockPerson.getAge()).thenReturn(21);<br />
Bouncer bouncer = new Bouncer();<br />
assertTrue(bouncer.checkAgeOf(mockPerson));<br />
}<br />
</code></p>
<p>Now we need real business logic in our method.</p>
<p><code><br />
return customer.getAge() &gt;= 21;<br />
</code></p>
<p>Green again.  Now it is time to refactor.  In this simple case I am not sure how to simplify the code.  There are a few more tests that should be written.  A test if getAge() returns null and if Person is null and other boundary cases.  Since the focus of this article is on Mockito I will stop here.</p>
<p>Mockito is a powerful mocking framework that simplifies the creation and usage of mock objects.  I encourage you to download my <a href="http://github.com/kesslerdn/mockito-learning">sample code</a> and continue to explore the Mockito framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/08/would-you-start-mocking-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Agile Teams: Unequal and Opposite Reactions</title>
		<link>http://blogs.sourceallies.com/2010/07/agile-teams-unequal-and-opposite-reactions/</link>
		<comments>http://blogs.sourceallies.com/2010/07/agile-teams-unequal-and-opposite-reactions/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:23:30 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Process]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[lean]]></category>
		<category><![CDATA[team]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1533</guid>
		<description><![CDATA[Einstein&#8217;s Third law of motion, &#8220;To every action there is always an equal and opposite reaction&#8230;&#8221; is a powerful standard in analyzing team dynamics.  I have been leading agile teams for over five years.  When I am asked to lead a new team I begin by looking for reactions that are disproportionate.  While this may [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">Einstein&#8217;s <a title="Third law of motion" href="http://en.wikipedia.org/wiki/Newton%27s_laws_of_motion#Newton.27s_third_law" target="_blank">Third law of motion</a>, &#8220;To every action there is always an equal and opposite reaction&#8230;&#8221; is a powerful standard in analyzing team dynamics.  I have been leading agile teams for over five years.  When I am asked to lead a new team I begin by looking for reactions that are disproportionate.  While this may seem like a strange place to focus this is a simple way to identify significant areas of improvement.</span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">Time and time again, I have uncovered issues that have been ignored and/or hidden by exploring &#8220;over reactions&#8221;.  They are indicators that there is more to the story.  For example, one of teams that I was leading was very frustrated with how much time we were spending estimating stories.  Their frustration eventually culminated in some of the team members refusing to participate in team estimation meetings.  As you can imagine this created significant tension between the developers and the business team.</span><br />
<span id="more-1533"></span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">While some teams do take too long to estimate, this team generally spent less than 1 percent of their month estimating cards.  With this unequal and opposite reaction focusing my attention I began to interview team members one-on-one.  These conversations confirmed that there was a problem, but failed to adequately explain why.</span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">At this point I approached the Project Lead and requested that we all sit down and discuss the estimation process.  At the conclusion of this meeting two things were clear.  First, the development team did not trust the business team&#8217;s motivations for gathering estimates.  Second, they did not feel like decision makers were adjusting their expectations based on the estimates that they received.</span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">This conversation helped both sides understand each other.  While this was not a magical cure, it did realign the action of estimating and the team’s reactions.  This may still seem like it was not worth addressing.</span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">On the contrary, exaggerated emotional investment can be a significant source of <a title="waste" href="http://en.wikipedia.org/wiki/Lean_software_development#Eliminate_waste" target="_blank">waste</a>.  This type of waste is often expressed through frustrations, confusion, fear, and/or apathy.  Individual opinions spread throughout teams and become a significant source of waste.  The only way to reduce this waste is to understand the root causes.  I do not have a perfect approach to efficiently identify these sources.  In my experience it takes patience and persistence to uncover the truth.</span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">These principles also apply to under reactions.  Some teams that have lost hope will withdraw.  The under reactions that will follow are just as important to address as over reactions.  Remember to pay attention to wheels that are abnormally quiet while you are oiling squeaky wheels.</span></p>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;text-decoration: none;vertical-align: baseline">As technical people we often shy away from feelings, however like it or not our teams are made up of people.  People that have feelings that are formed by their experiences and perceptions.  Ultimately people want to be heard and understood.  Once this occurs, teams tend to realign their reactions.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/07/agile-teams-unequal-and-opposite-reactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Glance at PowerShell</title>
		<link>http://blogs.sourceallies.com/2010/07/first-glance-at-powershell/</link>
		<comments>http://blogs.sourceallies.com/2010/07/first-glance-at-powershell/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 20:15:50 +0000</pubDate>
		<dc:creator>Max  Kuipers</dc:creator>
				<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1524</guid>
		<description><![CDATA[A couple days ago I had the surprisingly excellent opportunity to learn and use Windows PowerShell&#8230; What? Don&#8217;t look at me like that. I disapprove of Microsoft just as much as the next Linux fanboy, but seriously, this was cool. Just give me a chance to explain. I swear, I was forced into the situation [...]]]></description>
			<content:encoded><![CDATA[<p>A couple days ago I had the surprisingly excellent opportunity to learn and use <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">Windows PowerShell</a>&#8230; What? Don&#8217;t look at me like that. I disapprove of Microsoft just as much as the next Linux fanboy, but seriously, this was cool. Just give me a chance to explain. I swear, I was forced into the situation &#8211;  one of the projects I was working on required a simple script be written to rename files on a Windows server, but for various reasons, I couldn&#8217;t use <a href="http://en.wikipedia.org/wiki/Cygwin">Cygwin</a>. After a brief panic attack caused by the realization that I would have to be separated from my beloved Bash, I looked into which scripting language would be best. After an exhaustive, comprehensive, and fully extensive 30-second Google search I found myself with a choice between Powershell and classic Batch&#8230; Naturally, I chose Powershell.</p>
<p><span id="more-1524"></span></p>
<p>Most Windows 7 computers come with PowerShell and all the necessary dependencies already installed, so I never actually had to install it, but from what I&#8217;ve read the setup is fairly simple &#8211; you just sort of install it.  You also get a little IDE called Powershell ISE which is basically just your standard, 3-pane scripting IDE (with a command-line interpreter in one pane, the output in another, and a third pane for writing and saving scripts.)</p>
<p>I tried my standard approach of consulting forums and the <a href="http://msdn.microsoft.com/en-us/library/default.aspx">MSDN library</a> for a little while but it seemed most of the documentation I could find was either circular and self-referencing or written by some rabid Microsoft fanatic who was so hopelessly drunk on the M$ Kool-Aid that every other word they wrote was some special Microsoft technology or practice. After about a half hour of reading online documentation, all that I really learned was that commands in PowerShell are called &#8220;cmdlets.&#8221; It&#8217;s not clear what the distinction is between a cmdlet and your standard Bash command in Linux, but I guess I&#8217;ve seen more pathetic cries for attention in the Windows world than this.</p>
<p>Slightly dismayed at my lack of progress in learning much from my usual way, I considered the much suggested <code>get-help</code> cmdlet&#8230;</p>
<p><strong>UGH</strong> Ok, I&#8217;m just going to stop right here, I can&#8217;t make it any further calling these things &#8220;cmdlets.&#8221; Call me stubborn, or close-minded, but this is just ridiculous.  I&#8217;m calling them &#8220;commands.&#8221;</p>
<p>&#8230;Anyways, silly nomenclature aside, this <code>get-help</code> command is kind of like a &#8220;man&#8221; page to a Linux user, it displays the syntax, description, and examples for any command in PowerShell. The get-help command is in some ways even a little more clever than man pages. For instance, I needed to know how to create a new directory so first thing I tried was <code>get-help mkdir</code>. While <code>mkdir</code> is not a command in PowerShell, nor does it even have a directly analogous single-command counterpart in PowerShell, it recognized what I was asking for and brought me to the page for the <code>New-Item</code> command which has a <code>-type directory</code> flag you can use to make a new directory.  With this command, I was able to learn anything I needed to learn to make my script happen.</p>
<p>There were, of course, a few more bumps in the road, but nothing too serious; string manipulation is distinctly different from most other languages, and there was some difficulty in getting the permissions (or execution-policy) just right so that I could actually run the script.  All-in-all, it took me about four hours to get the environment set up, learn enough of the language to be productive, and finally write and test the script I needed.  Despite the handicap that it is a Microsoft-specific product, Powershell sincerely surprised me by being a fairly easy-to-learn and useful scripting language.  I really only got to use a very small part of the language, but nonetheless, I would recommend Powershell to anyone who needs to write a script in Windows but cannot use Cygwin.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/07/first-glance-at-powershell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How RAID 5 Works at a Bitwise Level</title>
		<link>http://blogs.sourceallies.com/2010/05/how-raid-5-works-at-a-bitwise-level/</link>
		<comments>http://blogs.sourceallies.com/2010/05/how-raid-5-works-at-a-bitwise-level/#comments</comments>
		<pubDate>Fri, 28 May 2010 11:01:56 +0000</pubDate>
		<dc:creator>Max  Kuipers</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[data storage]]></category>
		<category><![CDATA[How RAID Works]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[raid 5]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1386</guid>
		<description><![CDATA[RAID 5 is a pretty magical thing overall, though a large portion of its magic lies in how it works on a bitwise level.  But before I get into the bitwise sorcery, I&#8217;d like to briefly explain what RAID5 is. RAID stands for Redundant Array of Inexpensive (or Independent) Disks. There are a number of [...]]]></description>
			<content:encoded><![CDATA[<p>RAID 5 is a pretty magical thing overall, though a large portion of its magic lies in how it works on a bitwise level.  But before I get into the bitwise sorcery, I&#8217;d like to briefly explain what RAID5 is. RAID stands for Redundant Array of Inexpensive (or Independent) Disks. There are a number of different types of RAID such as RAID0, RAID1, RAID5 and RAID6 which each store data in different ways and have different space efficiencies and fault tolerances.<br />
<span id="more-1386"></span></p>
<blockquote><p>Space efficiency is given as amount of storage space available in an array of n disks, in multiples of the capacity of a single drive. For example if an array holds n=5 drives of 250GB and efficiency is n-1 then available space is 4 times 250GB or roughly 1TB.</p></blockquote>
<p>The space efficiency of RAID5 is n-1 and the fault tolerance allows for one disk to go down at a time.  What this means is that if you have a RAID5 array set up, you lose one of your disk&#8217;s worth of space in the array, yet if any one of the disks in the array goes down, you do not lose any data.  Compared to something like RAID1 which simply mirrors all data so that what is stored on one disk is also stored on another, RAID5 has a much better space efficiency.</p>
<p>Now if you&#8217;re like me, you probably wondered, &#8220;How the hell is RAID5 possible? Where do they fit the data? If you back up data, shouldn&#8217;t it all be duplicated somewhere? How is it possible to have space efficiency less than 1/2 n?  Isn&#8217;t there some conservation of mass law that prevents such a preposterously awesome thing from happening?&#8221;   To understand the answer to the question, we have to look at the bitwise level of RAID5, or how the data is really stored in 1&#8217;s and 0&#8217;s. And this, my friend, is where the mysterious and beautiful Exclusive Or (XOR) operator comes in.<!--more--></p>
<p>Many of you are familiar with AND and OR operators, AND only evaluates to true when both inputs are true, while OR only evaluates to false when both inputs are false.  The mathematical miscreant we know as &#8220;XOR&#8221; only evaluates to true when both of its inputs are opposite.  So, to quickly summarize the XOR function, take a look at the following truth table:</p>
<div id="attachment_1495" class="wp-caption aligncenter" style="width: 173px"><a href="http://ozark.hendrix.edu/~burch/logisim/docs/2.1.0/guide/tutorial/"><img class="size-full wp-image-1495" title="xor-table" src="http://blogs.sourceallies.com/wp-content/uploads/2010/04/xor-table.png" alt="An Exclusive Or Truth Table" width="163" height="131" /></a><p class="wp-caption-text">An Exclusive Or Truth Table</p></div>
<p>Got it? Good.</p>
<p>XOR has a few other interesting properties as well, the most important of which is that it is reversible.  That is, if you XOR A and B to get result C, then you can get A back by doing B XOR C, or get B back by doing A XOR C.  This can be extended so that if you do (A XOR B) XOR C = D, then you can do the same thing to get back any of the data stored in A, B, or C, by applying the exclusive or operator to D and the other two inputs.  Don&#8217;t believe me? Let&#8217;s do an example:</p>
<p>Let&#8217;s say A = 0010, B = 0101, and C = 1100.  So D would be equal to the XOR of all three:</p>
<pre>  (A XOR B XOR C)
= (0010 XOR 0101) XOR C
= 0111 XOR C
= 0111 XOR 1100
= 1101
= D</pre>
<p>So now if for some reason we lost one of the inputs, (A, B, or C), we can use D and two of the other inputs to get that one back.   So let&#8217;s say we lose B, we can get the data it contained back by XOR-ing the other three parts together:</p>
<pre>  A XOR C XOR D
= 0010 XOR 1100 XOR D
= 1110 XOR 1011
= 0101
= B</pre>
<p>Did I just blow your mind?  Some people call it &#8220;math.&#8221;  Others call it &#8220;logic.&#8221;  I call it like I see it and that XOR is straight up witchcraft.</p>
<p>Well all fantasy aside, the above example has some very practical applications for data storage. RAID5 uses this unique property of XOR to sort of stack data on top of each other into a storage unit called the &#8220;parity block&#8221; or &#8220;parity drive&#8221; (datum D in the example above would be considered the parity datum.) But the concept of RAID5 is a little more complicated than just abstracting the A, B, C, and D example from above to apply to whole drives instead of just 4-bit numbers.  RAID5 uses something called &#8220;striping&#8221; to store data. Each drive in a RAID5 array is &#8220;striped&#8221; into parts so that when you store data, you store it across all the drives in the array.  The concept of &#8220;striping&#8221; is probably best described the aid of the following picture:</p>
<div id="attachment_1488" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-1488" title="500px-RAID_5.svg" src="http://blogs.sourceallies.com/wp-content/uploads/2010/04/500px-RAID_5.svg-300x222.png" alt="4 - Disk Array in RAID5 format" width="300" height="222" /><p class="wp-caption-text">4 - Disk Array in RAID5 format</p></div>
<p>Each of the four drives in the picture above is divided into four blocks, each belonging to a stripe on the same level across each drive.  Each drive and each stripe have a parity block which is the XOR of the other three blocks. In the picture this is denoted by the subscript &#8220;p.&#8221; The fault tolerance for this set up with striping works just like the example above but repeated for every stripe.  So say you lost drive 3, you would XOR A<sub>1</sub> with A<sub>2</sub> and A<em><sub>p</sub></em> to get the remaining A<sub>3</sub> for the A stripe, B<sub>1</sub> with B<sub>2 </sub>and B<sub>3<strong> </strong></sub>to get your parity block, and then the same with C and D to get those bits of data back.</p>
<p>And that, in short, is how RAID5 works.</p>
<p>Sources:</p>
<p>http://en.wikipedia.org/wiki/RAID</p>
<p>http://www.scottklarr.com/topic/23/how-raid-5-really-works/</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/05/how-raid-5-works-at-a-bitwise-level/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing Ubuntu: A Trial and Error Account</title>
		<link>http://blogs.sourceallies.com/2010/05/installing-ubuntu-a-trial-and-error-account/</link>
		<comments>http://blogs.sourceallies.com/2010/05/installing-ubuntu-a-trial-and-error-account/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:04:12 +0000</pubDate>
		<dc:creator>Ryan  Day</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1509</guid>
		<description><![CDATA[Recently I decided it was time to grab up a spare computer that I could use for tinkering as well as back up files from my other machine in the event that it goes down. The one big thing I wanted to do was to install a Linux OS and experience everything that comes with [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I decided it was time to grab up a spare computer that I could use for tinkering as well as back up files from my other machine in the event that it goes down. The one big thing I wanted to do was to install a Linux OS and experience everything that comes with it. This would be my first time installing a Linux OS. I chose to install <a href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> since it is the most widely used and has the most extensive documentation and help available.</p>
<p><strong>The Download</strong><br />
When I bought this machine it had a fresh install of Windows XP and came with the recovery disk which was excellent because I had to use it multiple times before I got things just the way I wanted them. Since this computer didn’t have any files I didn’t have to worry about backing anything up but it would be a must if considering putting Ubuntu on an everyday machine. To install Ubuntu you need the install CD. Ubuntu community can mail you one if you so request online, but why not be a DIYer and burn it yourself? I downloaded the Ubuntu 9.10 Desktop version for a graphical install and then went straight to burning it onto a CD. This was a mistake. I didn’t figure that the piece of the installation instructions regarding running the checksum was all that important, but it absolutely is. If the download is the least bit wrong the installation will not work. I burned several CDs of a bad image. Eventually I followed the installation documentation more closely and actually downloaded winMd5Sum. With this free tool I was able to compare the checksum of the downloaded image with the correct checksum from the <a href="https://help.ubuntu.com/community/UbuntuHashes" target="_blank">Ubuntu site</a>. It took several attempts and switching to a Canadian mirror before getting a successful download. Finally I could burn it to a disc.</p>
<p><span id="more-1509"></span></p>
<p><strong>Burning the Disc</strong><br />
The download comes as an image with an “.iso” extension. I had never burned an image before so I followed the Ubuntu advice to download the free Infra Recorder. The actual burning of the image to the disc couldn’t have been easier. Following the Ubuntu instructions I quickly had an Ubuntu install disc. I inserted it into my computer and restarted it so it could boot from the disc and headed straight to the install options. Here is where I went wrong for the second time by skipping a small part of the install instructions. Instead of using the “Install” option on the disc I should have first chose, “Check the disc for defects.”  After a few failed installs and a bunch of wasted time, choosing the “Check for defects” option finally revealed that while my download was successful, my burn did not translate to the disc just right. Burning another disc or two finally yielded some successful results.</p>
<p><strong>Installing</strong><br />
There are many ways to install Ubuntu. It can be installed as the sole operating system on the computer, as a virtual OS inside of Windows, or even as a side-by-side dual boot with Windows. I was attempting the latter. When trying to achieve a dual boot installation the hard drive must be partitioned so that each OS can reside in its own territory. With Windows on the machine I first dabbled in the computer management menu to try to clear space for Ubuntu, but then while installing it was difficult to interpret the partitioning. My solution was to reformat the hard drive so that Windows again occupied the whole hard drive and then use the installer disc to set up the partitions. I think this is the best option because you get a very good visual of how your hard drive is split up and you’ll have to go through the setup menu anyway so it saves you time from toiling in a Windows configuration. Other items in the installation process are very easy such as choosing language, naming the computer and setting up a user account. With the install completed, the next time the computer starts there will be a choice to start Ubuntu or Windows which is the whole idea of a dual-booting system.</p>
<p>In Conclusion<br />
Installing Ubuntu, especially in a dual-boot situation, can be a daunting task. Although my experience exemplified Murphy’s Law it is a very do-able process. Looking back, I could have saved a ton of time had I followed the online instructions more carefully and verified the download and burn of the image. Bottom line though is that the instructions and documentation are great resources and there are plenty of forums and YouTube <a href="http://www.youtube.com/results?search_query=how+to+install+ubuntu&amp;aq=f" target="_blank">videos</a> also documenting the process. With the volume of help out there I wouldn’t worry about lacking experience like myself, just jump in, read up and take your time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/05/installing-ubuntu-a-trial-and-error-account/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Incrementing Oracle Sequences Without Permissions</title>
		<link>http://blogs.sourceallies.com/2010/04/incrementing-oracle-sequences-without-permissions/</link>
		<comments>http://blogs.sourceallies.com/2010/04/incrementing-oracle-sequences-without-permissions/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 19:06:52 +0000</pubDate>
		<dc:creator>Tim Bierbaum</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1499</guid>
		<description><![CDATA[If you are ever working with a database where data is consistently being imported, dropped, and/or restored; sooner or later you will find yourself in the situation where the primary key of a table is no longer synchronized with the sequence used to generate it.

If you have the appropriate permissions, this is easy to fix. [...]]]></description>
			<content:encoded><![CDATA[<p>If you are ever working with a database where data is consistently being imported, dropped, and/or restored; sooner or later you will find yourself in the situation where the primary key of a table is no longer synchronized with the sequence used to generate it.<br />
<span id="more-1499"></span><br />
If you have the appropriate permissions, this is easy to fix.  Say you need to advance the sequence by 500, you just execute the following sql:</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">ALTER</span> sequence MY_SEQ increment <span style="color: #00F;">BY</span> <span style="color: #800;">500</span><span style="color: #00F;">;</span>
<span style="color: #00F;">SELECT</span> MY_SEQ<span style="color: #00F;">.</span><span style="color: #00F;">NEXTVAL</span> <span style="color: #00F;">FROM</span> dual<span style="color: #00F;">;</span>
<span style="color: #00F;">ALTER</span> sequence MY_SEQ increment <span style="color: #00F;">BY</span> <span style="color: #800;">1</span><span style="color: #00F;">;</span></pre></div></div>

<p>What do you do if you don&#8217;t have the correct permissions to do this?  You can always call up the dba and ask him.  If you&#8217;re impatient, you can also do a little pl/sql programming to accomplish the same thing.  All you want to do is just repeatedly select the next value until the sequence value is higher that the current key value.</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">DECLARE</span>
  current_value <span style="color: #00F;">NUMBER</span><span style="color: #00F;">;</span>
  seq_val <span style="color: #00F;">NUMBER</span><span style="color: #00F;">;</span>
<span style="color: #00F;">BEGIN</span>
  <span style="color: #00F;">SELECT</span> <span style="color: #000;">MAX</span><span style="color: #00F;">&#40;</span>MY_TABLE<span style="color: #00F;">.</span>id<span style="color: #00F;">&#41;</span> <span style="color: #00F;">INTO</span> current_val <span style="color: #00F;">FROM</span> MY_TABLE<span style="color: #00F;">;</span>
  <span style="color: #00F;">WHILE</span> current_val <span style="color: #00F;">&gt;=</span> seq_val
  <span style="color: #00F;">LOOP</span>
    <span style="color: #00F;">SELECT</span> MY_SEQ<span style="color: #00F;">.</span><span style="color: #00F;">NEXTVAL</span> <span style="color: #00F;">INTO</span> seq_val <span style="color: #00F;">FROM</span> dual<span style="color: #00F;">;</span>
  <span style="color: #00F;">END</span> <span style="color: #00F;">LOOP</span><span style="color: #00F;">;</span>
<span style="color: #00F;">END</span><span style="color: #00F;">;</span></pre></div></div>

<p>Of course, if you encounter this situation once, chances are that you will encounter it many times.  Next, you can create a function that takes the table name, key column name, and sequence name and then executes dynamically created sql to fix the problem.</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">CREATE</span> <span style="color: #00F;">OR</span> <span style="color: #000;">REPLACE</span> <span style="color: #00F;">PROCEDURE</span> INCREMENT_SEQ<span style="color: #00F;">&#40;</span><span style="color: #00F;">IN</span> TABLE_NAME<span style="color: #00F;">,</span> <span style="color: #00F;">IN</span> ID_COLUMN_NAME<span style="color: #00F;">,</span> <span style="color: #00F;">IN</span> SEQUENCE_NAME<span style="color: #00F;">&#41;</span> <span style="color: #00F;">IS</span>
<span style="color: #00F;">DECLARE</span>
  current_value <span style="color: #00F;">NUMBER</span><span style="color: #00F;">;</span>
  seq_val <span style="color: #00F;">NUMBER</span> <span style="color: #00F;">:=</span> <span style="color: #00F;">-</span><span style="color: #800;">1</span><span style="color: #00F;">;</span>
<span style="color: #00F;">BEGIN</span>
  <span style="color: #00F;">EXECUTE</span> <span style="color: #00F;">IMMEDIATE</span> <span style="color: #F00;">'select max('</span> <span style="color: #00F;">||</span> TABLE_NAME <span style="color: #00F;">||</span> <span style="color: #F00;">'.'</span> <span style="color: #00F;">||</span> ID_COLUMN_NAME <span style="color: #00F;">||</span> <span style="color: #F00;">') into current value from '</span> <span style="color: #00F;">||</span> TABLE_NAME<span style="color: #00F;">;</span>
  <span style="color: #00F;">WHILE</span> current_val <span style="color: #00F;">&gt;=</span> seq_val
  <span style="color: #00F;">LOOP</span>
    <span style="color: #00F;">EXECUTE</span> <span style="color: #00F;">IMMEDIATE</span> <span style="color: #F00;">'select '</span> <span style="color: #00F;">||</span> SEQUENCE_NAME <span style="color: #00F;">||</span> <span style="color: #F00;">&quot;.nextval into seq_val from dual';
  end loop;
END INCREMENT_SEQ;</span></pre></div></div>

<p>Now, you should be able to fix any sequence/key mismatches simply by calling the procedure.</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;">INCREMENT_SEQ<span style="color: #00F;">&#40;</span><span style="color: #F00;">'MY_TABLE'</span><span style="color: #00F;">,</span> <span style="color: #F00;">'ID'</span><span style="color: #00F;">,</span> <span style="color: #F00;">'MY_SEQ'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/04/incrementing-oracle-sequences-without-permissions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Analytics Data Export API &#8211; Part 1</title>
		<link>http://blogs.sourceallies.com/2010/03/google-analytics-data-export-api-part-1/</link>
		<comments>http://blogs.sourceallies.com/2010/03/google-analytics-data-export-api-part-1/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 13:10:45 +0000</pubDate>
		<dc:creator>Octavian Covalschi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Google API]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1461</guid>
		<description><![CDATA[When Google exposed its Data Export API, it endeared itself closer to developers and to customers of Google Analytics. Data Export API allows us to develop client applications to retrieve data from existing analytics profiles of authorized users.
How does it work?
The Data Export API provides read-only access to all available analytics data. Any data that [...]]]></description>
			<content:encoded><![CDATA[<p>When Google exposed its Data Export API, it endeared itself closer to developers and to customers of Google Analytics. Data Export API allows us to develop client applications to retrieve data from existing analytics profiles of authorized users.</p>
<p><strong>How does it work?</strong><br />
The Data Export API provides read-only access to all available analytics data. Any data that is displayed in the analytics web interface can be accessed through this API. Nice isn&#8217;t it? You can get all your analytics data, for all your monitored websites and use it as you please.</p>
<p><span id="more-1461"></span></p>
<p><strong>Getting started</strong><br />
To get started basically you need very little &#8212; a valid Google Analytics account and a client that would do all the low level work(sending HTTP requests with corresponding headers) or you could write your own small client that fits your needs. For example you could write shell scripts that use cURL under the hood. Anyway, it doesn&#8217;t matter, the important thing here is to find a good way to communicate with the Google Analytics servers.</p>
<p>At this point, Google offers 2 solutions: a Java and a JavaScript client. Both are easy to use, but may not fit your needs. That&#8217;s why there are also other similar clients in different languages like PHP, Perl,  and Ruby.</p>
<p>The entire process of getting Google Analytics data and doing something useful with it can be split into 3 steps:</p>
<ul>
<li>Authorization</li>
<li>Data feed</li>
<li>Parse XML feed and perform your computations.</li>
</ul>
<p>In Part 2 I&#8217;ll describe several ways of authorizations and when you would use each. But before that I&#8217;d like to mention some limitations. Basically Google has several quota policies, which currently are:</p>
<ul>
<li>10,000 requests per 24 hours (this limit applies to a single web resource)</li>
<li>10 requests in any given 1-second period (this limit applies across all queries an application makes to the API)</li>
<li>4 pending requests at any given time. Be advised that this limit is new and is subject to change</li>
<li>A query is also limited to pagination limits of 10,000 entries per feed, with a default response of 1,000 entries</li>
</ul>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/03/google-analytics-data-export-api-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Master/Slave configuration with EJB3 and JPA</title>
		<link>http://blogs.sourceallies.com/2010/03/mysql-masterslave-configuration-with-ejb3-and-jpa/</link>
		<comments>http://blogs.sourceallies.com/2010/03/mysql-masterslave-configuration-with-ejb3-and-jpa/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 18:33:19 +0000</pubDate>
		<dc:creator>Vaithi  Subramanian</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mysql JPA replication]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1398</guid>
		<description><![CDATA[Well this turned out to be quite an exercise.
The goal: scalable reads with MySQL in master-slave configuration, writing to the master, and reading from N slaves, load balanced in round-robin fashion (or something).
The problem: using JPA (Java Persistence API) instead of direct JDBC calls. Turns out the MySQL ReplicationDriver (used to load balance reads to [...]]]></description>
			<content:encoded><![CDATA[<p>Well this turned out to be quite an exercise.</p>
<p>The goal: scalable reads with MySQL in master-slave configuration, writing to the master, and reading from N slaves, load balanced in round-robin fashion (or something).</p>
<p>The problem: using JPA (Java Persistence API) instead of direct JDBC calls. Turns out the MySQL ReplicationDriver (used to load balance reads to slaves and send writes to the master) relies on the readOnly state of the Connection in order to decide whether it&#8217;s a read or a write. With direct JDBC calls, I could get the Connection and toggle the readOnly state as needed.<br />
<span id="more-1398"></span><br />
However, buried under JPA and EntityManager and so on, there&#8217;s no way to do that. So I looked into other solutions (LBPool, for instance), but nothing out there seems to be  intended for JPA environment.</p>
<p>So I had to do it myself&#8230; in digging around in the MySQL Connector/J source, I discovered the loadbalance option, intended for use w/ MySQL Cluster, because in that environment, you don&#8217;t need to distinguish between master and slave, they&#8217;re all just nodes.</p>
<p>The loadbalance option wouldn&#8217;t work directly for me, of course, because I don&#8217;t want to load balance writes, just reads.</p>
<p>Soulution to the problem is to use two data sources, one for reads, and the other for writes, I can stick the read data source behind all my &#8220;fetch stuff&#8221; APIs, and use the write data source for everything else. Then I can use the loadbalance option for the read data source, because I know for certain I&#8217;m never sending it any writes.</p>
<p>I am currently using Jboss 4.2.1 GA here my mysql-ds.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;datasources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;no-tx-datasource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jndi-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MasterA<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jndi-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;connection-url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jdbc:mysql://masterDB/databasename<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/connection-url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;driver-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mysql.jdbc.ReplicationDriver<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/driver-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;user-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>username<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/user-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>password<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;min-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/min-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- Don't set this any higher than max_connections on your</span>
<span style="color: #808080; font-style: italic;">         MySQL server, usually this should be a 10 or a few 10's</span>
<span style="color: #808080; font-style: italic;">         of connections, not hundreds or thousands --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;max-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>50<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/max-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;idle-timeout-minutes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/idle-timeout-minutes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exception-sorter-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exception-sorter-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;valid-connection-checker-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/valid-connection-checker-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mySQL<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/no-tx-datasource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;no-tx-datasource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jndi-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SlaveA<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jndi-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;connection-url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jdbc:mysql://slaveA,slaveB/databasename<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/connection-url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;driver-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mysql.jdbc.ReplicationDriver<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/driver-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;user-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>username<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/user-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>password<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;min-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/min-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- Don't set this any higher than max_connections on your</span>
<span style="color: #808080; font-style: italic;">         MySQL server, usually this should be a 10 or a few 10's</span>
<span style="color: #808080; font-style: italic;">         of connections, not hundreds or thousands --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;max-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>50<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/max-pool-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;idle-timeout-minutes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/idle-timeout-minutes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exception-sorter-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exception-sorter-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;valid-connection-checker-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/valid-connection-checker-class-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mySQL<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/no-tx-datasource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/datasources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Persistence.xml for the JTA datasources.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;persistence</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/persistence&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/persistence persistence_1_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;persistence-unit</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Master&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;provider<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.hibernate.ejb.HibernatePersistence<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/provider<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jta-data-source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		java:/MasterA
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jta-data-source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hibernate.dialect&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;org.hibernate.dialect.MySQL5Dialect&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>			
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hibernate.connection.readOnly&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/persistence-unit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;persistence-unit</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Slave&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;provider<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.hibernate.ejb.HibernatePersistence<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/provider<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jta-data-source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		java:/SlaveA
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jta-data-source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hibernate.dialect&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;org.hibernate.dialect.MySQL5Dialect&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>			
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hibernate.connection.readOnly&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 	
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/persistence-unit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/persistence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>For normal JDBC connections read only state can changed like the following code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    ReplicationDriver driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ReplicationDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">Properties</span> props <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// We want this for failover on the slaves</span>
    props.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;autoReconnect&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// We want to load balance between the slaves</span>
    props.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;roundRobinLoadBalance&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    props.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user&quot;</span>, <span style="color: #0000ff;">&quot;user&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    props.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</span>, <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//</span>
    <span style="color: #666666; font-style: italic;">// Looks like a normal MySQL JDBC url, with a</span>
    <span style="color: #666666; font-style: italic;">// comma-separated list of hosts, the first</span>
    <span style="color: #666666; font-style: italic;">// being the 'master', the rest being any number</span>
    <span style="color: #666666; font-style: italic;">// of slaves that the driver will load balance against</span>
    <span style="color: #666666; font-style: italic;">//</span>
&nbsp;
    <span style="color: #003399;">Connection</span> conn <span style="color: #339933;">=</span>
        driver.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jdbc:mysql:replication://master,slave1,slave2,slave3/databasename&quot;</span>,
            props<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//</span>
    <span style="color: #666666; font-style: italic;">// Perform read/write work on the master</span>
    <span style="color: #666666; font-style: italic;">// by setting the read-only flag to &quot;false&quot;</span>
    <span style="color: #666666; font-style: italic;">//</span>
&nbsp;
    conn.<span style="color: #006633;">setReadOnly</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    conn.<span style="color: #006633;">setAutoCommit</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    conn.<span style="color: #006633;">createStatement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE some_table ....&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    conn.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//</span>
    <span style="color: #666666; font-style: italic;">// Now, do a query from a slave, the driver automatically picks one</span>
    <span style="color: #666666; font-style: italic;">// from the list</span>
    <span style="color: #666666; font-style: italic;">//</span>
&nbsp;
    conn.<span style="color: #006633;">setReadOnly</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">ResultSet</span> rs <span style="color: #339933;">=</span>
      conn.<span style="color: #006633;">createStatement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT a,b FROM alt_table&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     .......
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Conculsion:<br />
Thus with the help of two data sources I am able to replicate the functionality of Master/Slave Read scalability. If you are using the normal JDBC connection then changing the read-only is as simple as the above code. Hope this will be helpful for someone who needs to setup Replication in the code level.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/03/mysql-masterslave-configuration-with-ejb3-and-jpa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loadbalancing and its benefits</title>
		<link>http://blogs.sourceallies.com/2010/03/loadbalancing-and-its-benefits/</link>
		<comments>http://blogs.sourceallies.com/2010/03/loadbalancing-and-its-benefits/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 15:05:25 +0000</pubDate>
		<dc:creator>Ryan  Day</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Anycast]]></category>
		<category><![CDATA[Balancing]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Fail over]]></category>
		<category><![CDATA[Failover]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[IP Address]]></category>
		<category><![CDATA[Load]]></category>
		<category><![CDATA[Load Balancing]]></category>
		<category><![CDATA[Loadbalancing]]></category>
		<category><![CDATA[routing protocol]]></category>
		<category><![CDATA[Servers]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1387</guid>
		<description><![CDATA[What is load balancing?
Load balancing is the practice of distributing a workload across multiple computers for improved performance. Load balancing distributes work among resources in such a way that no one resource should be overloaded and each resource can have improved performance, depending on the load balancing algorithm. Items such as network traffic, SSL requests, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is load balancing?</strong><br />
Load balancing is the practice of distributing a workload across multiple computers for improved performance. Load balancing distributes work among resources in such a way that no one resource should be overloaded and each resource can have improved performance, depending on the load balancing algorithm. Items such as network traffic, SSL requests, database queries, or even hardware resources such as memory can be load balanced. This practice is commonly used in server farms where multiple physical boxes are coordinated to fulfill the requests of many end users.</p>
<p><span id="more-1387"></span></p>
<p><strong>How to accomplish load balancing?</strong><br />
Load balancing can be accomplished through software but is usually achieved with the help of a dedicated hardware appliance due to the speed requirements. A load balancer can use many different algorithms. The most basic method is round-robin, which sends a request to each server in the cluster successively. More sophisticated techniques make decisions based on CPU usage, number of requests queued, average response time or even number of lost packets. One problem with load balancing is that a user&#8217;s session is likely not replicated across the the whole server cluster so typically a single user&#8217;s requests will be &#8220;sticky&#8221; and always be routed to the same backend server.</p>
<p>Another, more global, method of load balancing is Anycast. Anycast is an addressing strategy often used in DNS where hosts in multiple geographical locations represent the same IP address. This balances workload because any request is routed to the closest host (as determined by the routing protocol). In the event of one of the hosts going offline the request is then routed to the next closest available host.  Routing requests to the nearest host has the added benefits of increasing response time and reliability.</p>
<p><strong>Why load balance?</strong><br />
Simply put, work gets done more efficiently when resources are not used to their capacity and as a result user response times are generally better. The best reason, however, is often times failover. Failover refers to the ability of a system to remain operational while one or more components have failed or gone down. Say your clumsy friend trips over a power cord, eliminating one of three nodes in a cluster hosting a website. People opening a new connection to your website will not notice because the load balancer will realize that the one node is not responding and will route all requests to the other two nodes until the first one is responsive again. The only users who might notice would have been sticky to that one node. Failover is also useful for maintenance. If something has to be upgraded across all nodes, then one node can be taken down at a time to be upgraded without any downtime for whatever service the cluster may be hosting.</p>
<p>Load balancing and failover are powerful concepts which allow network administrators to have some peace of mind and users to keep on working.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/03/loadbalancing-and-its-benefits/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Musings of a SpringOne 2009 Attendee – Day 4</title>
		<link>http://blogs.sourceallies.com/2010/03/musings-of-a-springone-2009-attendee-%e2%80%93-day-4/</link>
		<comments>http://blogs.sourceallies.com/2010/03/musings-of-a-springone-2009-attendee-%e2%80%93-day-4/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 16:00:53 +0000</pubDate>
		<dc:creator>Sudhakar Ramasamy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[SpringOne]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=535</guid>
		<description><![CDATA[This is the last and final part on my SpringOne 2009 experience. It&#8217;s late catching up to the 3 earlier posts but it&#8217;s here now. This post summarizes the sessions I attended from day 4 and wraps up with a summary of my take aways. If you want to catch up here are the three [...]]]></description>
			<content:encoded><![CDATA[<p>This is the last and final part on my SpringOne 2009 experience. It&#8217;s late catching up to the 3 earlier posts but it&#8217;s here now. This post summarizes the sessions I attended from day 4 and wraps up with a summary of my take aways. If you want to catch up here are the three earlier posts:</p>
<ol>
<li><a href="http://blogs.sourceallies.com/2009/10/musings-of-a-springone-2009-attendee-day-1">Musings of a SpringOne 2009 Attendee Day 1</a></li>
<li><a href="http://blogs.sourceallies.com/2009/10/musings-of-a-springone-2009-attendee-day-2">Musings of a SpringOne 2009 Attendee Day 2</a></li>
<li><a href="http://blogs.sourceallies.com/2009/10/musings-of-a-springone-2009-attendee-day-3">Musings of a SpringOne 2009 Attendee Day 3</a></li>
</ol>
<p>Read on for day 4.</p>
<p><span id="more-535"></span></p>
<h2><a href="http://www.springone2gx.com/conference/new_orleans/2009/10/session?id=15408">OSGi and Groovy Jump Start</a></h2>
<p>The presentation started with a <a href="http://www.youtube.com/watch?v=eTRM5n3khw8">5 minute youtube video</a> preview which I thought was pretty innovative.</p>
<p>The first half was around what is OSGi, some of which I&#8217;ve had experience with. I did pick up on a few key concepts that I didn&#8217;t know i wasn&#8217;t communicating earlier in my own presentations on OSGi.</p>
<p>We covered how a groovy POGO has groovy types in the public API. So if your groovy bundle has the groovylib in it&#8217;s classpath then it has to export the groovy package. Also when using Groovy in OSGi, if possible use POJOs for your applications type system since POGOs force you to expose couple groovy types in the bundle&#8217;s API.</p>
<p>The examples were done using <a href="http://www.gradle.org/">gradle</a> and this was my first live example of using gradle. This is a key benefit of conferences &#8212; being exposed to technologies you may otherwise not have the time to take a peek at.</p>
<p>I liked how the presenter took the path of not making things look complex but rather simplifying the concepts. He did this with concepts such as the  OSGi bundle lifecycle.</p>
<p>Some of the tools covered in this session were:</p>
<ul>
<li>bnd to create a groovy manifest</li>
<li>osgi bundle for gradle uses bnd</li>
<li>junit4osgi</li>
</ul>
<h2><a href="http://www.springone2gx.com/conference/new_orleans/2009/10/session?id=16462">Expand your business with Groovy &#8211; Case Study</a></h2>
<p>This session was a case study on how a monolithic application was extended to provide customizations using groovy. A major customer had approached  HypericQ wanting a custom dashboard.</p>
<p>HypericQ developed a architecture around attach point&#8217;s which are places within the UI where plugins can connect to.</p>
<p>Custom UI was provided by gsp templates for customer specific dashboards.</p>
<p>Groovy templates was used as the templating framework that allowed clients to build their own using GSP  pages.</p>
<p>A Web Services API was provided as part of the core platform that enabled several benefits:<br />
- hqapi command line interaction<br />
- allows integration testing of the application<br />
- embedding a groovy console inside the application<br />
- console gives you a HQL way to query the domain and not worry about the end customers database environment</p>
<p>The talk was an interesting exercise in how a dynamic plugin architecture could be implemented. <a href="http://docs.codehaus.org/display/GROOVY/Groovy+Categories">Groovy categories</a> was heavily used to enable this.</p>
<h2><a href="http://www.springone2gx.com/conference/new_orleans/2009/10/session?id=15779">Re-factoring a Spring Application for SOA using Spring technologies in 40 min</a></h2>
<p>The current focus of SOA is really software architecture. SOA is neither static nor predictable. The architectural pattern of any application must be reflective of the business. SOA is preparing the stuff that is critical to your business to stand the test of time. </p>
<p>Architecture involves the courage to be wrong while minimizing the impact of being wrong. It is about making educated decisions between speed and perfection. The longer it takes to deliver the software the higher the client&#8217;s expectations of that software is.</p>
<p>The foundation of SOA is highly cohesive, loosely coupled modules. One must practice</p>
<ol>
<li>strategy first programming</li>
<li>process life-cycle dynamics</li>
<li>process collaboration</li>
<li>loose coupling promotes a network based architecture over a hierarchical one &#8211; composition over inheritance</li>
</ol>
<p>SOA and OSGi enable embracing change by making versioning a runtime concept.</p>
<p>There is an argument to be made for deploying a process as a whole in BPEL. But what about flexible orchestration via simple messaging. We were given the American football analogy. Each play is scripted, but between plays we need to adjust strategy to meet the overall goal. </p>
<p>Modern event driven architecture was mentioned as a composite process linked together in a linear fashion through the use of rule based pathing.</p>
<p>The second half of this talk was the Spring booking demo from Spring Web Flow project. There are 3 OSGi bundles:</p>
<ol>
<li>war bundle</li>
<li>service bundle</li>
<li>datasource bundle</li>
</ol>
<p>The demo was using STS and it&#8217;s DM Server tooling. The entire development workflow was very seamless with SpringSource having done an awesome job of the tooling.</p>
<p>We saw an example of a transparent failover. So there is a need to take down the primary database for maintenance work without taking the application down. A backup datasource bundle is started and the primary datasource bundle is stopped. The datasource bundle is a simple datasource definition and an osgi service with ranking. Because of a higher rank the backup datasource bundle takes precendence and the primary datasource bundle can be safely stopped. Bundles can also take advantage of filtering besides ranking. </p>
<p>Spring Integration builds on pipes and filters. You can expose OSGi services as pipes. It provides the ability to change the behavior of a modularized application by changing how the modules are hooked up in the XML as opposed to modifying source code or in cases where the source code is not available.</p>
<h2>Conference Wrap Up</h2>
<p>Here are my key take aways:</p>
<ul>
<li>It is time for Grails</li>
<li>Need to investigate Spring Faces</li>
<li><a href="http://www.owasp.org/index.php/Category:OWASP_WebGoat_Project">Webgoat</a></li>
<li>Spring Web Flow</li>
<li>Spring Integration</li>
<li>Spring DM Server</li>
</ul>
<p>Overall it was a very productive conference and I would recommend it for anyone looking to attend it next year.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/03/musings-of-a-springone-2009-attendee-%e2%80%93-day-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
