use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileDownloader method queueForAsyncDownload.
public synchronized Future<Optional<File>> queueForAsyncDownload(FileReferenceDownload fileReferenceDownload, Duration timeout) {
FileReference fileReference = fileReferenceDownload.fileReference();
Future<Optional<File>> inProgress = fileReferenceDownloader.addDownloadListener(fileReference, () -> getFile(fileReferenceDownload));
if (inProgress != null) {
log.log(LogLevel.DEBUG, () -> "Already downloading '" + fileReference.value() + "'");
return inProgress;
}
Future<Optional<File>> future = queueForAsyncDownload(fileReferenceDownload);
log.log(LogLevel.DEBUG, () -> "Queued '" + fileReference.value() + "' for download with timeout " + timeout);
return future;
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileReceiverTest method receiveCompressedParts.
@Test
public void receiveCompressedParts() throws IOException {
File dirWithFiles = temporaryFolder.newFolder("files");
FileWriter writerA = new FileWriter(new File(dirWithFiles, "a"));
writerA.write("1");
writerA.close();
FileWriter writerB = new FileWriter(new File(dirWithFiles, "b"));
writerB.write("2");
writerB.close();
byte[] data = CompressedFileReference.compress(dirWithFiles);
transferCompressedData(new FileReference("ref"), "a", data);
File downloadDir = new File(root, "ref");
assertEquals("1", IOUtils.readFile(new File(downloadDir, "a")));
assertEquals("2", IOUtils.readFile(new File(downloadDir, "b")));
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class FileReceiverTest method receiveMultiPartFile.
@Test
public void receiveMultiPartFile() throws IOException {
String[] parts = new String[3];
parts[0] = "first part\n";
parts[1] = "second part\n";
parts[2] = "third part\n";
StringBuilder sb = new StringBuilder();
for (String s : parts) {
sb.append(s);
}
String all = sb.toString();
transferPartsAndAssert(new FileReference("ref-a"), "myfile-1", all, 1);
transferPartsAndAssert(new FileReference("ref-a"), "myfile-2", all, 2);
transferPartsAndAssert(new FileReference("ref-a"), "myfile-3", all, 3);
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class BundleLoader method retainOnly.
/**
* Returns the number of uninstalled bundles
*/
private int retainOnly(List<FileReference> newReferences) {
Set<Bundle> bundlesToRemove = new HashSet<>(Arrays.asList(osgi.getBundles()));
for (FileReference fileReferenceToKeep : newReferences) {
if (reference2Bundles.containsKey(fileReferenceToKeep))
bundlesToRemove.removeAll(reference2Bundles.get(fileReferenceToKeep));
}
bundlesToRemove.removeAll(initialBundles);
for (Bundle bundle : bundlesToRemove) {
log.info("Removing bundle '" + bundle.toString() + "'");
osgi.uninstall(bundle);
}
Set<FileReference> fileReferencesToRemove = new HashSet<>(reference2Bundles.keySet());
fileReferencesToRemove.removeAll(newReferences);
for (FileReference fileReferenceToRemove : fileReferencesToRemove) {
reference2Bundles.remove(fileReferenceToRemove);
}
return bundlesToRemove.size();
}
use of com.yahoo.config.FileReference in project vespa by vespa-engine.
the class ContainerTestBase method complete.
public void complete() {
try {
Container container = new Container(new CloudSubscriberFactory(dirConfigSource().configSource()), dirConfigSource().configId(), new ContainerTest.TestDeconstructor(), new Osgi() {
@SuppressWarnings("unchecked")
@Override
public Class<Object> resolveClass(BundleInstantiationSpecification spec) {
try {
return (Class<Object>) Class.forName(spec.classId.getName());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public BundleClasses getBundleClasses(ComponentSpecification bundle, Set<String> packagesToScan) {
throw new UnsupportedOperationException("getBundleClasses not supported");
}
@Override
public void useBundles(Collection<FileReference> bundles) {
}
@Override
public Bundle getBundle(ComponentSpecification spec) {
throw new UnsupportedOperationException("getBundle not supported.");
}
});
componentGraph = container.runOnce(componentGraph, Guice.createInjector());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations