我正在开发一个系统,我需要在Cassandra数据库中存储Avro Schemas.所以在Cassandra,我们将存储这样的东西SchemaId AvroSchema1 some schema2 another schema现在假设...
我正在开发一个系统,我需要在Cassandra数据库中存储Avro Schemas.所以在Cassandra,我们将存储这样的东西
SchemaId AvroSchema
1 some schema
2 another schema
现在假设我在Cassandra的上表中插入另一行,现在表格就像这样 –
SchemaId AvroSchema
1 some schema
2 another schema
3 another new schema
只要我在上表中插入一个新行 – 我需要告诉我的Java程序去拉新的模式ID和相应的模式.
解决这类问题的正确方法是什么?
我知道,一种方法是每隔几分钟进行一次轮询,让我们说每5分钟我们就会从上表中提取数据,但这不是每5分钟解决这个问题的正确方法,我正在拉动是否有任何新的架构..
但除此之外还有其他解决方案吗?
我们可以使用Apache Zookeeper吗?或者Zookeeper不适合这个问题?
或任何其他解决方案?
我正在运行Apache Cassandra 1.2.9
解决方法:
一些解决方案
>使用数据库触发器:Cassandra 2.0有一些触发器支持,但看起来它不是最终的,并且根据本文可能会在2.1中稍微改变:http://www.datastax.com/dev/blog/whats-new-in-cassandra-2-0-prototype-triggers-support.触发器是一种常见的解决方案.
>你提出了民意调查,但这并不总是一个糟糕的选择.特别是如果你有一些东西标记该行还没有被拉动,那么你可以从Cassandra中拉出新的行.如果查询费用不高,那么每5分钟拉一次对于Cassandra或任何数据库来说都不是明智之举.如果在很少的基础上插入新行,则此选项可能不太好.
Zookeeper不是一个完美的解决方案,请看这个引用:
Because watches are one time triggers and there is latency between
getting the event and sending a new request to get a watch you cannot
reliably see every change that happens to a node in ZooKeeper. Be
prepared to handle the case where the znode changes multiple times
between getting the event and setting the watch again. (You may not
care, but at least realize it may happen.)
报价来自:http://zookeeper.apache.org/doc/r3.4.2/zookeeperProgrammers.html#sc_WatchRememberThese
本文标题为:java – 每当有任何新行或任何新更新时从Cassandra数据库中拉出来?
基础教程推荐
- springboot集成KoTime的配置过程 2023-01-02
- Java 中不全部使用 Static 方法的理由 2023-04-06
- 详解java封装返回结果与RestControllerAdvice注解 2023-05-18
- Java服务假死之生产事故的排查与优化问题 2023-02-18
- IDEA2022.1创建maven项目规避idea2022新建maven项目卡死无反应问题 2023-04-16
- Java基础类库之StringBuffer类用法详解 2023-03-20
- Java中Cookie和Session详解及区别总结 2023-02-04
- Java:控制台输入车辆信息,将信息保存至数据库中 2023-10-30
- Java设计模式之模板方法模式Template Method Pattern详解 2023-07-01
- java客户端Etcd官方仓库jetcd中KeepAlive接口实现 2022-11-03
