use of com.yahoo.jrt.Int32Value in project vespa by vespa-engine.
the class FileDistributionRpcServer method setFileReferencesToDownload.
@SuppressWarnings({ "UnusedDeclaration" })
public final void setFileReferencesToDownload(Request req) {
Arrays.stream(req.parameters().get(0).asStringArray()).map(FileReference::new).forEach(fileReference -> downloader.queueForAsyncDownload(new FileReferenceDownload(fileReference)));
req.returnValues().add(new Int32Value(0));
}
use of com.yahoo.jrt.Int32Value in project vespa by vespa-engine.
the class FileReceiver method receiveFilePart.
@SuppressWarnings({ "UnusedDeclaration" })
public final void receiveFilePart(Request req) {
log.log(LogLevel.DEBUG, () -> "Received method call '" + req.methodName() + "' with parameters : " + req.parameters());
FileReference reference = new FileReference(req.parameters().get(0).asString());
int sessionId = req.parameters().get(1).asInt32();
int partId = req.parameters().get(2).asInt32();
byte[] part = req.parameters().get(3).asData();
Session session = getSession(sessionId);
int retval = verifySession(session, sessionId, reference);
try {
session.addPart(partId, part);
} catch (Exception e) {
log.severe("Got exception " + e);
retval = 1;
}
double completeness = (double) session.currentFileSize / (double) session.fileSize;
log.log(LogLevel.DEBUG, () -> String.format("%.1f percent of '%s' downloaded", completeness * 100, reference.value()));
downloader.setDownloadStatus(reference, completeness);
req.returnValues().add(new Int32Value(retval));
}
use of com.yahoo.jrt.Int32Value in project vespa by vespa-engine.
the class FileReceiver method receiveFileMeta.
@SuppressWarnings({ "UnusedDeclaration" })
public final void receiveFileMeta(Request req) {
log.log(LogLevel.DEBUG, () -> "Received method call '" + req.methodName() + "' with parameters : " + req.parameters());
FileReference reference = new FileReference(req.parameters().get(0).asString());
String fileName = req.parameters().get(1).asString();
String type = req.parameters().get(2).asString();
long fileSize = req.parameters().get(3).asInt64();
int sessionId = nextSessionId.getAndIncrement();
int retval = 0;
synchronized (sessions) {
if (sessions.containsKey(sessionId)) {
retval = 1;
log.severe("Session id " + sessionId + " already exist, impossible. Request from(" + req.target() + ")");
} else {
try {
sessions.put(sessionId, new Session(downloadDirectory, tmpDirectory, sessionId, reference, FileReferenceData.Type.valueOf(type), fileName, fileSize));
} catch (Exception e) {
retval = 1;
}
}
}
req.returnValues().add(new Int32Value(retval));
req.returnValues().add(new Int32Value(sessionId));
}
Aggregations