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


Java IStorageEngine.getVersions方法代码示例

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


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

示例1: handleDeleteRequest

import org.sdnplatform.sync.internal.store.IStorageEngine; //导入方法依赖的package包/类
@Override
protected void handleDeleteRequest(DeleteRequestMessage request,
                                   Channel channel) {
    try {
        String storeName = request.getStoreName();
        IStorageEngine<ByteArray, byte[]> store =
                syncManager.getRawStore(storeName);
        ByteArray key = new ByteArray(request.getKey());
        VectorClock newclock;
        if (request.isSetVersion()) {
            newclock = TProtocolUtil.getVersion(request.getVersion());
        } else {
            newclock = new VectorClock();
            List<IVersion> versions = store.getVersions(key);
            for (IVersion v : versions) {
                newclock = newclock.merge((VectorClock)v);
            }
        }
        newclock =
                newclock.incremented(rpcService.syncManager.getLocalNodeId(),
                                     System.currentTimeMillis());
        Versioned<byte[]> value = Versioned.value(null, newclock);
        store.put(key, value);

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

        SyncMessage bsm =
                new SyncMessage(MessageType.DELETE_RESPONSE);
        bsm.setDeleteResponse(m);
        channel.write(bsm);
    } catch (Exception e) {
        channel.write(getError(request.getHeader().getTransactionId(), e,
                               MessageType.DELETE_REQUEST));
    }
}
 
开发者ID:rizard,项目名称:fast-failover-demo,代码行数:39,代码来源:RPCChannelHandler.java

示例2: handlePutRequest

import org.sdnplatform.sync.internal.store.IStorageEngine; //导入方法依赖的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

示例3: handlePutRequest

import org.sdnplatform.sync.internal.store.IStorageEngine; //导入方法依赖的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.internal.store.IStorageEngine.getVersions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。