Search in sources :

Example 36 with FileReference

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

Example 37 with FileReference

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));
}
Also used : FileReference(com.yahoo.config.FileReference) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

FileReference (com.yahoo.config.FileReference)37 Test (org.junit.Test)10 File (java.io.File)9 Int32Value (com.yahoo.jrt.Int32Value)4 IOException (java.io.IOException)3 Bundle (org.osgi.framework.Bundle)3 StringValue (com.yahoo.jrt.StringValue)2 CompressedFileReference (com.yahoo.vespa.filedistribution.CompressedFileReference)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ByteBuffer (java.nio.ByteBuffer)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 Optional (java.util.Optional)2 ComponentSpecification (com.yahoo.component.ComponentSpecification)1 ConfigBuilder (com.yahoo.config.ConfigBuilder)1 ComponentInfo (com.yahoo.config.application.api.ComponentInfo)1 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)1 UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)1 MockHosts (com.yahoo.config.model.test.MockHosts)1 BundleInstantiationSpecification (com.yahoo.container.bundle.BundleInstantiationSpecification)1 CloudSubscriberFactory (com.yahoo.container.di.CloudSubscriberFactory)1