use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method testApplicationFile.
@Test
public void testApplicationFile() throws Exception {
Path p1 = Path.fromString("foo/bar/baz");
ApplicationFile f1 = getApplicationFile(p1);
ApplicationFile f2 = getApplicationFile(p1);
assertThat(f1.getPath(), is(p1));
assertThat(f2.getPath(), is(p1));
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method getGetMetaPath.
@Test
public void getGetMetaPath() throws Exception {
ApplicationFile file = getApplicationFile(Path.fromString("file1.txt"));
assertThat(file.getMetaPath().toString(), is(".meta/file1.txt"));
file = getApplicationFile(Path.fromString("dir/file1.txt"));
assertThat(file.getMetaPath().toString(), is("dir/.meta/file1.txt"));
file = getApplicationFile(Path.fromString("dir"));
assertThat(file.getMetaPath().toString(), is(".meta/dir"));
file = getApplicationFile(Path.fromString(""));
assertThat(file.getMetaPath().toString(), is(".meta/.root"));
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method testApplicationFileCanBeDeleted.
@Test
public void testApplicationFileCanBeDeleted() throws Exception {
ApplicationFile file = getApplicationFile(Path.fromString("file1.txt"));
file.writeFile(new StringReader("file1"));
assertThat(file.getPath().getName(), is("file1.txt"));
file.delete();
assertFalse(file.exists());
assertFalse(file.isDirectory());
List<ApplicationFile> files = file.listFiles(true);
assertTrue(files.isEmpty());
file = getApplicationFile(Path.fromString("subdir/file2.txt"));
file.writeFile(new StringReader("file2"));
assertThat(file.getPath().getName(), is("file2.txt"));
file.delete();
assertFalse(file.exists());
assertFalse(file.isDirectory());
files = file.listFiles(true);
assertTrue(files.isEmpty());
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ConfigModelRepo method getPermanentServices.
private Collection<Element> getPermanentServices(DeployState deployState) throws IOException, SAXException {
List<Element> permanentServices = new ArrayList<>();
Optional<ApplicationPackage> applicationPackage = deployState.getPermanentApplicationPackage();
if (applicationPackage.isPresent()) {
ApplicationFile file = applicationPackage.get().getFile(Path.fromString(ApplicationPackage.PERMANENT_SERVICES));
if (file.exists()) {
try (Reader reader = file.createReader()) {
Element permanentServicesRoot = getServicesFromReader(reader);
permanentServices.addAll(getServiceElements(permanentServicesRoot));
}
}
}
return permanentServices;
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class RankingConstantsValidator method validateRankingConstant.
private void validateRankingConstant(RankingConstant rankingConstant, ApplicationPackage application) throws FileNotFoundException {
// TODO: Handle validation of URI soon too.
if (rankingConstant.getPathType() == RankingConstant.PathType.FILE) {
String constantFile = rankingConstant.getFileName();
if (application.getFileReference(Path.fromString("")).getAbsolutePath().endsWith(FilesApplicationPackage.preprocessed) && constantFile.startsWith(FilesApplicationPackage.preprocessed)) {
constantFile = constantFile.substring(FilesApplicationPackage.preprocessed.length());
}
ApplicationFile tensorApplicationFile = application.getFile(Path.fromString(constantFile));
new ConstantTensorJsonValidator().validate(constantFile, rankingConstant.getTensorType(), tensorApplicationFile.createReader());
}
}
Aggregations