Madan Jampani

Changed type of term number and sequence number to long.

Change-Id: If90663fa9567988752f8c4af17daeff904865ab7
......@@ -24,14 +24,14 @@ import com.google.common.base.MoreObjects;
public final class MastershipTerm {
private final NodeId master;
private final int termNumber;
private final long termNumber;
private MastershipTerm(NodeId master, int term) {
private MastershipTerm(NodeId master, long term) {
this.master = master;
this.termNumber = term;
}
public static MastershipTerm of(NodeId master, int term) {
public static MastershipTerm of(NodeId master, long term) {
return new MastershipTerm(master, term);
}
......@@ -39,7 +39,7 @@ public final class MastershipTerm {
return master;
}
public int termNumber() {
public long termNumber() {
return termNumber;
}
......
......@@ -19,7 +19,7 @@ import static org.slf4j.LoggerFactory.getLogger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
......@@ -43,7 +43,7 @@ public class DeviceClockManager implements DeviceClockService, DeviceClockProvid
private final Logger log = getLogger(getClass());
// TODO: Implement per device ticker that is reset to 0 at the beginning of a new term.
private final AtomicInteger ticker = new AtomicInteger(0);
private final AtomicLong ticker = new AtomicLong(0);
private ConcurrentMap<DeviceId, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>();
@Activate
......
......@@ -34,8 +34,8 @@ import com.google.common.collect.ComparisonChain;
*/
public final class MastershipBasedTimestamp implements Timestamp {
private final int termNumber;
private final int sequenceNumber;
private final long termNumber;
private final long sequenceNumber;
/**
* Default version tuple.
......@@ -43,7 +43,7 @@ public final class MastershipBasedTimestamp implements Timestamp {
* @param termNumber the mastership termNumber
* @param sequenceNumber the sequenceNumber number within the termNumber
*/
public MastershipBasedTimestamp(int termNumber, int sequenceNumber) {
public MastershipBasedTimestamp(long termNumber, long sequenceNumber) {
this.termNumber = termNumber;
this.sequenceNumber = sequenceNumber;
}
......@@ -91,7 +91,7 @@ public final class MastershipBasedTimestamp implements Timestamp {
*
* @return termNumber
*/
public int termNumber() {
public long termNumber() {
return termNumber;
}
......@@ -100,7 +100,7 @@ public final class MastershipBasedTimestamp implements Timestamp {
*
* @return sequenceNumber
*/
public int sequenceNumber() {
public long sequenceNumber() {
return sequenceNumber;
}
......
......@@ -38,14 +38,14 @@ public class MastershipBasedTimestampSerializer extends Serializer<MastershipBas
@Override
public void write(Kryo kryo, Output output, MastershipBasedTimestamp object) {
output.writeInt(object.termNumber());
output.writeInt(object.sequenceNumber());
output.writeLong(object.termNumber());
output.writeLong(object.sequenceNumber());
}
@Override
public MastershipBasedTimestamp read(Kryo kryo, Input input, Class<MastershipBasedTimestamp> type) {
final int term = input.readInt();
final int sequence = input.readInt();
final long term = input.readLong();
final long sequence = input.readLong();
return new MastershipBasedTimestamp(term, sequence);
}
}
......
......@@ -39,13 +39,13 @@ public class MastershipTermSerializer extends Serializer<MastershipTerm> {
@Override
public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) {
final NodeId node = (NodeId) kryo.readClassAndObject(input);
final int term = input.readInt();
final long term = input.readLong();
return MastershipTerm.of(node, term);
}
@Override
public void write(Kryo kryo, Output output, MastershipTerm object) {
kryo.writeClassAndObject(output, object.master());
output.writeInt(object.termNumber());
output.writeLong(object.termNumber());
}
}
......