Skip to content
Snippets Groups Projects
Commit e3b4e187 authored by Costin Grigoras's avatar Costin Grigoras
Browse files

Automatically download missing local files if an AliEn replica exists

parent f9247846
No related branches found
Tags 1.0.19
No related merge requests found
...@@ -112,11 +112,17 @@ public class SQLDownload extends HttpServlet { ...@@ -112,11 +112,17 @@ public class SQLDownload extends HttpServlet {
final String range = request.getHeader("Range"); final String range = request.getHeader("Range");
final File localFile = obj.getLocalFile(false); File localFile = obj.getLocalFile(false);
if (localFile == null) { if (localFile == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "The file cannot be served by this server directly, the physical copy is not on this machine"); // If it has an AliEn replica, and is supposed to be on the local machine then try to bring it to this server and serve it as requested
return; if (obj.replicas.contains(Integer.valueOf(-1)) && AsyncMulticastQueue.stage(obj))
localFile = obj.getLocalFile(false);
if (localFile == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "The file cannot be served by this server directly, the physical copy is not on this machine");
return;
}
} }
if (range == null || range.trim().isEmpty()) { if (range == null || range.trim().isEmpty()) {
...@@ -280,7 +286,9 @@ public class SQLDownload extends HttpServlet { ...@@ -280,7 +286,9 @@ public class SQLDownload extends HttpServlet {
response.setContentLengthLong(contentLength); response.setContentLengthLong(contentLength);
try (RandomAccessFile input = new RandomAccessFile(localFile, "r"); OutputStream output = response.getOutputStream()) { try (
RandomAccessFile input = new RandomAccessFile(localFile, "r");
OutputStream output = response.getOutputStream()) {
final Iterator<Map.Entry<Long, Long>> itRange = requestedRanges.iterator(); final Iterator<Map.Entry<Long, Long>> itRange = requestedRanges.iterator();
final Iterator<String> itSubHeader = subHeaders.iterator(); final Iterator<String> itSubHeader = subHeaders.iterator();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment