Search in sources :

Example 1 with ApplicationFile

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));
}
Also used : Path(com.yahoo.path.Path) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Test(org.junit.Test)

Example 2 with ApplicationFile

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"));
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Test(org.junit.Test)

Example 3 with ApplicationFile

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());
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Test(org.junit.Test)

Example 4 with ApplicationFile

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;
}
Also used : Element(org.w3c.dom.Element) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Reader(java.io.Reader) StringReader(java.io.StringReader) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Example 5 with ApplicationFile

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

Aggregations

ApplicationFile (com.yahoo.config.application.api.ApplicationFile)23 Test (org.junit.Test)11 Path (com.yahoo.path.Path)5 ArrayList (java.util.ArrayList)3 File (java.io.File)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 TenantName (com.yahoo.config.provision.TenantName)1 IOUtils (com.yahoo.io.IOUtils)1 LogLevel (com.yahoo.log.LogLevel)1 CompressedApplicationInputStreamTest (com.yahoo.vespa.config.server.http.CompressedApplicationInputStreamTest)1 ContentHandler (com.yahoo.vespa.config.server.http.ContentHandler)1 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)1 ConfigUtils (com.yahoo.vespa.config.util.ConfigUtils)1 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)1 Exceptions (com.yahoo.yolean.Exceptions)1 java.io (java.io)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1