Search in sources :

Example 1 with Connection

use of com.yahoo.vespa.config.Connection in project vespa by vespa-engine.

the class FileReferenceDownloader method startDownloadRpc.

private boolean startDownloadRpc(FileReferenceDownload fileReferenceDownload) {
    Connection connection = connectionPool.getCurrent();
    Request request = new Request("filedistribution.serveFile");
    String fileReference = fileReferenceDownload.fileReference().value();
    request.parameters().add(new StringValue(fileReference));
    request.parameters().add(new Int32Value(fileReferenceDownload.downloadFromOtherSourceIfNotFound() ? 0 : 1));
    execute(request, connection);
    if (validateResponse(request)) {
        log.log(LogLevel.DEBUG, () -> "Request callback, OK. Req: " + request + "\nSpec: " + connection);
        if (request.returnValues().get(0).asInt32() == 0) {
            log.log(LogLevel.DEBUG, () -> "Found file reference '" + fileReference + "' available at " + connection.getAddress());
            return true;
        } else {
            log.log(LogLevel.DEBUG, "File reference '" + fileReference + "' not found for " + connection.getAddress());
            connectionPool.setNewCurrentConnection();
            return false;
        }
    } else {
        log.log(LogLevel.DEBUG, "Request failed. Req: " + request + "\nSpec: " + connection.getAddress() + ", error code: " + request.errorCode() + ", set error for connection and use another for next request");
        connectionPool.setError(connection, request.errorCode());
        return false;
    }
}
Also used : Connection(com.yahoo.vespa.config.Connection) Request(com.yahoo.jrt.Request) Int32Value(com.yahoo.jrt.Int32Value) StringValue(com.yahoo.jrt.StringValue)

Aggregations

Int32Value (com.yahoo.jrt.Int32Value)1 Request (com.yahoo.jrt.Request)1 StringValue (com.yahoo.jrt.StringValue)1 Connection (com.yahoo.vespa.config.Connection)1