Skip to content

Commit c33c022

Browse files
author
Tom May
committed
Implement Cassandra deleteBlob.
1 parent 0c3d002 commit c33c022

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public AbstractCassandraBlobContainer(BlobPath path, CassandraBlobStore blobStor
7171
}
7272

7373
@Override public boolean blobExists(String blobName) {
74+
logger.debug("TODO blobExists blobName={}", blobName);
7475
try {
75-
logger.debug("TODO blobExists blobName={}", blobName);
7676
Cassandra.Client client =
7777
CassandraClientFactory.getCassandraClient();
7878
try {
@@ -92,7 +92,26 @@ public AbstractCassandraBlobContainer(BlobPath path, CassandraBlobStore blobStor
9292

9393
@Override public boolean deleteBlob(String blobName) throws IOException {
9494
logger.debug("TODO deleteBlob blobName={}", blobName);
95-
return true;
95+
Cassandra.Client client =
96+
CassandraClientFactory.getCassandraClient();
97+
try {
98+
long timestamp = System.currentTimeMillis();
99+
client.remove(
100+
keySpace,
101+
blobKey(blobName),
102+
new ColumnPath("Blobs"),
103+
timestamp,
104+
ConsistencyLevel.QUORUM);
105+
return true;
106+
}
107+
catch (Exception e) {
108+
// TODO S3 does this, what's the deal with returning false
109+
// vs. throwing IOException?
110+
return false;
111+
}
112+
finally {
113+
CassandraClientFactory.closeCassandraClient(client);
114+
}
96115
}
97116

98117
@Override public void readBlob(final String blobName, final ReadBlobListener listener) {

0 commit comments

Comments
 (0)