本文整理汇总了Java中org.sdnplatform.sync.internal.TUtils.getClock方法的典型用法代码示例。如果您正苦于以下问题:Java TUtils.getClock方法的具体用法?Java TUtils.getClock怎么用?Java TUtils.getClock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sdnplatform.sync.internal.TUtils
的用法示例。
在下文中一共展示了TUtils.getClock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPruneOnWrite
import org.sdnplatform.sync.internal.TUtils; //导入方法依赖的package包/类
@Test
public void testPruneOnWrite() throws SyncException {
IStorageEngine<ByteArray, byte[]> engine = getStorageEngine();
Versioned<byte[]> v1 = new Versioned<byte[]>(new byte[] { 1 }, TUtils.getClock(1));
Versioned<byte[]> v2 = new Versioned<byte[]>(new byte[] { 2 }, TUtils.getClock(2));
Versioned<byte[]> v3 = new Versioned<byte[]>(new byte[] { 3 }, TUtils.getClock(1, 2));
ByteArray key = new ByteArray((byte) 3);
engine.put(key, v1);
engine.put(key, v2);
assertEquals(2, engine.get(key).size());
engine.put(key, v3);
assertEquals(1, engine.get(key).size());
}
示例2: getVersioned
import org.sdnplatform.sync.internal.TUtils; //导入方法依赖的package包/类
private Versioned<String> getVersioned(int... nodes) {
return new Versioned<String>("my-value", TUtils.getClock(nodes));
}
示例3: testCleanupTask
import org.sdnplatform.sync.internal.TUtils; //导入方法依赖的package包/类
@Test
public void testCleanupTask() throws Exception {
IStorageEngine<ByteArray, byte[]> engine = getStorageEngine();
engine.setTombstoneInterval(500);
Versioned<byte[]> v1_1 = new Versioned<byte[]>(new byte[] { 1 }, TUtils.getClock(1));
Versioned<byte[]> v1_2 = new Versioned<byte[]>(null, TUtils.getClock(1, 1));
// add, update, delete
Versioned<byte[]> v2_1 = new Versioned<byte[]>(new byte[] { 1 }, TUtils.getClock(1));
Versioned<byte[]> v2_2 = new Versioned<byte[]>(new byte[] { 2 }, TUtils.getClock(1, 2));
Versioned<byte[]> v2_3 = new Versioned<byte[]>(null, TUtils.getClock(1, 2, 1));
// delete then add again
Versioned<byte[]> v3_1 = new Versioned<byte[]>(new byte[] { 1 }, TUtils.getClock(1));
Versioned<byte[]> v3_2 = new Versioned<byte[]>(null, TUtils.getClock(1, 2));
Versioned<byte[]> v3_3 = new Versioned<byte[]>(new byte[] { 2 }, TUtils.getClock(1, 2, 1));
// delete concurrent to update
Versioned<byte[]> v4_1 = new Versioned<byte[]>(new byte[] { 1 }, TUtils.getClock(1));
Versioned<byte[]> v4_2 = new Versioned<byte[]>(new byte[] { 2 }, TUtils.getClock(1, 2));
Versioned<byte[]> v4_3 = new Versioned<byte[]>(null, TUtils.getClock(1, 1));
ByteArray key1 = new ByteArray((byte) 3);
ByteArray key2 = new ByteArray((byte) 4);
ByteArray key3 = new ByteArray((byte) 5);
ByteArray key4 = new ByteArray((byte) 6);
engine.put(key1, v1_1);
assertEquals(1, engine.get(key1).size());
engine.put(key1, v1_2);
List<Versioned<byte[]>> r = engine.get(key1);
assertEquals(1, r.size());
assertNull(r.get(0).getValue());
engine.put(key2, v2_1);
engine.put(key2, v2_2);
engine.put(key2, v2_3);
engine.put(key3, v3_1);
engine.put(key3, v3_2);
engine.put(key4, v4_1);
engine.put(key4, v4_2);
engine.put(key4, v4_3);
engine.cleanupTask();
r = engine.get(key1);
assertEquals(1, r.size());
assertNull(r.get(0).getValue());
engine.put(key3, v3_3);
Thread.sleep(501);
engine.cleanupTask();
r = engine.get(key1);
assertEquals(0, r.size());
r = engine.get(key2);
assertEquals(0, r.size());
r = engine.get(key3);
assertEquals(1, r.size());
r = engine.get(key4);
assertEquals(2, r.size());
}