本文整理汇总了Java中org.sdnplatform.sync.IStoreClient.get方法的典型用法代码示例。如果您正苦于以下问题:Java IStoreClient.get方法的具体用法?Java IStoreClient.get怎么用?Java IStoreClient.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sdnplatform.sync.IStoreClient
的用法示例。
在下文中一共展示了IStoreClient.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasicOneNode
import org.sdnplatform.sync.IStoreClient; //导入方法依赖的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());
}
示例2: waitForValue
import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
protected static <K, V> Versioned<V> waitForValue(IStoreClient<K, V> client,
K key, V value,
int maxTime,
String clientName)
throws Exception {
Versioned<V> v = null;
long then = System.currentTimeMillis();
while (true) {
v = client.get(key);
if (value != null) {
if (v.getValue() != null && v.getValue().equals(value)) break;
} else {
if (v.getValue() != null) break;
}
if (v.getValue() != null)
logger.info("{}: Value for key {} not yet right: " +
"expected: {}; actual: {}",
new Object[]{clientName, key, value, v.getValue()});
else
logger.info("{}: Value for key {} is null: expected {}",
new Object[]{clientName, key, value});
Thread.sleep(100);
assertTrue(then + maxTime > System.currentTimeMillis());
}
return v;
}
示例3: testNotify
import org.sdnplatform.sync.IStoreClient; //导入方法依赖的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());
}