2

Cassandra 2.0.5、Storm バージョン 0.9.0.1 のテーブルに単純な行を挿入しようとしています。

私のテストは次のとおりです。

ID (int) と文 (text) 列で構成されるテーブルがあります。id は主キーです。

私のスパウトは文を生成し、ID (コードの静的インクリメント) を追加します。

これは私のトポロジです:

TridentTopology topology = new TridentTopology();
StateFactory cassandraStateFactory = CassandraMapState.nonTransactional(options);
Fields fields = new Fields("id", "sentence");
MyTridentTupleMapper tupleMapper = new MyTridentTupleMapper(keyspace, fields);
CassandraUpdater updater = new CassandraUpdater(tupleMapper);
TridentState wordCounts = topology.newStream("spout1", spout)
            .each(new Fields("sentence"), new AddId(), new Fields("id"))
            .partitionPersist(cassandraStateFactory, fields, updater);

LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", config, topology.build());    

MyTridentTupleMapper のコード:

https://github.com/guywald/trident-cassandra-read-write-examples/blob/master/src/test/java/com/guywald/storm/trident/cassandra/MyTridentTupleMapper.java

次の例外が発生します。

2014-02-08 22:20:14 ERROR executor:0 - 
java.lang.RuntimeException: java.lang.ClassCastException: storm.trident.state.map.SnapshottableMap cannot be cast to com.hmsonline.storm.cassandra.trident.CassandraState
    at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:90)
    at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:61)
    at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:62)
    at backtype.storm.daemon.executor$fn__3498$fn__3510$fn__3557.invoke(executor.clj:730)
    at backtype.storm.util$async_loop$fn__444.invoke(util.clj:403)
    at clojure.lang.AFn.run(AFn.java:24)
    at java.lang.Thread.run(Thread.java:744)

なぜこれが返されるのかわかりません。助けていただければ幸いです。

4

1 に答える 1

0

CassandraUpdater は CassandraState を想定しているようですが、CassandraMapState.nonTransactional は互換性のない SnapshottableMap を作成します。CassandraMapState では、一般的な (または特殊なカスタムの) MapState アップデーターを使用する必要があると思います。ここに State と MapState をいつ使用するかについての良い説明があります: https://groups.google.com/forum/#!topic/storm-user/TASr2zWyzKs

あなたの例が機能するには、CassandraStateFactory を状態ファクトリーとして使用する必要があると思います。

于 2015-09-03T15:30:00.653 に答える