109
109
* @author Tom May ([email protected] )
110
110
*/
111
111
public class CassandraBlobStore extends AbstractComponent implements BlobStore {
112
- private static final String keySpace = "ElasticSearch" ;
113
-
114
112
private static final Charset utf8 = Charset .forName ("UTF-8" );
115
113
116
114
private final ESLogger logger = Loggers .getLogger (getClass ());
117
115
116
+ private final String keyspace ;
117
+
118
118
private final CassandraClientFactory cassandraClientFactory ;
119
119
120
120
private final Executor executor ;
@@ -125,6 +125,8 @@ public class CassandraBlobStore extends AbstractComponent implements BlobStore {
125
125
public CassandraBlobStore (Settings settings , Executor executor ) {
126
126
super (settings );
127
127
128
+ keyspace = settings .get ("keyspace" , "ElasticSearch" );
129
+
128
130
String host = settings .get ("host" , "localhost" );
129
131
int port = settings .getAsInt ("port" , 9160 );
130
132
cassandraClientFactory = new CassandraClientFactory (host , port );
@@ -178,7 +180,7 @@ boolean blobExists(String blobPath, String blobName) {
178
180
cassandraClientFactory .getCassandraClient ();
179
181
try {
180
182
return client .get_count (
181
- keySpace ,
183
+ keyspace ,
182
184
blobKey ,
183
185
new ColumnParent ("Blobs" ),
184
186
ConsistencyLevel .QUORUM ) != 0 ;
@@ -233,7 +235,7 @@ private boolean deleteBlobs(String blobPath, String... blobNames)
233
235
try {
234
236
client = cassandraClientFactory .getCassandraClient ();
235
237
client .batch_mutate (
236
- keySpace , mutationMap , ConsistencyLevel .QUORUM );
238
+ keyspace , mutationMap , ConsistencyLevel .QUORUM );
237
239
return true ;
238
240
}
239
241
catch (Exception e ) {
@@ -284,7 +286,7 @@ private void readBlob(Cassandra.Client client, String blobKey, BlobContainer.Rea
284
286
throws Exception
285
287
{
286
288
ColumnOrSuperColumn columnOrSuperColumn = client .get (
287
- keySpace ,
289
+ keyspace ,
288
290
blobKey ,
289
291
new ColumnPath ("Blobs" ).setColumn (utf8 .encode ("data" )),
290
292
ConsistencyLevel .QUORUM );
@@ -301,7 +303,7 @@ ImmutableMap<String, BlobMetaData> listBlobsByPrefix(String blobPath, @Nullable
301
303
Cassandra .Client client = cassandraClientFactory .getCassandraClient ();
302
304
try {
303
305
columns = client .get_slice (
304
- keySpace ,
306
+ keyspace ,
305
307
blobPath ,
306
308
new ColumnParent ("BlobNames" ),
307
309
new SlicePredicate ().setSlice_range (
@@ -409,7 +411,7 @@ private void writeBlob(Cassandra.Client client, String blobPath, String blobName
409
411
mutationMap .put (blobPath , blobNamesMutationMap );
410
412
411
413
client .batch_mutate (
412
- keySpace , mutationMap , ConsistencyLevel .QUORUM );
414
+ keyspace , mutationMap , ConsistencyLevel .QUORUM );
413
415
}
414
416
415
417
private Mutation createInsert (String name , ByteBuffer value , long timestamp ) {
0 commit comments