use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileReferenceDownloader method addToDownloadQueue.
void addToDownloadQueue(FileReferenceDownload fileReferenceDownload) {
FileReference fileReference = fileReferenceDownload.fileReference();
log.log(LogLevel.DEBUG, () -> "Will download file reference '" + fileReference.value() + "' with timeout " + downloadTimeout);
synchronized (downloads) {
downloads.put(fileReference, fileReferenceDownload);
downloadStatus.put(fileReference, 0.0);
}
downloadExecutor.submit(() -> startDownload(downloadTimeout, fileReferenceDownload));
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileReferenceDataTest method testLargerDataBlob.
@Test
public void testLargerDataBlob() {
String content = "blobbblubbblabb";
FileReferenceData fileReferenceData = new FileReferenceDataBlob(new FileReference("ref"), "foo", FileReferenceData.Type.compressed, Utf8.toBytes(content));
ByteBuffer byteBuffer = ByteBuffer.allocate(10);
assertEquals(10, fileReferenceData.nextContent(byteBuffer));
assertEquals(content.substring(0, 10), Utf8.toString(Arrays.copyOfRange(byteBuffer.array(), 0, 10)));
byteBuffer.flip();
assertEquals(5, fileReferenceData.nextContent(byteBuffer));
assertEquals(content.substring(10, 15), Utf8.toString(Arrays.copyOfRange(byteBuffer.array(), 0, 5)));
// nextContent() will always return everything for FileReferenceDataBlob, so nothing more should be read
assertEquals(-1, fileReferenceData.nextContent(byteBuffer));
}
Aggregations