GVKun编程网logo

Cassandra使用PHP SimpleCassie获取所有密钥(cas获取锁)

10

在本文中,我们将给您介绍关于Cassandra使用PHPSimpleCassie获取所有密钥的详细内容,并且为您解答cas获取锁的相关问题,此外,我们还将为您提供关于Android缓存框架ASimpl

在本文中,我们将给您介绍关于Cassandra使用PHP SimpleCassie获取所有密钥的详细内容,并且为您解答cas获取锁的相关问题,此外,我们还将为您提供关于Android 缓存框架 ASimpleCache、ASimpleCache —— 轻量级 Android 缓存框架、Cannot start Cassandra db using bin/cassandra、Cassandra Gossip 协议的知识。

本文目录一览:

Cassandra使用PHP SimpleCassie获取所有密钥(cas获取锁)

Cassandra使用PHP SimpleCassie获取所有密钥(cas获取锁)

是否可以使用SimpleCassie获取列族中的所有键?
我查看了SimpleCassie的谷歌代码,但不明白.

另一个问题是我使用以下代码来访问列值.

$price = $cassie-> keyspace(‘ToyStore’) – > cf(‘Toys’) – > key(‘Transformer’) – > column(‘Price’) – > get();

echo $price;

它总是抱怨“cassandra columnorsupercolumn的对象不能转换为字符串”.
是否可以打印出列值?

解决方法

您应该使用get_range_slices,以“”开头,并在每次调用后使用最后一个键作为下一次调用的开始键(免责声明:尚未使用SimpleCassie测试此项)

如何在列族中对列进行排序? LongType的价格?

有效的’compare_with’值是(来自cassandra.yaml):“AsciiType,UTF8Type,LexicalUUIDType,TimeUUIDType,LongType,和IntegerType(通用可变长度整数类型)

Android 缓存框架 ASimpleCache

Android 缓存框架 ASimpleCache

ASimpleCache可以缓存哪些东西

ASimpleCache基本可以缓存常用的Android对象,包括但不限于以下几种类型:

  • 普通字符串

  • JSON对象

  • 经过序列化的Java对象

  • 字节数组

ASimpleCache的特点

  • 轻量级,只有一个Java文件

  • 完整而灵活的配置,可以配置缓存路径,缓存大小,缓存数量,缓存超时时间等。

  • 超时缓存自动失效,并从内存中自动删除。

  • 多进程的支持

ASimpleCache的示例代码

设置缓存数据:

ACache mCache = ACache.get(this);
mCache.put("test_key1", "test value");
mCache.put("test_key2", "test value", 10);//保存10秒,如果超过10秒去获取这个key,将为null
mCache.put("test_key3", "test value", 2 * ACache.TIME_DAY);//保存两天,如果超过两天去获取这个key,将为null


获取缓存数据:

ACache mCache = ACache.get(this);
String value = mCache.getAsString("test_key1");


ASimpleCache —— 轻量级 Android 缓存框架

ASimpleCache —— 轻量级 Android 缓存框架

ASimpleCache 是一个为android制定的 轻量级的 开源缓存框架。轻量到只有一个java文件(由十几个类精简而来)。它的下载地址是:https://github.com/yangfuhai/ASimpleCache

Cannot start Cassandra db using bin/cassandra

Cannot start Cassandra db using bin/cassandra

13 down vote favorite
1

I have Ubuntu 12.04 with cassandra 1.1.3 (tarball installation), When I try to start cassandra, I get the following:

user@ubuntu:~/apache-cassandra-1.1.3/bin$ sudo ./cassandra -f
xss =  -ea -javaagent:./../lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms4G -Xmx4G -Xmn800M -XX:    +HeapDumpOnOutOfMemoryError -Xss128k
user@ubuntu:~/apache-cassandra-1.1.3/bin$

According to cassandra documentation, the output does not look as expected:

The service should start in the foreground and log gratuitously to 
standard-out. Assuming you don''t see messages with scary words like  
"error", or "fatal", or anything that looks like a Java stack trace,  
then chances are you''ve succeeded.

So, what is the problem?

cassandra
share | improve this question
edited Jun 17 at 17:43
Eric Leschinski
6,363 4 32 45
asked Aug 10 ''12 at 12:11
Ababneh A
327 2 11


Does your database contain any data? Or is this a new install? –  BryceAtNetwork23 Aug 10 ''12 at 13:00
1  
It is a new install, previously, I installed the ubuntu packaged cassandra 1.0 using apt-get, and it used to start without problems. Anyway, 2 days later, I uninstalled cassandra 1.0 by removing the folders manually, and installed the tarball for cassandra 1.1 (following the instructions in the official website) –  Ababneh A Aug 10 ''12 at 13:39

Correction: I followed the instructions in the README file, not form the website –  Ababneh A Aug 10 ''12 at 14:01

Did your cassandra.yaml remain the same? Is it referencing the correct data_file_directories? If so, try pointing it to a new (empty) directory and see if it comes-up. –  BryceAtNetwork23 Aug 10 ''12 at 19:08

I checked cassandra.yaml, and it was referencing an old directory that does not exist anymore (probably related to the previous installation). I set the following: data_file_directories: /db/cassandra/data, and also: commitlog_directory: /db/cassandra/commitlog, and, saved_caches_directory: /db/cassandra/commitlog. I tried agian, but cassandra did not come up, and the terminal returned the same error. –  Ababneh A Aug 10 ''12 at 21:11
show 1 more comment

2 Answers

active oldest votes
up vote 16 down vote

The problem may be caused by using OpenJDK, as described in a Cassandra bug report but, see the comments here for occurrences of this issue on Sun/Oracle and other JVMs:

  • https://issues.apache.org/jira/browse/CASSANDRA-2441

If you cannot install the Oracle JVM, then try changing the stack size in theconf/cassandra-env.shconfiguration script. Look for the following section, at around line 185, and change the-Xss180kto a higher value.

if [ "`uname`" = "Linux" ] ; then
  # reduce the per-thread stack size to minimize the impact of Thrift
  # thread-per-client.  (Best practice is for client connections to
  # be pooled anyway.) Only do so on Linux where it is known to be
  # supported.
  # u34 and greater need 180k
  JVM_OPTS="$JVM_OPTS -Xss180k"
fi
echo "xss = $JVM_OPTS"

I have used 280k successfully when testing installations on Ubuntu servers at Rackspace and Amazon.

Based on reports in the comments below, I would either suggest increasing the stack size in 20k increments, starting with-Xss200k, until Cassandra starts properly. Note that it is also possible to remove this option and use the default stack size per thread, but be aware of the impact this will have on memory consumption.

share | improve this answer
edited Aug 19 at 21:34
Beryllium
4,135 3 6 25
answered Jan 21 at 21:28
grkvlt
732 4 13

3  
Using a 256k stack-size fixes this problem on Red Hat 6. –  Raedwald Feb 28 at 15:48
1  
I ran into this problem with the Sun 1.7.0_15 JDK as well, and setting-Xss280kfixed it. So this issue isn''t limited to OpenJDK. –  Josh Glover Jul 8 at 13:59

I got away with 210k on Amazon Linux 64bit AMI (OpenJDK 1.6) –  delitescere Jul 10 at 2:16

280k fixed this for me on java version "1.6.0_27" OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-0ubuntu0.12.04.1) –  Steve Swinsburg Jul 25 at 2:41

Brilliant, worked perfectly setting to -Xss280k. Thank you. –  xetur Aug 31 at 18:40
up vote 1 down vote

This is most likely caused by attempting to run under OpenJDK 1.6, which causes a segmentation fault under Ubuntu/Debian. The seg fault is hidden because of the way the shell script executes the process. You can test for this problem by modifying $CASSANDRA_HOME/bin/cassandra as follows:

Change this line:

exec $NUMACTL "$JAVA" $JVM_OPTS $cassandra_parms -cp "$CLASSPATH" $props "$class"

to this:

echo $NUMACTL "$JAVA" $JVM_OPTS $cassandra_parms -cp "$CLASSPATH" $props "$class"

Then runbin/cassandra -fand copy the resulting java command. Run this directly to see if it produces the segmentation fault. If this is your problem, you need to switch to the Sun or IBM JDK, or alternatively you can upgrade to OpenJDK 1.7.

share | improve this answer
answered Oct 17 ''12 at 19:25
rs_atl
2,787 4 15


On Red Hat, I get a similar outcome but the O/S also reports "Segmentation fault (core dumped)". –  Raedwald Feb 28 at 14:00
2  
This is not restricted to OpenJDK 1.6 -- increasing the stack size resolves the problem. –  delitescere Jul 10 at

Cassandra Gossip 协议

Cassandra Gossip 协议

(一)Gossip的作用
Cassandra集群没有中心节点,各个节点的地位完全相同,它们通过一种叫做gossip的协议维护集群的状态。
通过gossip,每个节点都能知道集群中包含哪些节点,以及这些节点的状态,这使得Cassandra集群中的任何一个节点都可以完成任意key的路由,任意一个节点不可用都不会造成灾难性的后果。

(二)Gossip协议介绍
gossip的学名叫做Anti-entropy(逆熵?),比较适合在没有很高一致性要求的场景中用作同步信息。信息达到同步的时间大概是log(N),这里N表示节点的数量。
gossip有两种形式:anti-entropy和rumor-mongering。
gossip中的每个节点维护一组状态,状态可以用一个key/value对表示,还附带一个版本号,版本号大的为更新的状态。
消息的处理有3种方式,Cassandra采用第三种方式——Push-pull-gossip

(三)Gossip消息如何如何发送
当一个节点启动时,获取配置文件(cassandra.yaml)中的seeds配置,从而知道集群中所有的seed节点。
Cassandra内部有一个Gossiper,每隔一秒运行一次(在Gossiper.Java的start方法中),按照以下规则向其他节点发送同步消息:
1、随机取一个当前活着的节点,并向它发送同步请求
2、向随机一台不可达的机器发送同步请求
3、如果第一步中所选择的节点不是seed,或者当前活着的节点数少于seed数,则向随意一台seed发送同步请求
如果没有这个判断,考虑这样一种场景,有4台机器,{A, B, C, D},并且配置了它们都是seed,如果它们同时启动,可能会出现这样的情形:
1、A节点起来,发现没有活着的节点,走到第三步,和任意一个种子同步,假设选择了B
2、B节点和A完成同步,则认为A活着,它将和A同步,由于A是种子,B将不再和其他种子同步
3、C节点起来,发现没有活着的节点,同样走到第三步,和任意一个种子同步,假设这次选择了D
4、C节点和D完成同步,认为D活着,则它将和D同步,由于D也是种子,所以C也不再和其他种子同步
这时就形成了两个孤岛,A和B互相同步,C和D之间互相同步,但是{A,B}和{C,D}之间将不再互相同步,它们也就不知道对方的存在了。
加入第二个判断后,A和B同步完,发现只有一个节点活着,但是seed有4个,这时会再和任意一个seed通信,从而打破这个孤岛。

(四)Cassandra中Gossip数据结构
gossip通信的状态信息主要有3种:
1、EndPointState
2、HeartBeatState
3、ApplicationState
HeartBeatState 由generation和version组成,generation每次启动都会变化,用于区分机器重启前后的状态;Version是只能增长的,每次心跳之前进行递增
ApplicationState用于表示系统的状态,由state和version组成,state表示节点的状态,version是递增的,每个对象表示节点一种状态,比如表示当前load的状态大概是这样:(1.2, 20),含义为版本号为20时该节点的load是1.2
EndPointState 封装了一个节点的ApplicationState构成的映射(Map<String, ApplicationState> applicationState_)和HeartBeatState
一个节点自身的状态只能由自己修改,其他节点的状态只能通过同步更新。

(六)Gossip状态信息有哪些
负载信息(LOAD-INFORMATION)
迁移信息(MIGRATION)
节点状态信息(MOVE)
        BOOT(启动阶段)节点正在启动
        NORMAL(正常)节点加入了Token的ring,可以提供读
        LEAVING,节点准备离开Ring
        LEFT,节点被踢出集群或者是Token信息被手工变更

(七)Gossip消息同步过程

今天关于Cassandra使用PHP SimpleCassie获取所有密钥cas获取锁的分享就到这里,希望大家有所收获,若想了解更多关于Android 缓存框架 ASimpleCache、ASimpleCache —— 轻量级 Android 缓存框架、Cannot start Cassandra db using bin/cassandra、Cassandra Gossip 协议等相关知识,可以在本站进行查询。

本文标签: