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