forked from voldemort/voldemort
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to do Versioned puts. Added another test case for t…
…he same
- Loading branch information
Chinmay Soman
committed
Apr 26, 2013
1 parent
06c4b3e
commit 4f097fe
Showing
8 changed files
with
205 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package voldemort.coordinator; | ||
|
||
import org.codehaus.jackson.map.ObjectMapper; | ||
|
||
import voldemort.versioning.VectorClock; | ||
|
||
public class CoordinatorUtils { | ||
|
||
/** | ||
* Function to serialize the given Vector clock into a string. If something | ||
* goes wrong, it returns an empty string. | ||
* | ||
* @param vc The Vector clock to serialize | ||
* @return The string (JSON) version of the specified Vector clock | ||
*/ | ||
public static String getSerializedVectorClock(VectorClock vc) { | ||
VectorClockWrapper vcWrapper = new VectorClockWrapper(vc); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
String serializedVC = ""; | ||
try { | ||
serializedVC = mapper.writeValueAsString(vcWrapper); | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return serializedVC; | ||
} | ||
|
||
public static VectorClock deserializeVectorClock(String serializedVC) { | ||
VectorClock vc = null; | ||
|
||
if(serializedVC == null) { | ||
return null; | ||
} | ||
|
||
ObjectMapper mapper = new ObjectMapper(); | ||
|
||
try { | ||
VectorClockWrapper vcWrapper = mapper.readValue(serializedVC, VectorClockWrapper.class); | ||
vc = new VectorClock(vcWrapper.getVersions(), vcWrapper.getTimestamp()); | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return vc; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.