use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileDirectory method addFile.
public FileReference addFile(File source) {
try {
Long hash = computeReference(source);
FileReference reference = new FileReference(Long.toHexString(hash));
return addFile(source, reference);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileDirectoryTest method requireThatFileReferenceWithFilesWorks.
@Test
public void requireThatFileReferenceWithFilesWorks() throws IOException {
FileReference foo = createFile("foo");
FileReference bar = createFile("bar");
assertTrue(fileDirectory.getFile(foo).exists());
assertEquals("ea315b7acac56246", foo.value());
assertTrue(fileDirectory.getFile(bar).exists());
assertEquals("2b8e97f15c854e1d", bar.value());
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class BundleLoader method installWithFileDistribution.
private void installWithFileDistribution(List<FileReference> bundlesToInstall, FileAcquirer fileAcquirer) {
for (FileReference reference : bundlesToInstall) {
try {
log.info("Installing bundle with reference '" + reference.value() + "'");
List<Bundle> bundles = obtainBundles(reference, fileAcquirer);
reference2Bundles.put(reference, bundles);
} catch (Exception e) {
throw new RuntimeException("Could not install bundle '" + reference + "'", e);
}
}
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileDistributionRpcServer method getActiveFileReferencesStatus.
@SuppressWarnings({ "UnusedDeclaration" })
public final void getActiveFileReferencesStatus(Request req) {
Map<FileReference, Double> downloadStatus = downloader.downloadStatus();
String[] fileRefArray = new String[downloadStatus.keySet().size()];
fileRefArray = downloadStatus.keySet().stream().map(FileReference::value).collect(Collectors.toList()).toArray(fileRefArray);
double[] downloadStatusArray = new double[downloadStatus.values().size()];
int i = 0;
for (Double d : downloadStatus.values()) {
downloadStatusArray[i++] = d;
}
req.returnValues().add(new StringArray(fileRefArray));
req.returnValues().add(new DoubleArray(downloadStatusArray));
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileDistributionRpcServer method downloadFile.
private void downloadFile(Request req) {
FileReference fileReference = new FileReference(req.parameters().get(0).asString());
log.log(LogLevel.DEBUG, () -> "getFile() called for file reference '" + fileReference.value() + "'");
Optional<File> pathToFile = downloader.getFile(fileReference);
try {
if (pathToFile.isPresent()) {
req.returnValues().add(new StringValue(pathToFile.get().getAbsolutePath()));
log.log(LogLevel.DEBUG, () -> "File reference '" + fileReference.value() + "' available at " + pathToFile.get());
} else {
log.log(LogLevel.INFO, "File reference '" + fileReference.value() + "' not found, returning error");
req.setError(fileReferenceDoesNotExists, "File reference '" + fileReference.value() + "' not found");
}
} catch (Throwable e) {
log.log(LogLevel.WARNING, "File reference '" + fileReference.value() + "' got exception: " + e.getMessage());
req.setError(fileReferenceInternalError, "File reference '" + fileReference.value() + "' removed");
}
req.returnRequest();
}
Aggregations