Search in sources :

Example 91 with ApplicationId

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

the class RpcServer method createGetConfigContext.

/**
 * Returns the context for this request, or null if the server is not properly set up with handlers
 */
public GetConfigContext createGetConfigContext(Optional<TenantName> optionalTenant, JRTServerConfigRequest request, Trace trace) {
    if ("*".equals(request.getConfigKey().getConfigId())) {
        return GetConfigContext.create(ApplicationId.global(), superModelRequestHandler, trace);
    }
    // perhaps needed for non-hosted?
    TenantName tenant = optionalTenant.orElse(TenantName.defaultName());
    if (!hasRequestHandler(tenant)) {
        String msg = Tenants.logPre(tenant) + "Unable to find request handler for tenant. Requested from host '" + request.getClientHostName() + "'";
        metrics.incUnknownHostRequests();
        trace.trace(TRACELEVEL, msg);
        log.log(LogLevel.WARNING, msg);
        return null;
    }
    RequestHandler handler = getRequestHandler(tenant);
    ApplicationId applicationId = handler.resolveApplicationId(request.getClientHostName());
    if (trace.shouldTrace(TRACELEVEL_DEBUG)) {
        trace.trace(TRACELEVEL_DEBUG, "Host '" + request.getClientHostName() + "' should have config from application '" + applicationId + "'");
    }
    return GetConfigContext.create(applicationId, handler, trace);
}
Also used : RequestHandler(com.yahoo.vespa.config.server.RequestHandler) SuperModelRequestHandler(com.yahoo.vespa.config.server.SuperModelRequestHandler) TenantName(com.yahoo.config.provision.TenantName) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 92 with ApplicationId

use of com.yahoo.config.provision.ApplicationId 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 93 with ApplicationId

use of com.yahoo.config.provision.ApplicationId 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 94 with ApplicationId

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

the class HttpListConfigsRequest method createFromNamedListRequestFullAppId.

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

Example 95 with ApplicationId

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

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11