本文整理汇总了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);
}
示例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();
}
示例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));
}
}
示例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));
}
}