Search in sources :

Example 6 with ApplicationFile

use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.

the class ZooKeeperClient method writeUserIncludeDirs.

private void writeUserIncludeDirs(ApplicationPackage applicationPackage, List<String> userIncludeDirs) throws IOException {
    // User defined include directories
    for (String userInclude : userIncludeDirs) {
        ApplicationFile dir = applicationPackage.getFile(Path.fromString(userInclude));
        final List<ApplicationFile> files = dir.listFiles();
        if (files == null || files.isEmpty()) {
            configCurator.createNode(getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + userInclude).getAbsolute());
        }
        writeDir(dir, getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + userInclude), xmlFilter, true);
    }
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile)

Example 7 with ApplicationFile

use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.

the class ContentHandler method delete.

public HttpResponse delete(ContentRequest request) {
    ApplicationFile file = request.getExistingFile();
    deleteFile(file);
    return createResponse(request);
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile)

Example 8 with ApplicationFile

use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.

the class ApplicationHandler method handleGET.

@Override
public HttpResponse handleGET(HttpRequest request) {
    ApplicationId applicationId = getApplicationIdFromRequest(request);
    Tenant tenant = verifyTenantAndApplication(applicationId);
    if (isServiceConvergeRequest(request)) {
        return applicationRepository.serviceConvergenceCheck(tenant, applicationId, getHostNameFromRequest(request), request.getUri());
    }
    if (isClusterControllerStatusRequest(request)) {
        String hostName = getHostNameFromRequest(request);
        String pathSuffix = getPathSuffix(request);
        return applicationRepository.clusterControllerStatusPage(tenant, applicationId, hostName, pathSuffix);
    }
    if (isContentRequest(request)) {
        long sessionId = applicationRepository.getSessionIdForApplication(tenant, applicationId);
        String contentPath = ApplicationContentRequest.getContentPath(request);
        ApplicationFile applicationFile = applicationRepository.getApplicationFileFromSession(tenant.getName(), sessionId, contentPath, ContentRequest.getApplicationFileMode(request.getMethod()));
        ApplicationContentRequest contentRequest = new ApplicationContentRequest(request, sessionId, applicationId, zone, contentPath, applicationFile);
        return new ContentHandler().get(contentRequest);
    }
    if (isServiceConvergeListRequest(request)) {
        return applicationRepository.serviceListToCheckForConfigConvergence(tenant, applicationId, request.getUri());
    }
    if (isFiledistributionStatusRequest(request)) {
        Duration timeout = HttpHandler.getRequestTimeout(request, Duration.ofSeconds(5));
        return applicationRepository.filedistributionStatus(tenant, applicationId, timeout);
    }
    return new GetApplicationResponse(Response.Status.OK, applicationRepository.getApplicationGeneration(tenant, applicationId));
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Duration(java.time.Duration) ApplicationId(com.yahoo.config.provision.ApplicationId) ContentHandler(com.yahoo.vespa.config.server.http.ContentHandler)

Example 9 with ApplicationFile

use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.

the class LocalSessionTest method require_that_application_file_can_be_fetched.

@Test
public void require_that_application_file_can_be_fetched() throws Exception {
    LocalSession session = createSession(TenantName.defaultName(), 3);
    ApplicationFile f1 = session.getApplicationFile(Path.fromString("services.xml"), LocalSession.Mode.READ);
    ApplicationFile f2 = session.getApplicationFile(Path.fromString("services2.xml"), LocalSession.Mode.READ);
    assertTrue(f1.exists());
    assertFalse(f2.exists());
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Test(org.junit.Test)

Example 10 with ApplicationFile

use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.

the class ZKApplicationFileTest method getApplicationFile.

@Override
public ApplicationFile getApplicationFile(Path path) throws IOException {
    ConfigCurator configCurator = ConfigCurator.create(new MockCurator());
    File tmp = Files.createTempDir();
    writeAppTo(tmp);
    feed(configCurator, tmp);
    return new ZKApplicationFile(path, new ZKLiveApp(configCurator, Path.fromString("/0")));
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator)

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