Skip to content

Commit 3cd4d27

Browse files
author
shabtaisharon
authored
Merge pull request #306 from DenverM80/log_performance
Change format of LOG messages to be evaluated only if the LOG level i…
2 parents 675d69c + d44becd commit 3cd4d27

File tree

12 files changed

+29
-28
lines changed

12 files changed

+29
-28
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/ConnectionDetailsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static ConnectionDetails newForNode(final JobNode node, final ConnectionD
9191
connectionBuilder = builder(connectionDetails.getEndpoint(), connectionDetails.getCredentials());
9292
}
9393
else {
94-
LOG.trace("Creating new Connection Details for endpoint: " + node.getEndPoint());
94+
LOG.trace("Creating new Connection Details for endpoint: {}", node.getEndPoint());
9595
connectionBuilder = builder(buildAuthority(node, connectionDetails), connectionDetails.getCredentials());
9696
}
9797
connectionBuilder.withRedirectRetries(connectionDetails.getRetries())

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ public Ds3ClientBuilder withSocketTimeout(final int timeout) {
193193
*/
194194
@Override
195195
public Ds3Client build() {
196-
LOG.info("Making connection details for endpoint: " + this.endpoint
197-
+ " using authorization id: " + this.credentials.getClientId());
196+
LOG.info("Making connection details for endpoint [{}] using this authorization id [{}]",
197+
this.endpoint, this.credentials.getClientId());
198198
final ConnectionDetailsImpl.Builder connBuilder = ConnectionDetailsImpl
199199
.builder(this.endpoint, this.credentials)
200200
.withProxy(this.proxy)

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/interfaces/AbstractResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static Error parseErrorResponse(final String responseString) {
133133
return XmlOutput.fromXml(responseString, Error.class);
134134
} catch (final IOException e) {
135135
// It's likely the response string is not in a valid error format.
136-
LOG.error("Failed to parse error response", e);
136+
LOG.error("Failed to parse error response: {}", e);
137137
return null;
138138
}
139139
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/ChunkTransferrer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ public void transferChunks(
6969
try {
7070
final List<ListenableFuture<?>> tasks = new ArrayList<>();
7171
for (final Objects chunk : chunks) {
72-
LOG.debug("Processing parts for chunk: " + chunk.getChunkId().toString());
72+
LOG.debug("Processing parts for chunk: {}", chunk.getChunkId().toString());
7373

7474
final Ds3Client client = getClient(nodeMap, chunk.getNodeId(), mainClient);
7575
for (final BulkObject ds3Object : chunk.getObjects()) {
7676
final ObjectPart part = new ObjectPart(ds3Object.getOffset(), ds3Object.getLength());
7777
if (this.partTracker.containsPart(ds3Object.getName(), part)) {
78-
LOG.debug("Adding " + ds3Object.getName() + " to executor for processing");
78+
LOG.debug("Adding {} to executor for processing", ds3Object.getName());
7979
tasks.add(executor.submit(new Callable<Object>() {
8080
@Override
8181
public Object call() throws Exception {
82-
LOG.debug("Processing " + ds3Object.getName());
82+
LOG.debug("Processing {}", ds3Object.getName());
8383
ChunkTransferrer.this.itemTransferrer.transferItem(client, ds3Object);
8484
ChunkTransferrer.this.partTracker.completePart(ds3Object.getName(), part);
8585
return null;

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/Ds3ClientHelpersImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void ensureBucketExists(final String bucket) throws IOException, Signatur
186186
if (e.getStatusCode() != 409) {
187187
throw e;
188188
}
189-
LOG.warn("Creating " + bucket + " failed because it was created by another thread or process");
189+
LOG.warn("Creating {} failed because it was created by another thread or process", bucket);
190190
}
191191
}
192192
}
@@ -201,7 +201,7 @@ public void ensureBucketExists(final String bucket, final UUID dataPolicy) throw
201201
if (e.getStatusCode() != 409) {
202202
throw e;
203203
}
204-
LOG.warn("Creating " + bucket + " failed because it was created by another thread or process");
204+
LOG.warn("Creating {} failed because it was created by another thread or process", bucket);
205205
}
206206
}
207207
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/JobState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static AutoCloseableCache<String, WindowedChannelFactory> buildCache(
7373
@Override
7474
public WindowedChannelFactory get(final String key) {
7575
try {
76-
LOG.debug("Opening channel for : " + key);
76+
LOG.debug("Opening channel for: {}", key);
7777
return new WindowedChannelFactory(RangedSeekableByteChannel.wrap(channelBuilder.buildChannel(key), objectRanges.get(key), key));
7878
} catch (final IOException e) {
7979
throw new RuntimeException(e);
@@ -97,7 +97,7 @@ private final class ObjectCompletedListenerImpl implements ObjectCompletedListen
9797
public void objectCompleted(final String name) {
9898
JobState.this.objectsRemaining.decrementAndGet();
9999
try {
100-
LOG.debug("Closing file: " + name);
100+
LOG.debug("Closing file: {}", name);
101101
JobState.this.channelCache.close(name);
102102
} catch (final Exception e) {
103103
throw new RuntimeException(e);

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/ObjectChannelBuilderLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public ObjectChannelBuilderLogger(final Ds3ClientHelpers.ObjectChannelBuilder ch
1717

1818
@Override
1919
public SeekableByteChannel buildChannel(final String s) throws IOException {
20-
LOG.info("Opening channel for" + s);
20+
LOG.info("Opening channel for: {}", s);
2121
return this.channelBuilder.buildChannel(s);
2222
}
2323
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/WriteJobImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public WriteJobImpl(
6464
this.filteredChunks = null;
6565
this.partTracker = null;
6666
} else {
67-
LOG.info("Ready to start transfer for job " + this.masterObjectList.getJobId().toString() + " with "
68-
+ this.masterObjectList.getObjects().size() + " chunks");
67+
LOG.info("Ready to start transfer for job {} with {} chunks",
68+
this.masterObjectList.getJobId().toString(), this.masterObjectList.getObjects().size());
6969
this.filteredChunks = filterChunks(this.masterObjectList.getObjects());
7070
this.partTracker = JobPartTrackerFactory
7171
.buildPartTracker(Iterables.concat(ReadJobImpl.getAllBlobApiBeans(filteredChunks)));
@@ -156,7 +156,7 @@ public void transfer(final ObjectChannelBuilder channelBuilder)
156156
this.maxParallelRequests
157157
);
158158
for (final Objects chunk : filteredChunks) {
159-
LOG.debug("Allocating chunk: " + chunk.getChunkId().toString());
159+
LOG.debug("Allocating chunk: {}", chunk.getChunkId().toString());
160160
chunkTransferrer.transferChunks(
161161
this.masterObjectList.getNodes(),
162162
Collections.singletonList(filterChunk(allocateChunk(chunk))));
@@ -180,7 +180,7 @@ private Objects tryAllocateChunk(final Objects filtered) throws IOException, Sig
180180
final AllocateJobChunkSpectraS3Response response =
181181
this.client.allocateJobChunkSpectraS3(new AllocateJobChunkSpectraS3Request(filtered.getChunkId()));
182182

183-
LOG.info("AllocatedJobChunkResponse status: " + response.getStatus().toString());
183+
LOG.info("AllocatedJobChunkResponse status: {}", response.getStatus().toString());
184184
switch (response.getStatus()) {
185185
case ALLOCATED:
186186
retryAfterLeft = retryAfter; // Reset the number of retries to the initial value
@@ -193,7 +193,7 @@ private Objects tryAllocateChunk(final Objects filtered) throws IOException, Sig
193193
retryAfterLeft--;
194194

195195
final int retryAfter = response.getRetryAfterSeconds() * 1000;
196-
LOG.debug("Will retry allocate chunk call after " + retryAfter + " seconds");
196+
LOG.debug("Will retry allocate chunk call after {} seconds", retryAfter);
197197
Thread.sleep(retryAfter);
198198
return null;
199199
} catch (final InterruptedException e) {
@@ -286,16 +286,16 @@ private PutObjectRequest createRequest(final BulkObject ds3Object) throws IOExce
286286
private String calculateChecksum(final BulkObject ds3Object, final SeekableByteChannel channel) throws IOException {
287287
if (WriteJobImpl.this.checksumType != ChecksumType.Type.NONE) {
288288
if (WriteJobImpl.this.checksumFunction == null) {
289-
LOG.info("Calculating " + WriteJobImpl.this.checksumType.toString() + " checksum for blob: " + ds3Object.toString());
289+
LOG.info("Calculating {} checksum for blob: {}", WriteJobImpl.this.checksumType.toString(), ds3Object.toString());
290290
final SeekableByteChannelInputStream dataStream = new SeekableByteChannelInputStream(channel);
291291
final Hasher hasher = getHasher(WriteJobImpl.this.checksumType);
292292
final String checksum = hashInputStream(hasher, dataStream);
293-
LOG.info("Computed checksum for blob: " + checksum);
293+
LOG.info("Computed checksum for blob: {}", checksum);
294294
return checksum;
295295
} else {
296-
LOG.info("Getting checksum from user supplied callback for blob: " + ds3Object.toString());
296+
LOG.info("Getting checksum from user supplied callback for blob: {}", ds3Object.toString());
297297
final String checksum = WriteJobImpl.this.checksumFunction.compute(ds3Object, channel);
298-
LOG.info("User supplied checksum is: " + checksum);
298+
LOG.info("User supplied checksum is: {}", checksum);
299299
return checksum;
300300
}
301301
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/networking/NetworkClientImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public WebResponse getResponse(final Ds3Request request) throws IOException {
190190
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_TEMPORARY_REDIRECT) {
191191
redirectCount++;
192192
response.close();
193-
LOG.info("Performing retry - attempt: " + redirectCount);
193+
LOG.info("Performing retry - attempt: {}", redirectCount);
194194
}
195195
else {
196196
LOG.info("Got response from server");
@@ -224,7 +224,8 @@ public RequestExecutor(final CloseableHttpClient client, final HttpHost host, fi
224224
throw new RequiresMarkSupportedException();
225225
}
226226

227-
LOG.info("Sending request: " + this.ds3Request.getVerb() + " " + this.host.toString() + "" + this.ds3Request.getPath());
227+
Object[] paramArray = {this.ds3Request.getVerb(), this.host.toString(), this.ds3Request.getPath()};
228+
LOG.info("Sending request: {} {} {}", paramArray );
228229
this.checksumType = ds3Request.getChecksumType();
229230
this.hash = this.buildHash();
230231
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/serializer/XmlOutput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ protected static boolean isProductionBuild() {
7070
return true;
7171
}
7272
else {
73-
LOG.error("Unknown productionBuild value[" + productionBuild + "]. Defaulting to false for unknown XML elements.");
73+
LOG.error("Unknown productionBuild value[{}]. Defaulting to false for unknown XML elements.", productionBuild);
7474
}
7575
} catch (final IOException e) {
76-
LOG.error("Failed to load property file: ", e);
76+
LOG.error("Failed to load property file: {}", e);
7777
}
7878
}
7979

0 commit comments

Comments
 (0)