Skip to content

Commit

Permalink
Merge pull request #32215 from vespa-engine/hmusum/handle-filereferen…
Browse files Browse the repository at this point in the history
…ce-not-found-as-temporary-error

Handle file reference not found as a temporary error
  • Loading branch information
Harald Musum authored Aug 22, 2024
2 parents 491ba3b + 099a173 commit 6cb5d73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void declareMethods() {
private static final int baseErrorCode = 0x10000;
private static final int baseFileProviderErrorCode = baseErrorCode + 0x1000;

private static final int fileReferenceDoesNotExists = baseFileProviderErrorCode;
private static final int fileReferenceNotFound = baseFileProviderErrorCode;

private void getFile(Request req) {
req.detach();
Expand Down Expand Up @@ -112,8 +112,8 @@ private void downloadFile(Request req) {
req.returnValues().add(new StringValue(file.get().getAbsolutePath()));
log.log(Level.FINE, () -> "File reference '" + fileReference.value() + "' available at " + file.get());
} else {
log.log(Level.INFO, "File reference '" + fileReference.value() + "' not found, returning error");
req.setError(fileReferenceDoesNotExists, "File reference '" + fileReference.value() + "' not found");
log.log(Level.INFO, "File reference '" + fileReference.value() + "' not found");
req.setError(fileReferenceNotFound, "File reference '" + fileReference.value() + "' not found");
}

req.returnRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package com.yahoo.filedistribution.fileacquirer;

import com.yahoo.config.FileReference;
import com.yahoo.jrt.ErrorCode;
import com.yahoo.jrt.Request;
import com.yahoo.jrt.Spec;
import com.yahoo.jrt.StringValue;
Expand All @@ -19,6 +18,12 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.yahoo.filedistribution.fileacquirer.FileAcquirerImpl.FileDistributionErrorCode.fileReferenceNotFound;
import static com.yahoo.jrt.ErrorCode.ABORT;
import static com.yahoo.jrt.ErrorCode.CONNECTION;
import static com.yahoo.jrt.ErrorCode.GENERAL_ERROR;
import static com.yahoo.jrt.ErrorCode.OVERLOAD;
import static com.yahoo.jrt.ErrorCode.TIMEOUT;
import static com.yahoo.net.HostName.getLocalhost;

/**
Expand All @@ -36,7 +41,7 @@ static final class FileDistributionErrorCode {

public static final int baseErrorCode = 0x10000;
public static final int baseFileProviderErrorCode = baseErrorCode + 0x1000;
public static final int fileReferenceDoesNotExists = baseFileProviderErrorCode;
public static final int fileReferenceNotFound = baseFileProviderErrorCode;

}

Expand Down Expand Up @@ -113,7 +118,7 @@ public Target getTarget(Timer timer) throws InterruptedException {

private boolean temporaryError(int errorCode) {
return switch (errorCode) {
case ErrorCode.ABORT, ErrorCode.CONNECTION, ErrorCode.GENERAL_ERROR, ErrorCode.OVERLOAD, ErrorCode.TIMEOUT -> true;
case ABORT, CONNECTION, GENERAL_ERROR, OVERLOAD, TIMEOUT, fileReferenceNotFound -> true;
default -> false;
};
}
Expand Down Expand Up @@ -152,10 +157,7 @@ public File waitFor(FileReference fileReference, long timeout, TimeUnit timeUnit
log.log(Level.INFO, "Retrying waitFor for " + fileReference + ": " + request.errorCode() + " -- " + request.errorMessage());
Thread.sleep(1000);
} else {
if (request.errorCode() == FileDistributionErrorCode.fileReferenceDoesNotExists)
throw new FileReferenceDoesNotExistException(fileReference.value());
else
throw new RuntimeException("Wait for " + fileReference + " failed: " + request.errorMessage() + " (" + request.errorCode() + ")");
throw new RuntimeException("Wait for " + fileReference + " failed: " + request.errorMessage() + " (" + request.errorCode() + ")");
}
} while ( timer.isTimeLeft() );

Expand Down

0 comments on commit 6cb5d73

Please sign in to comment.