Skip to content

Commit

Permalink
Merge pull request #545 from pdowler/master
Browse files Browse the repository at this point in the history
minoc: count bytes transferred for fails and in multi-part put
  • Loading branch information
pdowler authored Dec 14, 2023
2 parents 36f9885 + 0312537 commit e1dfb6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion minoc/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
# tags with and without build number so operators use the versioned
# tag but we always keep a timestamped tag in case a semantic tag gets
# replaced accidentally
VER=0.9.9
VER=0.9.10
TAGS="${VER} ${VER}-$(date --utc +"%Y%m%dT%H%M%S")"
unset VER
11 changes: 8 additions & 3 deletions minoc/src/main/java/org/opencadc/minoc/PutAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
package org.opencadc.minoc;

import ca.nrc.cadc.db.TransactionManager;
import ca.nrc.cadc.io.ByteCountInputStream;
import ca.nrc.cadc.io.ByteLimitExceededException;
import ca.nrc.cadc.io.ReadException;
import ca.nrc.cadc.io.WriteException;
Expand Down Expand Up @@ -214,14 +215,16 @@ public void doAction() throws Exception {
StorageMetadata artifactMetadata = null;
long startTime = System.currentTimeMillis();
Long transferTime = null;

if (PUT_TXN_OP_COMMIT.equalsIgnoreCase(txnOP)) {
artifactMetadata = storageAdapter.commitTransaction(txnID);
txnID = null;
profiler.checkpoint("storageAdapter.put.commit.ok");
} else {
log.debug("writing new artifact to " + storageAdapter.getClass().getName());
ByteCountInputStream bcis = new ByteCountInputStream(in);
try {
artifactMetadata = storageAdapter.put(newArtifact, in, txnID);
artifactMetadata = storageAdapter.put(newArtifact, bcis, txnID);
transferTime = System.currentTimeMillis() - startTime;
profiler.checkpoint("storageAdapter.put.write.ok");
} catch (ReadException ex) {
Expand All @@ -242,6 +245,10 @@ public void doAction() throws Exception {
} catch (ByteLimitExceededException | PreconditionFailedException | TransientException ex) {
profiler.checkpoint("storageAdapter.put.write.fail");
throw ex;
} finally {
if (bcis.getByteCount() > 0) {
logInfo.setBytes(bcis.getByteCount());
}
}
log.debug("writing new artifact to " + storageAdapter.getClass().getName() + " OK");
}
Expand Down Expand Up @@ -331,8 +338,6 @@ public void doAction() throws Exception {
syncOutput.setDigest(artifact.getContentChecksum());
syncOutput.setHeader("content-length", 0);

super.logInfo.setBytes(artifact.getContentLength());

// this block could be passed off to a thread so request completes??
if (newOSL != null) {
log.debug("deleting from storage...");
Expand Down

0 comments on commit e1dfb6d

Please sign in to comment.