Search in sources :

Example 31 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class SuperModelControllerTest method setupHandler.

@Before
public void setupHandler() throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
    models.put(TenantName.from("a"), new LinkedHashMap<>());
    File testApp = new File("src/test/resources/deploy/app");
    ApplicationId app = ApplicationId.from(TenantName.from("a"), ApplicationName.from("foo"), InstanceName.defaultName());
    models.get(app.tenant()).put(app, new ApplicationInfo(app, 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp))));
    SuperModel superModel = new SuperModel(models);
    handler = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
}
Also used : TenantName(com.yahoo.config.provision.TenantName) SuperModel(com.yahoo.config.model.api.SuperModel) SuperModelConfigProvider(com.yahoo.vespa.config.server.model.SuperModelConfigProvider) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) LinkedHashMap(java.util.LinkedHashMap) VespaModel(com.yahoo.vespa.model.VespaModel) UncompressedConfigResponseFactory(com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File) Before(org.junit.Before)

Example 32 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class HttpListConfigsRequest method createFromListRequestSimpleAppId.

private static HttpListConfigsRequest createFromListRequestSimpleAppId(HttpRequest req, BindingMatch<?> bm) {
    TenantName tenant = TenantName.from(bm.group(2));
    ApplicationName application = ApplicationName.from(bm.group(3));
    return new HttpListConfigsRequest(null, new ApplicationId.Builder().tenant(tenant).applicationName(application).build(), req.getBooleanProperty(HttpConfigRequests.RECURSIVE_QUERY_PROPERTY), false);
}
Also used : ApplicationName(com.yahoo.config.provision.ApplicationName) TenantName(com.yahoo.config.provision.TenantName)

Example 33 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class HttpListConfigsRequest method createFromNamedListRequestSimpleAppId.

private static HttpListConfigsRequest createFromNamedListRequestSimpleAppId(HttpRequest req, BindingMatch<?> bm) {
    TenantName tenant = TenantName.from(bm.group(2));
    ApplicationName application = ApplicationName.from(bm.group(3));
    String conf = bm.group(4);
    String cId;
    String cName;
    String cNamespace;
    if (bm.groupCount() >= 6) {
        cId = bm.group(5);
    } else {
        cId = "";
    }
    Tuple2<String, String> nns = HttpConfigRequest.nameAndNamespace(conf);
    cName = nns.first;
    cNamespace = nns.second;
    ConfigKey<?> key = new ConfigKey<>(cName, cId, cNamespace);
    return new HttpListConfigsRequest(key, new ApplicationId.Builder().tenant(tenant).applicationName(application).build(), req.getBooleanProperty(HttpConfigRequests.RECURSIVE_QUERY_PROPERTY), false);
}
Also used : ApplicationName(com.yahoo.config.provision.ApplicationName) ConfigKey(com.yahoo.vespa.config.ConfigKey) TenantName(com.yahoo.config.provision.TenantName)

Example 34 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class ListApplicationsHandler method handleGET.

@Override
public HttpResponse handleGET(HttpRequest request) {
    TenantName tenantName = Utils.getTenantNameFromApplicationsRequest(request);
    final String urlBase = Utils.getUrlBase(request, "/application/v2/tenant/" + tenantName + "/application/");
    List<ApplicationId> applicationIds = listApplicationIds(tenantName);
    Collection<String> applicationUrls = Collections2.transform(applicationIds, new Function<ApplicationId, String>() {

        @Override
        public String apply(ApplicationId id) {
            return createUrlStringFromId(urlBase, id, zone);
        }
    });
    return new ListApplicationsResponse(Response.Status.OK, applicationUrls);
}
Also used : TenantName(com.yahoo.config.provision.TenantName) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 35 with TenantName

use of com.yahoo.config.provision.TenantName 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

TenantName (com.yahoo.config.provision.TenantName)48 Test (org.junit.Test)15 ApplicationId (com.yahoo.config.provision.ApplicationId)12 Map (java.util.Map)12 LinkedHashMap (java.util.LinkedHashMap)11 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)9 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)4 ApplicationName (com.yahoo.config.provision.ApplicationName)4 SuperModel (com.yahoo.config.model.api.SuperModel)3 Slime (com.yahoo.slime.Slime)3 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)3 PrepareParams (com.yahoo.vespa.config.server.session.PrepareParams)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 DeployState (com.yahoo.config.model.deploy.DeployState)2 Version (com.yahoo.config.provision.Version)2 Zone (com.yahoo.config.provision.Zone)2 ConfigKey (com.yahoo.vespa.config.ConfigKey)2