use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class VespaModelTestCase method testDeployLogger.
@Test
public void testDeployLogger() throws IOException, SAXException {
final String services = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<services version=\"1.0\">" + "<config name=\"unknsownfoo\">" + "<logserver><host>foo</host></logserver>" + "</config>" + "<admin version=\"2.0\">" + " <adminserver hostalias=\"node0\" />" + "</admin>" + "</services>";
MyLogger logger = new MyLogger();
final DeployState.Builder builder = new DeployState.Builder();
builder.modelHostProvisioner(new HostsXmlProvisioner(new StringReader(simpleHosts)));
ApplicationPackage app = new MockApplicationPackage.Builder().withHosts(simpleHosts).withServices(services).build();
DeployState deployState = builder.deployLogger(logger).applicationPackage(app).build(true);
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
Validation.validate(model, true, deployState);
assertFalse(logger.msgs.isEmpty());
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class VespaModelTester method createModel.
/**
* Creates a model using the hosts already added to this
*
* @param services the services xml string
* @param failOnOutOfCapacity whether we should get an exception when not enough hosts of the requested flavor
* is available or if we should just silently receive a smaller allocation
* @return the resulting model
*/
public VespaModel createModel(String services, boolean failOnOutOfCapacity, int startIndexForClusters, String... retiredHostNames) {
VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
HostProvisioner provisioner = hosted ? new InMemoryProvisioner(hostsByFlavor, failOnOutOfCapacity, startIndexForClusters, retiredHostNames) : new SingleNodeProvisioner();
DeployProperties properties = new DeployProperties.Builder().hostedVespa(hosted).applicationId(applicationId).build();
DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
return modelCreatorWithMockPkg.create(false, deployState, configModelRegistry);
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class SessionFactoryImpl method create.
private LocalSession create(File applicationFile, String applicationName, long currentlyActiveSession, TimeoutBudget timeoutBudget) {
long sessionId = sessionCounter.nextSessionId();
Path sessionIdPath = sessionsPath.append(String.valueOf(sessionId));
log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute());
try {
ensureZKPathDoesNotExist(sessionIdPath);
SessionZooKeeperClient sessionZooKeeperClient = new SessionZooKeeperClient(curator, configCurator, sessionIdPath, defRepo, serverId, nodeFlavors);
File userApplicationDir = tenantFileSystemDirs.getUserApplicationDir(sessionId);
IOUtils.copyDirectory(applicationFile, userApplicationDir);
ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, applicationName, sessionId, currentlyActiveSession);
applicationPackage.writeMetaData();
return createSessionFromApplication(applicationPackage, sessionId, sessionZooKeeperClient, timeoutBudget, clock);
} catch (Exception e) {
throw new RuntimeException("Error creating session " + sessionIdPath, e);
}
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ApplicationHandlerTest method addApplication.
private static Tenants addApplication(ApplicationId applicationId, long sessionId) throws Exception {
// This method is a good illustration of the spaghetti wiring resulting from no design
// TODO: When this setup looks sane we have refactored sufficiently that there is a design
TenantName tenantName = applicationId.tenant();
Path tenantPath = Tenants.getTenantPath(tenantName);
Path sessionPath = tenantPath.append(Tenant.SESSIONS).append(String.valueOf(sessionId));
MockCurator curator = new MockCurator();
GlobalComponentRegistry componentRegistry = new TestComponentRegistry.Builder().curator(curator).modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))).build();
// Creates the application path element in zk
Tenants tenants = new Tenants(componentRegistry);
tenants.addTenant(tenantName);
Tenant tenant = tenants.getTenant(tenantName);
tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
SessionZooKeeperClient sessionClient = new SessionZooKeeperClient(curator, sessionPath);
SessionContext context = new SessionContext(app, sessionClient, new File("/serverDb"), tenant.getApplicationRepo(), null, new SuperModelGenerationCounter(curator));
tenant.getLocalSessionRepo().addSession(new LocalSession(tenantName, sessionId, null, context));
// TODO: Instead, use ApplicationRepository to deploy the application
sessionClient.writeApplicationId(applicationId);
tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenantName, sessionId, componentRegistry, sessionClient, Clock.systemUTC()));
return tenants;
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ApplicationHandlerTest method addMockApplication.
static void addMockApplication(Tenant tenant, ApplicationId applicationId, long sessionId, Clock clock) {
tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
tenant.getLocalSessionRepo().addSession(new SessionHandlerTest.MockSession(sessionId, app, applicationId));
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))).build();
tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenant.getName(), sessionId, componentRegistry, new MockSessionZKClient(app), clock));
}
Aggregations