Search in sources :

Example 1 with ApplicationMetaData

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

the class ZooKeeperClientTest method testFeedAppMetaDataToZooKeeper.

@Test
public void testFeedAppMetaDataToZooKeeper() {
    assertTrue(zk.exists(appPath, ConfigCurator.META_ZK_PATH));
    ApplicationMetaData metaData = ApplicationMetaData.fromJsonString(zk.getData(appPath, ConfigCurator.META_ZK_PATH));
    assertThat(metaData.getApplicationName(), is("appName"));
    assertTrue(metaData.getCheckSum().length() > 0);
    assertThat(metaData.getDeployedByUser(), is("foo"));
    assertThat(metaData.getDeployPath(), is("/bar/baz"));
    assertThat(metaData.getDeployTimestamp(), is(1345l));
    assertThat(metaData.getGeneration(), is(3l));
    assertThat(metaData.getPreviousActiveGeneration(), is(2l));
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) Test(org.junit.Test)

Example 2 with ApplicationMetaData

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

the class FilesApplicationPackage method readMetaData.

public static ApplicationMetaData readMetaData(File appDir) {
    ApplicationMetaData defaultMetaData = new ApplicationMetaData(appDir, "n/a", "n/a", 0l, "", 0l, 0l);
    File metaFile = new File(appDir, META_FILE_NAME);
    if (!metaFile.exists()) {
        return defaultMetaData;
    }
    try (FileReader reader = new FileReader(metaFile)) {
        return ApplicationMetaData.fromJsonString(IOUtils.readAll(reader));
    } catch (Exception e) {
        // Not a big deal, return default
        return defaultMetaData;
    }
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) JarFile(java.util.jar.JarFile) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) TransformerException(javax.xml.transform.TransformerException) URISyntaxException(java.net.URISyntaxException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 3 with ApplicationMetaData

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

the class ApplicationDeployTest method testMetaData.

@Test
public void testMetaData() throws IOException, JSONException {
    File tmp = Files.createTempDir();
    String appPkg = TESTDIR + "app1";
    IOUtils.copyDirectory(new File(appPkg), tmp);
    final DeployData deployData = new DeployData("foo", "bar", "baz", 13l, 1337l, 3l);
    FilesApplicationPackage app = FilesApplicationPackage.fromFileWithDeployData(tmp, deployData);
    app.writeMetaData();
    FilesApplicationPackage newApp = FilesApplicationPackage.fromFileWithDeployData(tmp, deployData);
    ApplicationMetaData meta = newApp.getMetaData();
    assertThat(meta.getDeployedByUser(), is("foo"));
    assertThat(meta.getDeployPath(), is("bar"));
    assertThat(meta.getDeployTimestamp(), is(13l));
    assertThat(meta.getGeneration(), is(1337l));
    assertThat(meta.getPreviousActiveGeneration(), is(3l));
    final String checkSum = meta.getCheckSum();
    assertNotNull(checkSum);
    assertTrue((new File(tmp, "hosts.xml")).delete());
    FilesApplicationPackage app2 = FilesApplicationPackage.fromFileWithDeployData(tmp, deployData);
    final String app2CheckSum = app2.getMetaData().getCheckSum();
    assertThat(app2CheckSum, is(not(checkSum)));
    assertTrue((new File(tmp, "files/foo.json")).delete());
    FilesApplicationPackage app3 = FilesApplicationPackage.fromFileWithDeployData(tmp, deployData);
    final String app3CheckSum = app3.getMetaData().getCheckSum();
    assertThat(app3CheckSum, is(not(app2CheckSum)));
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 4 with ApplicationMetaData

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

the class SessionFactoryImpl method createSessionFromExisting.

@Override
public LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, TimeoutBudget timeoutBudget) {
    File existingApp = getSessionAppDir(existingSession.getSessionId());
    ApplicationMetaData metaData = FilesApplicationPackage.readMetaData(existingApp);
    ApplicationId existingApplicationId = existingSession.getApplicationId();
    long liveApp = getLiveApp(existingApplicationId);
    logger.log(LogLevel.DEBUG, "Create from existing application id " + existingApplicationId + ", live app for it is " + liveApp);
    LocalSession session = create(existingApp, metaData.getApplicationName(), liveApp, timeoutBudget);
    session.setApplicationId(existingApplicationId);
    session.setVespaVersion(existingSession.getVespaVersion());
    return session;
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) ApplicationId(com.yahoo.config.provision.ApplicationId) File(java.io.File)

Example 5 with ApplicationMetaData

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

the class SessionActiveHandler method handlePUT.

@Override
protected HttpResponse handlePUT(HttpRequest request) {
    final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
    Utils.checkThatTenantExists(tenants, tenantName);
    Tenant tenant = tenants.getTenant(tenantName);
    TimeoutBudget timeoutBudget = getTimeoutBudget(request, DEFAULT_ACTIVATE_TIMEOUT);
    final Long sessionId = getSessionIdV2(request);
    ApplicationId applicationId = applicationRepository.activate(tenant, sessionId, timeoutBudget, shouldIgnoreLockFailure(request), shouldIgnoreSessionStaleFailure(request));
    ApplicationMetaData metaData = applicationRepository.getMetadataFromSession(tenant, sessionId);
    return new SessionActiveResponse(metaData.getSlime(), request, applicationId, sessionId, zone);
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) TimeoutBudget(com.yahoo.vespa.config.server.TimeoutBudget) ApplicationId(com.yahoo.config.provision.ApplicationId)

Aggregations

ApplicationMetaData (com.yahoo.config.application.api.ApplicationMetaData)5 ApplicationId (com.yahoo.config.provision.ApplicationId)2 File (java.io.File)2 JarFile (java.util.jar.JarFile)2 Test (org.junit.Test)2 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)1 TenantName (com.yahoo.config.provision.TenantName)1 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)1 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)1 URISyntaxException (java.net.URISyntaxException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 SAXException (org.xml.sax.SAXException)1