<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Clustering"]]></title>
		<link>http://forum.space4j.org/posts/list/2.page</link>
		<description><![CDATA[Latest messages posted in the topic "Clustering"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Clustering</title>
				<description><![CDATA[ Clustering can be useful for load-balance and fault-tolerance. It also allows a snapshot to be taken without placing the whole system in read-only mode. That's because you can use a slave to take snapshot while the rest of the nodes continue to run like nothing as happened, in other words, only the slave taking the snapshot needs to enter read-only mode.<br /> <br /> To create a Space4J cluster is very easy and simple. Refer to the [url="http://www.space4j.org/phonebookcluster.jsp"]PhoneBookCluster.java[/url] program for an example. We also have a [url="http://s4j.mentaframework.org/posts/list/4.page"]stress program[/url] to test the cluster feature.<br /> <br /> The source code for PhoneBookCluster.java is below:<br /> [code]<br /> package org.space4j.examples.phonebook;<br /> <br /> <br /> import org.space4j.Space4J;<br /> import org.space4j.implementation.MasterSpace4J;<br /> import org.space4j.implementation.SlaveSpace4J;<br /> <br /> <br /> /**<br />  * This is to show you how simple it is to make a Space4J cluster!<br />  * <br />  * To make a cluster, open up two shells (or DOS) and execute in the first:<br />  * <br />  * java org.space4j.demos.phonebook.PhoneBookCluster master<br />  * <br />  * and in the second:<br />  * <br />  * java org.space4j.demos.PhoneBookCluster slave 127.0.0.1<br />  * <br />  * You can also use two different machines. Just pass the master IP address to the slave instead of 127.0.0.1.<br />  * IMPORTANT: If you use two different machines, you must have the main Space4J dir (space4j_db) mounted, so <br />  * both machines can have access to it.<br />  */<br /> public class PhoneBookCluster extends PhoneBookIndexing {<br />     <br />     public PhoneBookCluster(Space4J space4j) throws Exception {<br />     	<br />         super(space4j);<br />     	<br />     }<br />     <br />     static Space4J createSpace4J(String master, String master_ip) throws Exception {<br />     	<br />         Space4J space4j = null;<br />     	<br />         if (master.equals("-master")) {<br />         	<br />             space4j = new MasterSpace4J("PhoneBook");<br />         	<br />         } else if (master.equals("-slave")) {<br />         	<br />             if (master_ip != null) {<br />             	<br />                 space4j = new SlaveSpace4J("PhoneBook", master_ip);<br />             	<br />             } else {<br />             	<br />                 space4j = new SlaveSpace4J("PhoneBook", "127.0.0.1");<br />             	<br />             }<br />         }<br />         <br />         return space4j;<br />     }<br />     <br />     public static void main(String[] args) throws Exception {<br />     	<br />         if (args.length &lt; 1 || args.length &gt; 2) {<br />     		<br />             System.out.println(<br />                     "format: java PhoneBookCluster [-master|-slave] &lt;IP def: 127.0.0.1&gt;");<br />     		<br />             return;<br />         }<br />     	<br />         Space4J space4j = createSpace4J(args[0],<br />                 args.length &gt; 1 ? args[1] : null);<br />     	<br />         PhoneBookCluster book = new PhoneBookCluster(space4j);<br />         <br />         run(book);<br />     }<br /> }<br /> [/code]<br /> <br /> <br /> <br /> ]]></description>
				<guid isPermaLink="true">http://forum.space4j.org/posts/preList/6/6.page</guid>
				<link>http://forum.space4j.org/posts/preList/6/6.page</link>
				<pubDate><![CDATA[Fri, 5 Sep 2008 16:24:35]]> GMT</pubDate>
				<author><![CDATA[ saoj]]></author>
			</item>
	</channel>
</rss>
