本文整理汇总了Java中org.sdnplatform.sync.IStoreClient.addStoreListener方法的典型用法代码示例。如果您正苦于以下问题:Java IStoreClient.addStoreListener方法的具体用法?Java IStoreClient.addStoreListener怎么用?Java IStoreClient.addStoreListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sdnplatform.sync.IStoreClient
的用法示例。
在下文中一共展示了IStoreClient.addStoreListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}