Skip to content

Commit 951bea6

Browse files
author
Tom May
committed
Make Cassandra keyspace configurable.
1 parent 8a7f856 commit 951bea6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

config/elasticsearch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ gateway:
33
cassandra:
44
host: localhost
55
port: 9160
6+
keyspace: ElasticSearch
67

78
index:
89
numberOfShards: 1

plugins/cassandra/src/main/java/org/elasticsearch/cassandra/blobstore/CassandraBlobStore.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@
109109
* @author Tom May ([email protected])
110110
*/
111111
public class CassandraBlobStore extends AbstractComponent implements BlobStore {
112-
private static final String keySpace = "ElasticSearch";
113-
114112
private static final Charset utf8 = Charset.forName("UTF-8");
115113

116114
private final ESLogger logger = Loggers.getLogger(getClass());
117115

116+
private final String keyspace;
117+
118118
private final CassandraClientFactory cassandraClientFactory;
119119

120120
private final Executor executor;
@@ -125,6 +125,8 @@ public class CassandraBlobStore extends AbstractComponent implements BlobStore {
125125
public CassandraBlobStore(Settings settings, Executor executor) {
126126
super(settings);
127127

128+
keyspace = settings.get("keyspace", "ElasticSearch");
129+
128130
String host = settings.get("host", "localhost");
129131
int port = settings.getAsInt("port", 9160);
130132
cassandraClientFactory = new CassandraClientFactory(host, port);
@@ -178,7 +180,7 @@ boolean blobExists(String blobPath, String blobName) {
178180
cassandraClientFactory.getCassandraClient();
179181
try {
180182
return client.get_count(
181-
keySpace,
183+
keyspace,
182184
blobKey,
183185
new ColumnParent("Blobs"),
184186
ConsistencyLevel.QUORUM) != 0;
@@ -233,7 +235,7 @@ private boolean deleteBlobs(String blobPath, String... blobNames)
233235
try {
234236
client = cassandraClientFactory.getCassandraClient();
235237
client.batch_mutate(
236-
keySpace, mutationMap, ConsistencyLevel.QUORUM);
238+
keyspace, mutationMap, ConsistencyLevel.QUORUM);
237239
return true;
238240
}
239241
catch (Exception e) {
@@ -284,7 +286,7 @@ private void readBlob(Cassandra.Client client, String blobKey, BlobContainer.Rea
284286
throws Exception
285287
{
286288
ColumnOrSuperColumn columnOrSuperColumn = client.get(
287-
keySpace,
289+
keyspace,
288290
blobKey,
289291
new ColumnPath("Blobs").setColumn(utf8.encode("data")),
290292
ConsistencyLevel.QUORUM);
@@ -301,7 +303,7 @@ ImmutableMap<String, BlobMetaData> listBlobsByPrefix(String blobPath, @Nullable
301303
Cassandra.Client client = cassandraClientFactory.getCassandraClient();
302304
try {
303305
columns = client.get_slice(
304-
keySpace,
306+
keyspace,
305307
blobPath,
306308
new ColumnParent("BlobNames"),
307309
new SlicePredicate().setSlice_range(
@@ -409,7 +411,7 @@ private void writeBlob(Cassandra.Client client, String blobPath, String blobName
409411
mutationMap.put(blobPath, blobNamesMutationMap);
410412

411413
client.batch_mutate(
412-
keySpace, mutationMap, ConsistencyLevel.QUORUM);
414+
keyspace, mutationMap, ConsistencyLevel.QUORUM);
413415
}
414416

415417
private Mutation createInsert(String name, ByteBuffer value, long timestamp) {

0 commit comments

Comments
 (0)