gpt4 book ai didi

cassandra - 检查 Astyanax Keyspace 是否为空或不存在

转载 作者:行者123 更新时间:2023-12-02 22:48:20 26 4
gpt4 key购买 nike

有没有办法检查当前上下文中是否存在 Astyanax Keyspace?现在我的代码执行以下操作:

keyspace = context.getClient();
try{
keyspace.describeKeyspace();
}catch (BadRequestException e){
keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
.put("strategy_options", ImmutableMap.<String, Object>builder()
.put("replication_factor", "1")
.build())
.put("strategy_class", "SimpleStrategy")
.build();
}

这是检查键空间是否存在的唯一方法吗?

最佳答案

我就是这样做的...

try {
keyspace.getKeyspaceProperties();
LOG.debug("keyspace exist");
} catch (Exception e) {
LOG.debug("keyspace does NOT exist");
}

此代码将生成异常,因此请务必添加一些注释。如果人们检查日志,他们就会明白发生了什么

更新有人在github上提出了功能请求 Issue #382 。希望对您有帮助...

关于cassandra - 检查 Astyanax Keyspace 是否为空或不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18209569/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com