Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9866681
groupmembership changes
Nov 3, 2013
4914c96
hash changes
Nov 3, 2013
dfb6d33
hash changes
Nov 3, 2013
d9247db
Adding BoltDBClient
adarshms Nov 3, 2013
7c59dbc
BoldDBClient and boltdb.prop
adarshms Nov 3, 2013
a8177c3
rmi stuff
Nov 3, 2013
3b7cfb4
rmi stuff
Nov 3, 2013
70834e9
readme
Nov 3, 2013
9ac31f6
merging
Nov 3, 2013
0560b30
Server request forwarding
adarshms Nov 4, 2013
5d2e91e
pom changes
Nov 4, 2013
469437a
Merge branch 'boltdb-mp3' of https://github.com/adarshms/boltdb into …
Nov 4, 2013
d828dda
BoltDBServer Show functionality
adarshms Nov 4, 2013
919c2c0
Merge branch 'boltdb-mp3' of https://github.com/adarshms/boltdb into …
adarshms Nov 4, 2013
2927a2b
finding successor node
Nov 4, 2013
cbfce48
Merge branch 'boltdb-mp3' of https://github.com/adarshms/boltdb into …
adarshms Nov 4, 2013
265c854
finding successor node
Nov 4, 2013
5873a76
A lot of changes
adarshms Nov 4, 2013
323c964
A lot of changes
adarshms Nov 4, 2013
da3187d
moving keys
Nov 4, 2013
65824d3
move keys for join,leave
Nov 4, 2013
f377e6d
changes
adarshms Nov 4, 2013
99a8e6d
changes
adarshms Nov 4, 2013
3d65b09
move keys during leave fixed
Nov 5, 2013
d167af5
Fixed all operations
adarshms Nov 9, 2013
dd55a6e
Update BoltDBProtocol.java
ashwinshankar77 Nov 10, 2013
d2d43b2
added comments
ashwinshankar77 Nov 10, 2013
d941daa
Comments
adarshms Nov 10, 2013
56fed1a
nits
Nov 25, 2013
904d0c6
nits
Nov 25, 2013
cc862e9
heartbeat turned on
Nov 29, 2013
5d88b05
something
adarshms Nov 29, 2013
dc2a0df
something
adarshms Nov 29, 2013
012c70f
in the middle-not stable
Nov 30, 2013
8b37cd2
something
adarshms Nov 30, 2013
9530b9b
something
adarshms Nov 30, 2013
d8a61a5
something
adarshms Nov 30, 2013
0e7f594
in the middle-not stable
Nov 30, 2013
38dbac5
in the middle-not stable
Nov 30, 2013
29720f5
something
adarshms Nov 30, 2013
fc54f8e
Merge branch 'boltdb-final' of https://github.com/adarshms/boltdb int…
adarshms Nov 30, 2013
0039e49
something
adarshms Nov 30, 2013
a66164a
something
adarshms Nov 30, 2013
5d2463a
join changes
Dec 1, 2013
4fec6d2
join changes
Dec 1, 2013
2377f73
something
adarshms Dec 2, 2013
42d7e2c
join replication
adarshms Dec 2, 2013
221d397
commenting handle crash
Dec 3, 2013
3ae490a
Merge branch 'boltdb-final' of https://github.com/adarshms/boltdb int…
Dec 3, 2013
cc56c18
crash working
Dec 4, 2013
722df1e
Movie search client
adarshms Dec 6, 2013
9aa4a36
application
adarshms Dec 8, 2013
10e5658
cool application
adarshms Dec 8, 2013
8c617ce
indexer
adarshms Dec 8, 2013
d106229
consistency levels
Dec 8, 2013
23652bf
merge
Dec 8, 2013
9db4713
nits
Dec 8, 2013
5589e91
performance
adarshms Dec 8, 2013
98e3553
most recent read/write
Dec 8, 2013
ee95578
code cleanup and comments
Dec 9, 2013
44b0912
deleted
adarshms Dec 9, 2013
d8e6571
Merge branch 'boltdb-final' of https://github.com/adarshms/boltdb int…
adarshms Dec 9, 2013
78c5d21
changes
adarshms Dec 9, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Steps to run the membership service -
-----------------------------------------------------------------------------------------------------------------
Steps to run the BoltDB KeyValue Store Server -
-----------------------------------------------------------------------------------------------------------------

1) Copy the boltdb-0.0.1-SNAPSHOT.jar, gson-1.7.1.jar, log4j-1.2.17.jar, dgroupmembership and boltdb.prop
files into a folder.
1) Copy the boltdb-0.0.1-SNAPSHOT.jar, gson-1.7.1.jar, log4j-1.2.17.jar, commons-collections-3.0.jar, boltdb-server, server.policy
BoltDBServer_Stub.class and boltdb.prop files into a folder.
2) cd into the folder to which you copied the above files.
3) Open the boltdb.prop file in a text editor and set the properties
3) Open the server.policy file and change the path in the policy file to the path of the current folder( where
the jar resides)
4) Open the boltdb.prop file in a text editor and set the properties
* "groupmembership.contact" - This is the hostname/ipaddress of the contact machine.
* "groupmembership.tfail" - The time out for marking a process as failed
* "groupmembership.heartbeat.freq" - The frequency at which the local heartbeat should be
Expand All @@ -12,18 +16,50 @@ Steps to run the membership service -
membership list should be refreshed (mark failures and remove marked entries).
* "groupmembership.gossip.freq" - The gossip frequency.
* "groupmembership.lossrate" - The message loss rate to be simulated.
* "groupmembership.rfactor" - The replication factor

4) Run the command - "./dgroupmembership -contact true -id machine.1
5) Run the command - "./boltdb-server -contact true -id machine.1
* "-contact" option is for specifying whether or not this daemon is the contact machine
daemon.(In this case, it is "true". For the other daemons, specify "-contact" as "false")
* "-id" is a unique id for the daemon and this unique id will be used to name the log file
on this machine.
5) While running the service, if you wish to voluntarily leave the system, type "leave" and hit enter. If you
want to crash the process, press Ctrl+C.
6) On the boltdb-server> prompt -
* If you wish to voluntarily leave the system, type "leave" and hit enter.
* If you wish to print out the membership list type "shownodes" and hit enter
* If you wish to print out the contents of the key value store type "showKV" and hit enter.
* If you wish to print out 10 most recent reads and writes, type "show" and hit enter
-----------------------------------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------------------------------
Steps to run the BoltDB KeyValue Store Client -
-----------------------------------------------------------------------------------------------------------------

1) Copy the boltdb-0.0.1-SNAPSHOT.jar, gson-1.7.1.jar, log4j-1.2.17.jar, commons-collections-3.0.jar, boltdb-server, server.policy
BoltDBServer_Stub.class and boltdb.prop files into a folder.
2) cd into the folder to which you copied the above files.
3) Open the client.policy file and change the path in the policy file to the path of the current folder( where
the jar resides)
4) Open the boltdb.prop file in a text editor and set the properties
* "boltdb.kvstore.server" - This is the hostname/ipaddress of the server to which the client talks.
* "boltdb.kvstore.clevel" - This is the consistency level. Possible values - ONE, QUORUM, ALL
5) Run the command - "./boltdb-client
6) On the boltdb-client> prompt -
* "insert <clevel> <key> <value>" - Inserts the key and value onto the Distributed Key Value Store with the given consistency level
* "update <clevel> <key> <value>" - Updates the key and value onto the Distributed Key Value Store with the given consistency level
* "lookup <clevel> <key>" - Looks Up the key in the Distributed Key Value Store with the given consistency level
* "delete <clevel> <key>" - Deletes the key from the Distributed Key Value Store with the given consistency level
-----------------------------------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------------------------------
Steps to run the Log Querier service -
-----------------------------------------------------------------------------------------------------------------

Start the LogQuerier server -

1) Copy the boltdb-0.0.1-SNAPSHOT.jar, dgrep and boltdb.prop files into a folder. (If you have already
copied these files in the previous step - while running the GroupMembership daemon, you should be fine)
2) cd into the folder to which you copied the above files.
Expand All @@ -34,6 +70,7 @@ Start the LogQuerier server -


Query logs using the LogQuerier client -

1) Copy the boltdb-0.0.1-SNAPSHOT.jar, dgrep and boltdb.prop files into a folder (If you have already
copied these files in the previous step - while running the GroupMembership daemon, you should be fine)
2) cd into the folder to which you copied the above files.
Expand All @@ -44,3 +81,4 @@ Query logs using the LogQuerier client -
* To look for joins, type the command "./dgrep -key JOINED"
* To look for crashes, type the command "./dgrep -key CRASHED"
* To look for leavs, type the command "./dgrep -key LEFT"
-----------------------------------------------------------------------------------------------------------------
12 changes: 6 additions & 6 deletions boltdb/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Expand Down
8 changes: 8 additions & 0 deletions boltdb/boltdb.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
machines.address=192.17.11.8:6789,192.17.11.7:6789,192.17.11.18:6789,192.17.11.19:6789
groupmembership.lossrate=0
groupmembership.contact=siebl-0218-07.ews.illinois.edu
groupmembership.tfail=3
groupmembership.heartbeat.freq=600
groupmembership.refreshMembershipList.freq=1000
groupmembership.gossip.freq=1000
boltdb.server=172.16.149.48
24 changes: 23 additions & 1 deletion boltdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,24 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rmic-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>rmic-process-classes</id>
<goals>
<goal>rmic</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -45,6 +62,11 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</project>
223 changes: 223 additions & 0 deletions boltdb/src/main/java/edu/uiuc/boltdb/BoltDBClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
package edu.uiuc.boltdb;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.Properties;
import java.util.StringTokenizer;

/**
* This class represents the client component of the distributed key value store. On start up it creates
* a boltdb-client> shell where the user can type in the insert, update, lookup and delete queries.
* The BoltDBClient class creates a reference to a remote BoltDBServer object in the member variable boltDBServer.
* All the operations (insert, lookup, update and delete) are performed on this remote object reference.
*
* @author Adarsh
*
*/

public class BoltDBClient {

private BoltDBProtocol boltDBServer = null;

public BoltDBClient(String rmiString) throws MalformedURLException, RemoteException, NotBoundException {
if(System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
boltDBServer = (BoltDBProtocol) Naming.lookup("rmi://" + rmiString + "/KVStore");
}

/**
* @param args
* @throws IOException
* @throws NotBoundException
*/
public static void main(String[] args) {
try {
Properties prop = new Properties();
FileInputStream fis = new FileInputStream("./boltdb.prop");
prop.load(fis);
fis.close();
String rmiString = prop.getProperty("boltdb.kvstore.server");
BoltDBClient boltDBClient = new BoltDBClient(rmiString);
boltDBClient.runClientShell();
} catch(Exception e) {
e.printStackTrace();
}
}

// Method to simulate a boltdb-client shell
private void runClientShell() throws IOException {
// Simulate a unix shell
String commandString = "";
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));

// Break out with Ctrl+C
while (true) {
// Read user's input
System.out.print("boltdb-client>");
commandString = console.readLine();

// If the user entered a return, just loop again
if (commandString.equals(""))
continue;
handleCommand(commandString);
}
}

private BoltDBProtocol.CONSISTENCY_LEVEL getConsistency(String clevel) {
if(clevel.equals("ONE")) return BoltDBProtocol.CONSISTENCY_LEVEL.ONE;
else if (clevel.equals("QUORUM")) return BoltDBProtocol.CONSISTENCY_LEVEL.QUORUM;
else if (clevel.equals("ALL")) return BoltDBProtocol.CONSISTENCY_LEVEL.ALL;

return null;
}
// This method handles the commands entered by the user in the boltdb-client shell
private void handleCommand(String commandString) {
try {
StringTokenizer stk = new StringTokenizer(commandString);
if(stk.countTokens() < 3) {
printUsage(0);
return;
}

// The Command Type
String commandType = stk.nextToken();

if(commandType.equals("insert")) {
String clevel = stk.nextToken();
if (!clevel.equals("ONE") && !clevel.equals("QUORUM") && !clevel.equals("ALL")) {
printUsage(1);
return;
}
BoltDBProtocol.CONSISTENCY_LEVEL consistencyLevel = getConsistency(clevel);

String keyStr = stk.nextToken();
long key = parseKey(keyStr);
if(key == -1) return;
String value = "";
if(stk.hasMoreTokens()) {
while(stk.hasMoreTokens())
value += stk.nextToken() + " ";
}
else {
printUsage(1);
return;
}
value = value.trim();
// Perform Insert Operation on the remote server object
if(!boltDBServer.insert(key, new ValueTimeStamp(value, 0), true,consistencyLevel))
System.out.println("Key already present");
} else if(commandType.equals("update")) {
String clevel = stk.nextToken();
if (!clevel.equals("ONE") && !clevel.equals("QUORUM") && !clevel.equals("ALL")) {
printUsage(2);
return;
}
BoltDBProtocol.CONSISTENCY_LEVEL consistencyLevel = getConsistency(clevel);

String keyStr = stk.nextToken();
long key = parseKey(keyStr);
if(key == -1) return;
String value = "";
if(stk.hasMoreTokens()) {
while(stk.hasMoreTokens())
value += stk.nextToken() + " ";
}
else {
printUsage(2);
return;
}
value = value.trim();
// Perform Update Operation on the remote server object
if(!boltDBServer.update(key, new ValueTimeStamp(value, 0), true, consistencyLevel))
System.out.println("Key not present");
} else if(commandType.equals("lookup")) {
String clevel = stk.nextToken();
if (!clevel.equals("ONE") && !clevel.equals("QUORUM") && !clevel.equals("ALL")) {
printUsage(3);
return;
}
BoltDBProtocol.CONSISTENCY_LEVEL consistencyLevel = getConsistency(clevel);

String keyStr = stk.nextToken();
long key = parseKey(keyStr);
if(key == -1) return;
// Perform LookUp Operation on the remote server object
ValueTimeStamp value = boltDBServer.lookup(key, true, consistencyLevel);
if(value == null) {
System.out.println("Key not present");
return;
}
System.out.println("Look Up Result : " + value.value);
} else if(commandType.equals("delete")) {
String clevel = stk.nextToken();
if (!clevel.equals("ONE") && !clevel.equals("QUORUM") && !clevel.equals("ALL")) {
printUsage(4);
return;
}
BoltDBProtocol.CONSISTENCY_LEVEL consistencyLevel = getConsistency(clevel);
String keyStr = stk.nextToken();
long key = parseKey(keyStr);
if(key == -1) return;
// Perform Delete Operation on the remote server object
if(boltDBServer.delete(key, true, consistencyLevel))
System.out.println("Key Value Pair Deleted");
else
System.out.println("Delete Failed");
} else {
printUsage(0);
return;
}
} catch(RemoteException re) {
if(re.getCause().getCause() != null)
System.out.println(re.getCause().getCause().getMessage());
else
System.out.println(re.getCause().getMessage());
}
}

// Method to parse the key entered by the user to long, and to validate the key
private long parseKey(String keyStr) {
long key;
try {
key = Long.parseLong(keyStr);
if(key < 0L || key > 1000000L) {
System.out.println("Invalid Key Range. Key should be in the Range 0 - 1000000");
return -1L;
}
return key;
} catch(NumberFormatException nfe) {
System.out.println("Invalid Key : Please enter an Integer value for key");
return -1L;
}
}

// Method to print the usage of BoltDBClient
private void printUsage(int type) {
System.out.println("Invalid Command");
System.out.println("Usage : ");
switch(type) {
case 1: System.out.println("insert <clevel> <key> <value>");
break;
case 2: System.out.println("update <clevel> <key> <value>");
break;
case 3: System.out.println("lookukp <clevel> <key>");
break;
case 4: System.out.println("delete <clevel> <key>");
break;
default:System.out.println("insert <clevel> <key> <value>");
System.out.println("update <clevel> <key> <value>");
System.out.println("lookup <clevel> <key>");
System.out.println("delete <clevel> <key>");
break;
}
System.out.println("<key> is an integer value in the range 0 - 1000000");
System.out.println();
}
}
Loading