Skip to content

Commit

Permalink
vector clock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjiewu committed May 8, 2013
1 parent f31e48f commit 8fd7ea6
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 103 deletions.
17 changes: 17 additions & 0 deletions src/java/voldemort/versioning/ClockEntry.java
Expand Up @@ -28,6 +28,7 @@
*
*/
@NotThreadsafe
@Deprecated
public final class ClockEntry implements Cloneable, Serializable {

private static final long serialVersionUID = 1;
Expand Down Expand Up @@ -108,11 +109,27 @@ public String toString() {
}

public void setNodeId(short nodeId) {
if(nodeId < 0)
throw new IllegalArgumentException("Node id " + nodeId + " is not in the range (0, "
+ Short.MAX_VALUE + ").");
this.nodeId = nodeId;
}

public void setVersion(long version) {
if(version < 1)
throw new IllegalArgumentException("Version " + version + " is not in the range (1, "
+ Short.MAX_VALUE + ").");
this.version = version;
}

public void validate() {
if(nodeId < 0)
throw new InvalidClockEntryException("Node id " + nodeId + " is not in the range (0, "
+ Short.MAX_VALUE + ").");
if(version < 1)
throw new InvalidClockEntryException("Version " + version + " is not in the range (1, "
+ Short.MAX_VALUE + ").");

}

}
24 changes: 24 additions & 0 deletions src/java/voldemort/versioning/InvalidClockEntryException.java
@@ -0,0 +1,24 @@
package voldemort.versioning;

import voldemort.VoldemortException;

public class InvalidClockEntryException extends VoldemortException {

private static final long serialVersionUID = 1L;

public InvalidClockEntryException() {
super();
}

public InvalidClockEntryException(String s, Throwable t) {
super(s, t);
}

public InvalidClockEntryException(String s) {
super(s);
}

public InvalidClockEntryException(Throwable t) {
super(t);
}
}

0 comments on commit 8fd7ea6

Please sign in to comment.