Skip to content

Commit f1d7e99

Browse files
committed
Merge pull request #73 from rpmoore/master
Adding logging around various conditions in the helper functions
2 parents f337ef3 + fbd5c9b commit f1d7e99

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.spectralogic.ds3client.models.bulk.Node;
2525
import com.spectralogic.ds3client.models.bulk.Objects;
2626
import com.spectralogic.ds3client.serializer.XmlProcessingException;
27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729

2830
import java.io.IOException;
2931
import java.security.SignatureException;
@@ -33,6 +35,7 @@
3335
import java.util.concurrent.Executors;
3436

3537
class ChunkTransferrer {
38+
private final static Logger LOG = LoggerFactory.getLogger(ChunkTransferrer.class);
3639
private final ItemTransferrer itemTransferrer;
3740
private final Ds3Client mainClient;
3841
private final JobPartTracker partTracker;
@@ -57,18 +60,24 @@ public void transferChunks(
5760
final Iterable<Node> nodes,
5861
final Iterable<Objects> chunks)
5962
throws SignatureException, IOException, XmlProcessingException {
63+
LOG.debug("Getting ready to process chunks");
6064
final Map<UUID, Node> nodeMap = buildNodeMap(nodes);
65+
LOG.debug("Starting executor service");
6166
final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(maxParallelRequests));
67+
LOG.debug("Executor service started");
6268
try {
6369
final List<ListenableFuture<?>> tasks = new ArrayList<>();
6470
for (final Objects chunk : chunks) {
71+
LOG.debug("Processing parts for chunk: " + chunk.getChunkId().toString());
6572
final Ds3Client client = mainClient.newForNode(nodeMap.get(chunk.getNodeId()));
6673
for (final BulkObject ds3Object : chunk) {
6774
final ObjectPart part = new ObjectPart(ds3Object.getOffset(), ds3Object.getLength());
6875
if (this.partTracker.containsPart(ds3Object.getName(), part)) {
76+
LOG.debug("Adding " + ds3Object.getName() + " to executor for processing");
6977
tasks.add(executor.submit(new Callable<Object>() {
7078
@Override
7179
public Object call() throws Exception {
80+
LOG.debug("Processing " + ds3Object.getName());
7281
ChunkTransferrer.this.itemTransferrer.transferItem(client, ds3Object);
7382
ChunkTransferrer.this.partTracker.completePart(ds3Object.getName(), part);
7483
return null;
@@ -79,6 +88,7 @@ public Object call() throws Exception {
7988
}
8089
executeWithExceptionHandling(tasks);
8190
} finally {
91+
LOG.debug("Shutting down executor");
8292
executor.shutdown();
8393
}
8494
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.io.IOException;
3232
import java.security.SignatureException;
3333
import java.util.ArrayList;
34-
import java.util.Arrays;
3534
import java.util.Collections;
3635
import java.util.List;
3736

@@ -41,11 +40,13 @@ public WriteJobImpl(
4140
final Ds3Client client,
4241
final MasterObjectList masterObjectList) {
4342
super(client, masterObjectList);
43+
LOG.info("Ready to start transfer for job " + masterObjectList.getJobId().toString() + " with " + masterObjectList.getObjects().size() + " chunks");
4444
}
4545

4646
@Override
4747
public void transfer(final ObjectChannelBuilder channelBuilder)
4848
throws SignatureException, IOException, XmlProcessingException {
49+
LOG.debug("Starting job transfer");
4950
final List<Objects> filteredChunks = filterChunks(this.masterObjectList.getObjects());
5051
try (final JobState jobState = new JobState(channelBuilder, filteredChunks)) {
5152
final ChunkTransferrer chunkTransferrer = new ChunkTransferrer(
@@ -55,6 +56,7 @@ public void transfer(final ObjectChannelBuilder channelBuilder)
5556
this.maxParallelRequests
5657
);
5758
for (final Objects chunk : filteredChunks) {
59+
LOG.debug("Allocating chunk: " + chunk.getChunkId().toString());
5860
chunkTransferrer.transferChunks(this.masterObjectList.getNodes(), Collections.singletonList(filterChunk(allocateChunk(chunk))));
5961
}
6062
} catch (final SignatureException | IOException | XmlProcessingException | RuntimeException e) {
@@ -75,12 +77,16 @@ private Objects allocateChunk(final Objects filtered) throws IOException, Signat
7577
private Objects tryAllocateChunk(final Objects filtered) throws IOException, SignatureException {
7678
final AllocateJobChunkResponse response =
7779
this.client.allocateJobChunk(new AllocateJobChunkRequest(filtered.getChunkId()));
80+
81+
LOG.info("AllocatedJobChunkResponse status: " + response.getStatus().toString());
7882
switch (response.getStatus()) {
7983
case ALLOCATED:
8084
return response.getObjects();
8185
case RETRYLATER:
8286
try {
83-
Thread.sleep(response.getRetryAfterSeconds() * 1000);
87+
final int retryAfter = response.getRetryAfterSeconds() * 1000;
88+
LOG.debug("Will retry allocate chunk call after " + retryAfter + " seconds");
89+
Thread.sleep(retryAfter);
8490
return null;
8591
} catch (final InterruptedException e) {
8692
throw new RuntimeException(e);

0 commit comments

Comments
 (0)