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