use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class ClouderaManagerAPIServiceModelGenerator method generateService.
/**
* This method functions differently than others. This method inquires the
* discovery client and uses the CM url used by the driver (which was
* populated by the descriptor).
*
* @param service Service.
* @param serviceConfig Service config.
* @param role Role.
* @param roleConfig Role config.
* @return ServiceModel for given service and role.
* @throws ApiException Exception interacting with CM.
*/
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
final String basePath = getClient().getBasePath();
URI uri;
try {
uri = new URI(basePath);
} catch (URISyntaxException e) {
throw new ApiException(e);
}
final String serviceURL = getModelType() == ServiceModel.Type.API ? String.format(Locale.getDefault(), "%s://%s:%s/api", uri.getScheme(), uri.getHost(), uri.getPort()) : String.format(Locale.getDefault(), "%s://%s:%s", uri.getScheme(), uri.getHost(), uri.getPort());
return new ServiceModel(getModelType(), getService(), getServiceType(), getRoleType(), serviceURL);
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class AtlasServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
String hostname = role.getHostRef().getHostname();
String scheme;
String port;
boolean sslEnabled = Boolean.parseBoolean(getRoleConfigValue(roleConfig, SSL_ENABLED));
if (sslEnabled) {
scheme = "https";
port = getRoleConfigValue(roleConfig, HTTPS_PORT);
} else {
scheme = "http";
port = getRoleConfigValue(roleConfig, HTTP_PORT);
}
ServiceModel model = new ServiceModel(getModelType(), getService(), getServiceType(), getRoleType(), String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addRoleProperty(getRoleType(), SSL_ENABLED, getRoleConfigValue(roleConfig, SSL_ENABLED));
model.addRoleProperty(getRoleType(), HTTPS_PORT, getRoleConfigValue(roleConfig, HTTPS_PORT));
model.addRoleProperty(getRoleType(), HTTP_PORT, getRoleConfigValue(roleConfig, HTTP_PORT));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class HdfsUIServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
String hostname = role.getHostRef().getHostname();
String scheme;
String port;
boolean sslEnabled = Boolean.parseBoolean(getServiceConfigValue(serviceConfig, SSL_ENABLED));
if (sslEnabled) {
scheme = "https";
port = getRoleConfigValue(roleConfig, HTTPS_PORT);
} else {
scheme = "http";
port = getRoleConfigValue(roleConfig, HTTP_PORT);
}
String namenodeUrl = String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port);
ServiceModel model = createServiceModel(namenodeUrl);
model.addServiceProperty(SSL_ENABLED, getServiceConfigValue(serviceConfig, SSL_ENABLED));
model.addRoleProperty(role.getType(), HTTPS_PORT, getRoleConfigValue(roleConfig, HTTPS_PORT));
model.addRoleProperty(role.getType(), HTTP_PORT, getRoleConfigValue(roleConfig, HTTP_PORT));
ServiceModel parent = super.generateService(service, serviceConfig, role, roleConfig);
addParentModelMetadata(model, parent);
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class WebHdfsServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
ServiceModel parent = super.generateService(service, serviceConfig, role, roleConfig);
String serviceUrl = parent.getServiceUrl() + WEBHDFS_SUFFIX;
ServiceModel model = createServiceModel(serviceUrl);
model.addServiceProperty(WEBHDFS_ENABLED, getServiceConfigValue(serviceConfig, WEBHDFS_ENABLED));
// Add parent model metadata
addParentModelMetadata(model, parent);
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class ImpalaServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
String hostname = role.getHostRef().getHostname();
boolean sslEnabled = Boolean.parseBoolean(getServiceConfigValue(serviceConfig, SSL_ENABLED));
String scheme = sslEnabled ? "https" : "http";
// Role config properties
String port = getRoleConfigValue(roleConfig, HTTP_PORT);
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s/", scheme, hostname, port));
model.addServiceProperty(SSL_ENABLED, getServiceConfigValue(serviceConfig, SSL_ENABLED));
model.addRoleProperty(getRoleType(), HTTP_PORT, port);
return model;
}
Aggregations