当前位置: 首页>>代码示例>>Java>>正文


Java Occurred.AFTER属性代码示例

本文整理汇总了Java中org.sdnplatform.sync.IVersion.Occurred.AFTER属性的典型用法代码示例。如果您正苦于以下问题:Java Occurred.AFTER属性的具体用法?Java Occurred.AFTER怎么用?Java Occurred.AFTER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.sdnplatform.sync.IVersion.Occurred的用法示例。


在下文中一共展示了Occurred.AFTER属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveConflicts

public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) {
    int size = items.size();
    if(size <= 1)
        return items;

    List<Versioned<T>> newItems = Lists.newArrayList();
    for(Versioned<T> v1: items) {
        boolean found = false;
        for(ListIterator<Versioned<T>> it2 =
                newItems.listIterator(); it2.hasNext();) {
            Versioned<T> v2 = it2.next();
            Occurred compare = v1.getVersion().compare(v2.getVersion());
            if(compare == Occurred.AFTER) {
                if(found)
                    it2.remove();
                else
                    it2.set(v1);
            }
            if(compare != Occurred.CONCURRENTLY)
                found = true;
        }
        if(!found)
            newItems.add(v1);
    }
    return newItems;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:VectorClockInconsistencyResolver.java

示例2: compare

public int compare(Versioned<S> v1, Versioned<S> v2) {
    Occurred occurred = v1.getVersion().compare(v2.getVersion());
    if(occurred == Occurred.BEFORE)
        return -1;
    else if(occurred == Occurred.AFTER)
        return 1;
    else
        return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:9,代码来源:Versioned.java

示例3: doput

public boolean doput(K key, Versioned<V> value) throws SyncException {
    StoreUtils.assertValidKey(key);

    IVersion version = value.getVersion();

    while(true) {
        List<Versioned<V>> items = map.get(key);
        // If we have no value, optimistically try to add one
        if(items == null) {
            items = new ArrayList<Versioned<V>>();
            items.add(new Versioned<V>(value.getValue(), version));
            if (map.putIfAbsent(key, items) != null)
                continue;
            return true;
        } else {
            synchronized(items) {
                // if this check fails, items has been removed from the map
                // by delete, so we try again.
                if(map.get(key) != items)
                    continue;

                // Check for existing versions - remember which items to
                // remove in case of success
                List<Versioned<V>> itemsToRemove = new ArrayList<Versioned<V>>(items.size());
                for(Versioned<V> versioned: items) {
                    Occurred occurred = value.getVersion().compare(versioned.getVersion());
                    if(occurred == Occurred.BEFORE) {
                        return false;
                    } else if(occurred == Occurred.AFTER) {
                        itemsToRemove.add(versioned);
                    }
                }
                items.removeAll(itemsToRemove);
                items.add(value);
            }
            return true;
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:InMemoryStorageEngine.java


注:本文中的org.sdnplatform.sync.IVersion.Occurred.AFTER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。