本文整理汇总了Java中org.sdnplatform.sync.Versioned.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java Versioned.setValue方法的具体用法?Java Versioned.setValue怎么用?Java Versioned.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sdnplatform.sync.Versioned
的用法示例。
在下文中一共展示了Versioned.setValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import org.sdnplatform.sync.Versioned; //导入方法依赖的package包/类
@Override
public IVersion put(K key, V value) throws SyncException {
List<IVersion> versions = getVersions(key);
Versioned<V> versioned;
if(versions.isEmpty())
versioned = Versioned.value(value, new VectorClock());
else if(versions.size() == 1)
versioned = Versioned.value(value, versions.get(0));
else {
versioned = get(key, null);
if(versioned == null)
versioned = Versioned.value(value, new VectorClock());
else
versioned.setValue(value);
}
return put(key, versioned);
}
示例2: testBasicOneNode
import org.sdnplatform.sync.Versioned; //导入方法依赖的package包/类
@Test
public void testBasicOneNode() throws Exception {
AbstractSyncManager sync = syncManagers[0];
IStoreClient<Key, TBean> testClient =
sync.getStoreClient("global", Key.class, TBean.class);
Key k = new Key("com.bigswitch.bigsync.internal", "test");
TBean tb = new TBean("hello", 42);
TBean tb2 = new TBean("hello", 84);
TBean tb3 = new TBean("hello", 126);
assertNotNull(testClient.get(k));
assertNull(testClient.get(k).getValue());
testClient.put(k, tb);
Versioned<TBean> result = testClient.get(k);
assertEquals(result.getValue(), tb);
result.setValue(tb2);
testClient.put(k, result);
try {
result.setValue(tb3);
testClient.put(k, result);
fail("Should get ObsoleteVersionException");
} catch (ObsoleteVersionException e) {
// happy town
}
result = testClient.get(k);
assertEquals(tb2, result.getValue());
}
示例3: testNotify
import org.sdnplatform.sync.Versioned; //导入方法依赖的package包/类
@Test
public void testNotify() throws Exception {
IStoreClient<String, String> client0 =
syncManagers[0].getStoreClient("local",
String.class, String.class);
IStoreClient<String, String> client2 =
syncManagers[2].getStoreClient("local",
new TypeReference<String>() {},
new TypeReference<String>() {});
TestListener t0 = new TestListener();
TestListener t2 = new TestListener();
client0.addStoreListener(t0);
client2.addStoreListener(t2);
client0.put("test0", "value");
client2.put("test2", "value");
HashSet<Update> c0 = new HashSet<Update>();
c0.add(new Update("test0", UpdateType.LOCAL));
c0.add(new Update("test2", UpdateType.REMOTE));
HashSet<Update> c2 = new HashSet<Update>();
c2.add(new Update("test0", UpdateType.REMOTE));
c2.add(new Update("test2", UpdateType.LOCAL));
waitForNotify(t0, c0, 2000);
waitForNotify(t2, c2, 2000);
assertEquals(2, t0.notified.size());
assertEquals(2, t2.notified.size());
t0.notified.clear();
t2.notified.clear();
Versioned<String> v0 = client0.get("test0");
v0.setValue("newvalue");
client0.put("test0", v0);
Versioned<String> v2 = client0.get("test2");
v2.setValue("newvalue");
client2.put("test2", v2);
waitForNotify(t0, c0, 2000);
waitForNotify(t2, c2, 2000);
assertEquals(2, t0.notified.size());
assertEquals(2, t2.notified.size());
t0.notified.clear();
t2.notified.clear();
client0.delete("test0");
client2.delete("test2");
waitForNotify(t0, c0, 2000);
waitForNotify(t2, c2, 2000);
assertEquals(2, t0.notified.size());
assertEquals(2, t2.notified.size());
}