Skip to content

Commit 01743e6

Browse files
author
Tom May
committed
Make CassandraBlobStore.toString() return host:port, use it in a few places
for logging and exception strings.
1 parent 951bea6 commit 01743e6

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public AbstractCassandraBlobContainer(BlobPath path, CassandraBlobStore blobStor
4343
super(path);
4444
this.blobPath = path.buildAsString("/");
4545
this.blobStore = blobStore;
46-
logger.debug("AbstractCassandraBlobContainer path={}", path);
46+
logger.debug("AbstractCassandraBlobContainer blobStore={} path={}",
47+
blobStore, path);
4748
}
4849

4950
@Override public boolean blobExists(String blobName) {

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public class CassandraBlobStore extends AbstractComponent implements BlobStore {
115115

116116
private final String keyspace;
117117

118+
private final String hostAndPort;
119+
118120
private final CassandraClientFactory cassandraClientFactory;
119121

120122
private final Executor executor;
@@ -129,18 +131,19 @@ public CassandraBlobStore(Settings settings, Executor executor) {
129131

130132
String host = settings.get("host", "localhost");
131133
int port = settings.getAsInt("port", 9160);
134+
hostAndPort = host + ':' + port;
132135
cassandraClientFactory = new CassandraClientFactory(host, port);
133136

134137
this.executor = executor;
135138

136139
this.bufferSizeInBytes = (int) settings.getAsBytesSize("buffer_size", new ByteSizeValue(100, ByteSizeUnit.KB)).bytes();
137140

138-
logger.debug("CassandraBlobStore {}:{} executor: {} bufferSizeInBytes: {}",
139-
host, port, executor, bufferSizeInBytes);
141+
logger.debug("CassandraBlobStore {} executor: {} bufferSizeInBytes: {}",
142+
this, executor, bufferSizeInBytes);
140143
}
141144

142145
@Override public String toString() {
143-
return "cassandra"; // XXX
146+
return hostAndPort;
144147
}
145148

146149
/* XXX
@@ -165,7 +168,7 @@ public int bufferSizeInBytes() {
165168
}
166169
catch (IOException ex) {
167170
// Oh well, nothing we can do but log.
168-
logger.warn("delete {} failed", ex, blobPath);
171+
logger.warn("delete {} failed on {}", ex, blobPath, this);
169172
}
170173
}
171174

@@ -314,16 +317,16 @@ ImmutableMap<String, BlobMetaData> listBlobsByPrefix(String blobPath, @Nullable
314317
ConsistencyLevel.QUORUM);
315318
}
316319
catch (InvalidRequestException ex) {
317-
throw new IOException("Cassandra get_slice on ???:??? failed", ex);
320+
throw new IOException("Cassandra get_slice failed on " + this, ex);
318321
}
319322
catch (UnavailableException ex) {
320-
throw new IOException("Cassandra get_slice on ???:??? failed", ex);
323+
throw new IOException("Cassandra get_slice failed on " + this, ex);
321324
}
322325
catch (TimedOutException ex) {
323-
throw new IOException("Cassandra get_slice on ???:??? failed", ex);
326+
throw new IOException("Cassandra get_slice failed on " + this, ex);
324327
}
325328
catch (TException ex) {
326-
throw new IOException("Cassandra get_slice on ???:??? failed", ex);
329+
throw new IOException("Cassandra get_slice failed on " + this, ex);
327330
}
328331
finally {
329332
cassandraClientFactory.closeCassandraClient(client);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class CassandraImmutableBlobContainer extends AbstractCassandraBlobContai
3333

3434
public CassandraImmutableBlobContainer(BlobPath path, CassandraBlobStore blobStore) {
3535
super(path, blobStore);
36+
logger.debug("CassandraImmutableBlobContainer blobStore={} path={}",
37+
blobStore, path);
3638
}
3739

3840
@Override public void writeBlob(String blobName, InputStream is, long sizeInBytes, WriterListener listener) {

0 commit comments

Comments
 (0)