我正在开发一个系统,我需要在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数据库中拉出来?


基础教程推荐
- Java单链表的增删改查与面试题详解 2023-05-25
- SpringBoot DataSource数据源实现自动配置流程详解 2023-06-06
- jvm垃圾回收算法详细解析 2023-03-07
- Springboot实例讲解实现专业材料认证管理系统流程 2022-12-06
- Java static关键字详细解析 2023-04-23
- 通过FeignClient如何获取文件流steam is close问题 2023-01-09
- [java] 在linux+chrome/firefox上使用java applet 2023-08-31
- javaSql面试题(10题) 2023-11-01
- Spring Boot Rest常用框架注解详情简介 2022-12-19
- Java,MySQL:我保存了“ČeskáTřebová”,但保存了“?eskáT?ebová”(来自终端一切都很好) 2023-10-30