请教一下~
测试过程中遇到两个疑问(juicefs配合tikv使用的测试)
1.tikv的事务接口文档没找到,只看到了raw API;
2.juicefs会像tikv写数据,监控也看到数据有变化了,但是我通过scan接口没查到数据,(只有最初的几条设置时写的元数据,展示出来还是乱码),有点没理解
代码如下,麻烦帮忙看下~
(startKeyStr, endKeyStr 都传null)
@RequestMapping(value = "/scan", method = RequestMethod.GET)
public Map<String, String> scan(
@RequestParam(value = "startKeyStr", required = false) String startKeyStr,
@RequestParam(value = "endKeyStr", required = false) String endKeyStr
) throws Exception {
System.out.println("scan/all api");
TiConfiguration conf = TiConfiguration.createRawDefault("xx.xx.xx.xxx:2379");
TiSession session = TiSession.create(conf);
RawKVClient client = session.createRawClient();
ByteString startKey = null;
ByteString endKey = null;
if(startKeyStr != null){
startKey = ByteString.copyFromUtf8(startKeyStr);
}
if(endKeyStr != null){
endKey = ByteString.copyFromUtf8(endKeyStr);
}
Map<String, String> res = new HashMap<>();
int limit = 4;
while(true) {
List<Kvrpcpb.KvPair> list = client.scan(startKey, endKey, limit);
Key maxKey = Key.MIN;
for (Kvrpcpb.KvPair pair : list) {
System.out.println(pair);
res.put(pair.getKey().toStringUtf8(), pair.getValue().toStringUtf8());
Key currentKey = Key.toRawKey(pair.getKey());
if(currentKey.compareTo(maxKey) > 0) {
maxKey = currentKey;
}
}
if(list.size() < limit) {
break;
}
startKey = maxKey.next().toByteString();
}
return res;
}
结果返回如下:
只有几条创建fs的记录;(通过rawAPI写入的数据也可以查到…通过juicefs写入的数据就拿不出来,监控显示确实有读写)