Skip to content

Commit

Permalink
Basic CR-NAS-399 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
petchris committed Jan 26, 2021
1 parent c782cd4 commit 55db287
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import dk.netarkivet.common.distribute.bitrepository.BitmagUtils;

import dk.netarkivet.common.distribute.bitrepository.action.putfile.PutFileAction; // ?
import dk.netarkivet.common.distribute.bitrepository.action.putfile.PutFileAction;

import dk.netarkivet.common.exceptions.ArgumentNotValid;
import dk.netarkivet.common.exceptions.IOFailure;
Expand Down Expand Up @@ -86,9 +86,6 @@ public class BitmagArcRepositoryClient extends Synchronizer implements ArcReposi
/** Listens on this queue for replies. */
private final ChannelID replyQ;

/** The length of time to wait for a get reply before giving up. */
private long timeoutGetOpsMillis;

// NOTE: The constants defining setting names below are left non-final on
// purpose! Otherwise, the static initialiser that loads default values
// will not run.
Expand Down Expand Up @@ -179,15 +176,6 @@ private BitmagArcRepositoryClient() {
}
}

timeoutGetOpsMillis = Settings.getLong(ARCREPOSITORY_GET_TIMEOUT);

log.info(
"BitmagArcRepositoryClient will timeout on each getrequest after {} milliseconds.",
timeoutGetOpsMillis);
replyQ = Channels.getThisReposClient();
JMSConnectionFactory.getInstance().setListener(replyQ, this);
log.info("BitmagArcRepositoryClient listens for replies on channel '{}'", replyQ);

File configDir = Settings.getFile(BITREPOSITORY_SETTINGS_DIR);
log.info("Getting bitmag config from " + BITREPOSITORY_SETTINGS_DIR + "=" + configDir.getAbsolutePath());

Expand Down Expand Up @@ -237,11 +225,12 @@ public static synchronized BitmagArcRepositoryClient getInstance() {

@Override
public synchronized void close() {
JMSConnectionFactory.getInstance().removeListener(replyQ, this);
// JMSConnectionFactory.getInstance().removeListener(replyQ, this);
/* if (bitrep != null) {
bitrep.shutdown();
}
*/
BitmagUtils.shudown();
instance = null;
}

Expand Down Expand Up @@ -356,7 +345,10 @@ protected void error(String errMsg) {
* @return The status of the batch job after it ended.
*/
public BatchStatus batch(FileBatchJob job, String replicaId, String... args) {
return batch(job, replicaId, "", args);
String msg = "Batch is no longer used";
log.warn(msg);
// return batch(job, replicaId, "", args);
return null;
}

/**
Expand All @@ -375,7 +367,7 @@ public BatchStatus batch(FileBatchJob job, String replicaId, String... args) {
*/
public BatchStatus batch(FileBatchJob job, String replicaId, String batchId, String... args) throws IOFailure,
ArgumentNotValid {
ArgumentNotValid.checkNotNull(job, "FileBatchJob job");
/* ArgumentNotValid.checkNotNull(job, "FileBatchJob job");
ArgumentNotValid.checkNotNullOrEmpty(replicaId, "String replicaId");
log.debug("Starting batchjob '{}' running on replica '{}'", job, replicaId);
Expand All @@ -392,6 +384,11 @@ public BatchStatus batch(FileBatchJob job, String replicaId, String batchId, Str
}
return new BatchStatus(brMsg.getFilesFailed(), brMsg.getNoOfFilesProcessed(), brMsg.getResultFile(),
job.getExceptions());
*/

String msg = "Batch is no longer used";
log.warn(msg);
return null;
}

/**
Expand Down Expand Up @@ -461,7 +458,7 @@ public File correct(String replicaId, String checksum, File file, String credent


/**
* Attempts to upload a given file. NEW
* Attempts to upload a given file.
*
* @param file The file to upload. Should exist. The packageId is the name of the file
* @param collectionId The Id of the collection to upload to
Expand All @@ -477,7 +474,6 @@ public boolean uploadFile(final File file, final String fileId, final String col
return false;
}
boolean success = false;
URL url = null;
try {
log.info("Calling this.putTheFile...");

Expand All @@ -493,8 +489,8 @@ public boolean uploadFile(final File file, final String fileId, final String col
log.warn("Upload of file '{}' failed ", file.getAbsolutePath());
}
} catch (Exception e) {
log.warn("Unexpected error while storing file '{}'", file.getAbsolutePath(), e);
success = false;
log.warn("Unexpected error while storing file '{}'", file.getAbsolutePath(), e);
success = false;
}
return success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ public class PutFileAction implements ClientAction {
private final File targetFile;
private boolean actionIsSuccess;

/* public OperationEvent.OperationEventType getFinalEvent() {
return finalEvent;
}
private static OperationEvent.OperationEventType finalEvent; // static?
*/
/**
* Constructor to instantiate the put-file action
* @param client The client to perform the action on
Expand All @@ -61,7 +55,6 @@ public void performAction() {

ChecksumDataForFileTYPE checksumData = BitmagUtils.getValidationChecksum(targetFile,
BitmagUtils.getChecksumSpec(ChecksumType.MD5));

client.putFile(collectionID, url, fileID, targetFile.length(), checksumData, null,
eventHandler, "PutFile from NAS");
eventHandler.waitForFinish();
Expand All @@ -70,7 +63,6 @@ public void performAction() {
if (actionIsSuccess) {
log.info("Put operation was a success! Put file '{}' to bitmag with id: '{}'.",
targetFile.getName(), fileID);
// finalEvent = eventHandler.getFinalEvent();
} else {
log.warn("Failed put operation for file '{}'.", targetFile.getName());
}
Expand Down

0 comments on commit 55db287

Please sign in to comment.