使用AnnotatedCompositeSerializer放置的Astyanax复合柱在几个小时后通过多个客户端变得无法获取

Dav*_*ber 6 java cassandra astyanax

我有一个奇怪的问题.我的java应用程序通过astyanax将列放入cassandra.这似乎是暂时的,但是几个小时之后,如果我通过[row] [复合列],那么该列似乎就会消失.如果我获取整行,或者获取应该包含该列的一系列列,则返回该列.此行为发生在多个客户端,包括cassandra-cli和pycassa.例如:

get msg_metadata['someKey'];
=> (column=185779:completed, value={"timestamp":"1407777081","id":"167727"}, timestamp=1407777083241001)
Returned 1 results.
Elapsed time: 58 msec(s)

get msg_metadata['someKey']['185779:completed'];
=> (column=185779:completed, value={"timestamp":"1407777081","id":"167727"}, timestamp=1407777083241001)
Returned 1 results.
Elapsed time: 42 msec(s)

-- several hours later
get msg_metadata['someKey']['185779:completed'];
Value was not found
Elapsed time: 72 msec(s).

get msg_metadata['someKey'];
=> (column=185779:completed, value={"timestamp":"1407777081","id":"167727"}, timestamp=1407777083241001)
Returned 1 results.
Elapsed time: 107 msec(s)
Run Code Online (Sandbox Code Playgroud)

我在Cassandra 1.1.12集群中创建了以下列族:

create column family msg_metadata
with column_type = 'Standard'
and comparator = 'CompositeType(org.apache.cassandra.db.marshal.IntegerType,org.apache.cassandra.db.marshal.AsciiType)'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'AsciiType';
Run Code Online (Sandbox Code Playgroud)

我有以下代码,使用Astyanax 1.0.3

public class ColumnFamilies {
    public static final AnnotatedCompositeSerializer<MyField> MY_FIELD =
        new AnnotatedCompositeSerializer<MyField>(MyField.class);

    public static final ColumnFamily<String, MyField> MESSAGE_METADATA =
        new ColumnFamily<String, MyField>(
                "msg_metadata", AsciiSerializer.get(), MY_FIELD);

    public static class MyField {
        @Component(ordinal = 0)
        private Integer myId;

        @Component(ordinal = 1)
        private String fieldName;

        public CustomerField(Integer myId, String fieldName) {
            this.myId = myId;
            this.fieldName = fieldName;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序写入列族,如下所示:

    final MutationBatch mutationBatch = MESSAGE_METADATA.prepareMutationBatch();
    final MyField field = new MyField(myId, fieldName);
    mutationBatch.withRow(rowKey).putColumn(field, value, null);
    mutationBatch.execute();
Run Code Online (Sandbox Code Playgroud)

这让我困惑了一段时间.最初我认为问题可能是列族.我尝试过创建新的列族,但没有帮助.我怀疑复合列序列化有些混乱,但这只是我的直觉.任何想法发生了什么以及我如何解决这个问题?谢谢!

小智 -1

只是一个预感 - 您可以尝试将复合键中的 IntegerType 更改为 Int32Type 并检查是否有同样的问题?