1818import com .hmsonline .storm .cassandra .bolt .mapper .TridentColumnMapper ;
1919import com .hmsonline .storm .cassandra .bolt .mapper .TridentTupleMapper ;
2020import com .hmsonline .storm .cassandra .client .AstyanaxClient ;
21+ import com .hmsonline .storm .cassandra .client .AstyanaxClientFactory ;
2122
2223public class TridentCassandraLookupFunction <K , C , V > implements Function {
2324 private static final long serialVersionUID = 12132012L ;
@@ -27,24 +28,35 @@ public class TridentCassandraLookupFunction<K, C, V> implements Function {
2728 private TridentColumnMapper <K , C , V > columnsMapper ;
2829 private TridentTupleMapper <K , C , V > tupleMapper ;
2930 private AstyanaxClient <K , C , V > client ;
30- private String clientConfigKey ;
31+ private String cassandraClusterId ;
3132
3233 private Filter tupleFilter = null ; // used to prevent processing for tuples
3334 // that should be skipped by the lookup
3435 private int numberOfOutputFields = 1 ; // used to emit when the incoming
3536 // tuple doesn't pass the filter check
3637 private boolean emitEmptyOnFailure = false ;
3738
38- public TridentCassandraLookupFunction (String clientConfigKey , TridentTupleMapper <K , C , V > tupleMapper ,
39+ /**
40+ * @param cassandraClusterId Unique identifier for the Cassandra cluster
41+ * @param tupleMapper
42+ * @param columnMapper
43+ */
44+ public TridentCassandraLookupFunction (String cassandraClusterId , TridentTupleMapper <K , C , V > tupleMapper ,
3945 TridentColumnMapper <K , C , V > columnMapper ) {
4046 this .columnsMapper = columnMapper ;
4147 this .tupleMapper = tupleMapper ;
42- this .clientConfigKey = clientConfigKey ;
48+ this .cassandraClusterId = cassandraClusterId ;
4349 }
4450
45- public TridentCassandraLookupFunction (String clientConfigKey , TridentTupleMapper <K , C , V > tupleMapper ,
51+ /**
52+ * @param cassandraClusterId Unique identifier for the Cassandra cluster
53+ * @param tupleMapper
54+ * @param columnMapper
55+ * @param emitEmptyOnFailure
56+ */
57+ public TridentCassandraLookupFunction (String cassandraClusterId , TridentTupleMapper <K , C , V > tupleMapper ,
4658 TridentColumnMapper <K , C , V > columnMapper , boolean emitEmptyOnFailure ) {
47- this (clientConfigKey , tupleMapper , columnMapper );
59+ this (cassandraClusterId , tupleMapper , columnMapper );
4860 this .emitEmptyOnFailure = emitEmptyOnFailure ;
4961 }
5062
@@ -63,10 +75,8 @@ public void setEmitEmptyOnFailure(boolean emitEmptyOnFailure) {
6375 @ Override
6476 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
6577 public void prepare (Map stormConf , TridentOperationContext context ) {
66- Map <String , Object > config = (Map <String , Object >) stormConf .get (this .clientConfigKey );
67-
68- this .client = new AstyanaxClient <K , C , V >();
69- this .client .start (config );
78+ Map <String , Object > config = (Map <String , Object >) stormConf .get (this .cassandraClusterId );
79+ this .client = AstyanaxClientFactory .getInstance (cassandraClusterId , config );
7080 }
7181
7282 @ Override
0 commit comments