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


Java Versioned.value方法代码示例

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


在下文中一共展示了Versioned.value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:AbstractStoreClient.java

示例2: put

import org.sdnplatform.sync.Versioned; //导入方法依赖的package包/类
@Override
public IVersion put(K key, Versioned<V> versioned)
        throws SyncException {
    VectorClock vc = (VectorClock)versioned.getVersion();

    vc = vc.incremented(syncManager.getLocalNodeId(),
                        System.currentTimeMillis());
    versioned = Versioned.value(versioned.getValue(), vc);

    delegate.put(key, versioned);
    return versioned.getVersion();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:13,代码来源:DefaultStoreClient.java

示例3: handlePutRequest

import org.sdnplatform.sync.Versioned; //导入方法依赖的package包/类
@Override
protected void handlePutRequest(PutRequestMessage request,
                                Channel channel) {
    String storeName = request.getStoreName();
    try {
        IStorageEngine<ByteArray, byte[]> store =
                syncManager.getRawStore(storeName);

        ByteArray key = new ByteArray(request.getKey());
        Versioned<byte[]> value = null;
        if (request.isSetVersionedValue()) {
            value = TProtocolUtil.
                    getVersionedValued(request.getVersionedValue());
            value.increment(syncManager.getLocalNodeId(),
                            System.currentTimeMillis());
        } else if (request.isSetValue()) {
            byte[] rvalue = request.getValue();
            List<IVersion> versions = store.getVersions(key);
            VectorClock newclock = new VectorClock();
            for (IVersion v : versions) {
                newclock = newclock.merge((VectorClock)v);
            }
            newclock = newclock.incremented(syncManager.getLocalNodeId(),
                                            System.currentTimeMillis());
            value = Versioned.value(rvalue, newclock);
        } else {
            throw new SyncException("No value specified for put");
        }

        store.put(key, value);

        PutResponseMessage m = new PutResponseMessage();
        AsyncMessageHeader header = new AsyncMessageHeader();
        header.setTransactionId(request.getHeader().getTransactionId());
        m.setHeader(header);

        SyncMessage bsm = new SyncMessage(MessageType.PUT_RESPONSE);
        bsm.setPutResponse(m);
        channel.writeAndFlush(bsm);
    } catch (Exception e) {
        channel.writeAndFlush(getError(request.getHeader().getTransactionId(), e,
                               MessageType.PUT_REQUEST));
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:45,代码来源:RPCChannelHandler.java

示例4: handlePutRequest

import org.sdnplatform.sync.Versioned; //导入方法依赖的package包/类
@Override
protected void handlePutRequest(PutRequestMessage request,
                                Channel channel) {
    String storeName = request.getStoreName();
    try {
        IStorageEngine<ByteArray, byte[]> store =
                syncManager.getRawStore(storeName);

        ByteArray key = new ByteArray(request.getKey());
        Versioned<byte[]> value = null;
        if (request.isSetVersionedValue()) {
            value = TProtocolUtil.
                    getVersionedValued(request.getVersionedValue());
            value.increment(syncManager.getLocalNodeId(),
                            System.currentTimeMillis());
        } else if (request.isSetValue()) {
            byte[] rvalue = request.getValue();
            List<IVersion> versions = store.getVersions(key);
            VectorClock newclock = new VectorClock();
            for (IVersion v : versions) {
                newclock = newclock.merge((VectorClock)v);
            }
            newclock = newclock.incremented(syncManager.getLocalNodeId(),
                                            System.currentTimeMillis());
            value = Versioned.value(rvalue, newclock);
        } else {
            throw new SyncException("No value specified for put");
        }

        store.put(key, value);

        PutResponseMessage m = new PutResponseMessage();
        AsyncMessageHeader header = new AsyncMessageHeader();
        header.setTransactionId(request.getHeader().getTransactionId());
        m.setHeader(header);

        SyncMessage bsm = new SyncMessage(MessageType.PUT_RESPONSE);
        bsm.setPutResponse(m);
        channel.write(bsm);
    } catch (Exception e) {
        channel.write(getError(request.getHeader().getTransactionId(), e,
                               MessageType.PUT_REQUEST));
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:45,代码来源:RPCChannelHandler.java


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