本文整理汇总了Java中org.sdnplatform.sync.error.ObsoleteVersionException类的典型用法代码示例。如果您正苦于以下问题:Java ObsoleteVersionException类的具体用法?Java ObsoleteVersionException怎么用?Java ObsoleteVersionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObsoleteVersionException类属于org.sdnplatform.sync.error包,在下文中一共展示了ObsoleteVersionException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSeeds
import org.sdnplatform.sync.error.ObsoleteVersionException; //导入依赖的package包/类
private void updateSeeds(ClusterConfig config) throws SyncException {
List<String> hosts = new ArrayList<String>();
for (Node n : config.getNodes()) {
if (!config.getNode().equals(n)) {
HostAndPort h =
HostAndPort.fromParts(n.getHostname(), n.getPort());
hosts.add(h.toString());
}
}
Collections.sort(hosts);
String seeds = Joiner.on(',').join(hosts);
while (true) {
try {
Versioned<String> sv = unsyncStoreClient.get(SEEDS);
if (sv.getValue() == null || !sv.getValue().equals(seeds)) {
if (logger.isDebugEnabled()) {
logger.debug("[{}] Updating seeds to \"{}\" from \"{}\"",
new Object[]{config.getNode().getNodeId(),
seeds, sv.getValue()});
}
unsyncStoreClient.put(SEEDS, seeds);
}
break;
} catch (ObsoleteVersionException e) { }
}
}
示例2: updateSeeds
import org.sdnplatform.sync.error.ObsoleteVersionException; //导入依赖的package包/类
private void updateSeeds(ClusterConfig config) throws SyncException {
List<String> hosts = new ArrayList<String>();
for (Node n : config.getNodes()) {
if (!config.getNode().equals(n)) {
HostAndPort h =
HostAndPort.fromParts(n.getHostname(), n.getPort());
hosts.add(h.toString());
}
}
Collections.sort(hosts);
String seeds = Joiner.on(',').join(hosts);
while (true) {
try {
Versioned<String> sv = unsyncStoreClient.get(SEEDS);
if (sv.getValue() == null || !sv.getValue().equals(seeds)) {
if (logger.isDebugEnabled()) {
logger.debug("[{}] Updating seeds to \"{}\" from \"{}\"",
new Object[]{config.getNode().getNodeId(),
seeds, sv.getValue()});
}
unsyncStoreClient.put(SEEDS, seeds);
}
break;
} catch (ObsoleteVersionException e) { }
}
}
示例3: putIfNotObsolete
import org.sdnplatform.sync.error.ObsoleteVersionException; //导入依赖的package包/类
@Override
public boolean putIfNotObsolete(K key, Versioned<V> versioned)
throws SyncException {
try {
put(key, versioned);
return true;
} catch (ObsoleteVersionException e) {
return false;
}
}
示例4: testBasicOneNode
import org.sdnplatform.sync.error.ObsoleteVersionException; //导入依赖的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());
}
示例5: testObsoletePutFails
import org.sdnplatform.sync.error.ObsoleteVersionException; //导入依赖的package包/类
private void testObsoletePutFails(String message,
IStore<K, V> store,
K key,
Versioned<V> versioned) throws SyncException {
VectorClock clock = (VectorClock) versioned.getVersion();
clock = clock.clone();
try {
store.put(key, versioned);
fail(message);
} catch(ObsoleteVersionException e) {
// this is good, but check that we didn't fuck with the version
assertEquals(clock, versioned.getVersion());
}
}