Add tracking of blob ids added via direct upload
@@ -236,14 +236,7 @@ public class DataStoreBlobStore
checkNotNull(stream);
DataRecord dr = writeStream(stream, options);
String id = getBlobId(dr);
- if (tracker != null && !InMemoryDataRecord.isInstance(id)) {
- try {
- tracker.add(id);
- log.trace("Tracked Id {}", id);
- } catch (Exception e) {
- log.warn("Could not add track id", e);
- }
- }
+ updateTracker(id);
threw = false;
stats.uploaded(System.nanoTime() - start, TimeUnit.NANOSECONDS, dr.getLength());
stats.uploadCompleted(id);
@@ -257,6 +250,18 @@ public class DataStoreBlobStore
}
}
+ private void updateTracker(String id) {
+ if (tracker != null && !InMemoryDataRecord.isInstance(id)) {
+ try {
+ tracker.add(id);
+ log.trace("Tracked Id {}", id);
+ }
+ catch (Exception e) {
+ log.warn("Could not add track id", e);
+ }
+ }
+ }
+
@Override
public int readBlob(String encodedBlobId, long pos, byte[] buff, int off, int length) throws IOException {
//This is inefficient as repeated calls for same blobId would involve opening new Stream
@@ -724,7 +729,9 @@ public class DataStoreBlobStore
if (delegate instanceof DataRecordAccessProvider) {
try {
DataRecord record = ((DataRecordAccessProvider) delegate).completeDataRecordUpload(uploadToken);
- return new BlobStoreBlob(this, getBlobId(record));
+ String id = getBlobId(record);
+ updateTracker(id);
+ return new BlobStoreBlob(this, id);
}
catch (DataStoreException | DataRecordUploadException e) {
log.warn("Unable to complete direct upload for upload token {}", uploadToken, e);
