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));
}
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;
}
}
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)));
}
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;
}
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);
}
Aggregations