Search in sources :

Example 11 with Int32Value

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));
}
Also used : Int32Value(com.yahoo.jrt.Int32Value)

Example 12 with Int32Value

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));
}
Also used : Int32Value(com.yahoo.jrt.Int32Value) FileReference(com.yahoo.config.FileReference) IOException(java.io.IOException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 13 with Int32Value

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));
}
Also used : Int32Value(com.yahoo.jrt.Int32Value) FileReference(com.yahoo.config.FileReference) IOException(java.io.IOException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Aggregations

Int32Value (com.yahoo.jrt.Int32Value)13 Request (com.yahoo.jrt.Request)6 StringValue (com.yahoo.jrt.StringValue)5 FileReference (com.yahoo.config.FileReference)4 DataValue (com.yahoo.jrt.DataValue)4 Int8Value (com.yahoo.jrt.Int8Value)4 Compressor (com.yahoo.compress.Compressor)2 Values (com.yahoo.jrt.Values)2 Cursor (com.yahoo.slime.Cursor)2 Slime (com.yahoo.slime.Slime)2 NodeState (com.yahoo.vdslib.state.NodeState)2 FileReferenceDownload (com.yahoo.vespa.filedistribution.FileReferenceDownload)2 IOException (java.io.IOException)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 Int64Value (com.yahoo.jrt.Int64Value)1 ListenFailedException (com.yahoo.jrt.ListenFailedException)1 Spec (com.yahoo.jrt.Spec)1 StringArray (com.yahoo.jrt.StringArray)1 Supervisor (com.yahoo.jrt.Supervisor)1 Target (com.yahoo.jrt.Target)1