本文整理汇总了Java中org.sdnplatform.sync.internal.version.ClockEntry类的典型用法代码示例。如果您正苦于以下问题:Java ClockEntry类的具体用法?Java ClockEntry怎么用?Java ClockEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClockEntry类属于org.sdnplatform.sync.internal.version包,在下文中一共展示了ClockEntry类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTVectorClock
import org.sdnplatform.sync.internal.version.ClockEntry; //导入依赖的package包/类
/**
* Convert a {@link VectorClock} into a
* {@link org.sdnplatform.sync.thrift.VectorClock}
* @param vc the input clock
* @return the output thrift object
*/
public static org.sdnplatform.sync.thrift.VectorClock
getTVectorClock(VectorClock vc) {
org.sdnplatform.sync.thrift.VectorClock tvc =
new org.sdnplatform.sync.thrift.VectorClock();
tvc.setTimestamp(vc.getTimestamp());
for (ClockEntry ce : vc.getEntries()) {
org.sdnplatform.sync.thrift.ClockEntry tce =
new org.sdnplatform.sync.thrift.ClockEntry();
tce.setNodeId(ce.getNodeId());
tce.setVersion(ce.getVersion());
tvc.addToVersions(tce);
}
return tvc;
}
示例2: getTVectorClock
import org.sdnplatform.sync.internal.version.ClockEntry; //导入依赖的package包/类
/**
* Convert a {@link VectorClock} into a
* {@link org.sdnplatform.sync.thrift.VectorClock}
* @param vc the input clock
* @return the output thrift object
*/
public static org.sdnplatform.sync.thrift.VectorClock
getTVectorClock(VectorClock vc) {
org.sdnplatform.sync.thrift.VectorClock tvc =
new org.sdnplatform.sync.thrift.VectorClock();
tvc.setTimestamp(vc.getTimestamp());
for (ClockEntry ce : vc.getEntries()) {
org.sdnplatform.sync.thrift.ClockEntry tce =
new org.sdnplatform.sync.thrift.ClockEntry();
tce.setNodeId(ce.getNodeId());
tce.setVersion(ce.getVersion());
tvc.addToVersions(tce);
}
return tvc;
}
示例3: getVersion
import org.sdnplatform.sync.internal.version.ClockEntry; //导入依赖的package包/类
/**
* Convert a thrift {@link org.sdnplatform.sync.thrift.VectorClock} into
* a {@link VectorClock}.
* @param tvc the {@link org.sdnplatform.sync.thrift.VectorClock}
* @param the {@link VectorClock}
*/
public static VectorClock getVersion(org.sdnplatform.sync.thrift.VectorClock tvc) {
ArrayList<ClockEntry> entries =
new ArrayList<ClockEntry>();
if (tvc.getVersions() != null) {
for (org.sdnplatform.sync.thrift.ClockEntry ce :
tvc.getVersions()) {
entries.add(new ClockEntry(ce.getNodeId(), ce.getVersion()));
}
}
return new VectorClock(entries, tvc.getTimestamp());
}
示例4: testMergeWithLargeVersion
import org.sdnplatform.sync.internal.version.ClockEntry; //导入依赖的package包/类
/**
* See gihub issue #25: Incorrect coersion of version to short before
* passing to ClockEntry constructor
*/
@Test
public void testMergeWithLargeVersion() {
VectorClock clock1 = getClock(1);
VectorClock clock2 = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1,
Short.MAX_VALUE + 1)),
System.currentTimeMillis());
VectorClock mergedClock = clock1.merge(clock2);
assertEquals(mergedClock.getMaxVersion(), Short.MAX_VALUE + 1);
}
示例5: testIncrement
import org.sdnplatform.sync.internal.version.ClockEntry; //导入依赖的package包/类
@Test
public void testIncrement() {
ClockEntry v = new ClockEntry((short) 0, 1);
assertEquals(v.getNodeId(), 0);
assertEquals(v.getVersion(), 1);
ClockEntry v2 = v.incremented();
assertEquals(v.getVersion(), 1);
assertEquals(v2.getVersion(), 2);
}