summaryrefslogtreecommitdiffstats
path: root/config-proxy
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-11-14 14:38:23 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-11-14 14:51:27 +0100
commitd2953453e8018cd0cae22afb8e3b2afa99c4b63b (patch)
treefa010b1e7c790ec961876482126f2307d4edfbeb /config-proxy
parent3c2a0964ff6b1caed437fba425c40467560b3c37 (diff)
Add receive files chunked skeleton.
Diffstat (limited to 'config-proxy')
-rw-r--r--config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java52
1 files changed, 46 insertions, 6 deletions
diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java
index faf0e186fb3..7c3133ea69d 100644
--- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java
+++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java
@@ -15,11 +15,17 @@ import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
import java.util.logging.Logger;
public class FileReceiver {
private final static Logger log = Logger.getLogger(FileReceiver.class.getName());
+ private final static String RECEIVE_METHOD = "filedistribution.receiveFile";
+ private final static String RECEIVE_META_METHOD = "filedistribution.receiveFileMeta";
+ private final static String RECEIVE_PART_METHOD = "filedistribution.receiveFilePart";
+ private final static String RECEIVE_EOF_METHOD = "filedistribution.receiveFileEof";
private final Supervisor supervisor;
private final FileReferenceDownloader downloader;
@@ -34,22 +40,44 @@ public class FileReceiver {
}
private void registerMethods() {
- supervisor.addMethod(receiveFileMethod(this));
+ receiveFileMethod(this).forEach((method) -> supervisor.addMethod(method));
}
// Defined here so that it can be added to supervisor used by client (server will use same connection when calling
// receiveFile after getting a serveFile method call). handler needs to implement receiveFile method
- private Method receiveFileMethod(Object handler) {
- return new Method("filedistribution.receiveFile", "ssxlis", "i", // TODO Temporary method to get started with testing
- handler, "receiveFile")
+ private List<Method> receiveFileMethod(Object handler) {
+ List<Method> methods = new ArrayList<>();
+ methods.add(new Method(RECEIVE_META_METHOD, "ssl", "ii", handler,"receiveFileMeta")
+ .paramDesc(0, "filereference", "file reference to download")
+ .paramDesc(1, "filename", "filename")
+ .paramDesc(2, "filelength", "length in bytes of file")
+ .returnDesc(0, "ret", "0 if success, 1 otherwise")
+ .returnDesc(1, "session-id", "Session id to be used for this transfer"));
+ methods.add(new Method(RECEIVE_PART_METHOD, "siix", "i", handler,"receiveFilePart")
+ .paramDesc(0, "filereference", "file reference to download")
+ .paramDesc(1, "session-id", "Session id to be used for this transfer")
+ .paramDesc(2, "partid", "relative part number starting at zero")
+ .paramDesc(3, "data", "bytes in this part")
+ .returnDesc(0, "ret", "0 if success, 1 otherwise"));
+ methods.add(new Method(RECEIVE_EOF_METHOD, "siilis", "i", handler,"receiveFileEof")
+ .paramDesc(0, "filereference", "file reference to download")
+ .paramDesc(1, "session-id", "Session id to be used for this transfer")
+ .paramDesc(2, "partid", "relative part number starting at zero")
+ .paramDesc(3, "crc-code", "crc code (xxhash64)")
+ .paramDesc(4, "error-code", "Error code. 0 if none")
+ .paramDesc(5, "error-description", "Error description.")
+ .returnDesc(0, "ret", "0 if success, 1 if crc mismatch, 2 otherwise"));
+ // Temporary method until we have chunking
+ methods.add(new Method(RECEIVE_METHOD, "ssxlis", "i", handler, "receiveFile")
.methodDesc("receive file reference content")
- .paramDesc(0, "file references", "file reference to download")
+ .paramDesc(0, "file reference", "file reference to download")
.paramDesc(1, "filename", "filename")
.paramDesc(2, "content", "array of bytes")
.paramDesc(3, "hash", "xx64hash of the file content")
.paramDesc(4, "errorcode", "Error code. 0 if none")
.paramDesc(5, "error-description", "Error description.")
- .returnDesc(0, "ret", "0 if success, 1 otherwise");
+ .returnDesc(0, "ret", "0 if success, 1 otherwise"));
+ return methods;
}
@SuppressWarnings({"UnusedDeclaration"})
@@ -91,4 +119,16 @@ public class FileReceiver {
}
}
+ @SuppressWarnings({"UnusedDeclaration"})
+ public final void receiveFileMeta(Request req) {
+ log.info("Received method call '" + req.methodName() + "' with parameters : " + req.parameters());
+ }
+ @SuppressWarnings({"UnusedDeclaration"})
+ public final void receiveFilePart(Request req) {
+ log.info("Received method call '" + req.methodName() + "' with parameters : " + req.parameters());
+ }
+ @SuppressWarnings({"UnusedDeclaration"})
+ public final void receiveFileEof(Request req) {
+ log.info("Received method call '" + req.methodName() + "' with parameters : " + req.parameters());
+ }
}