use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class KuduUIServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
String hostname = role.getHostRef().getHostname();
String sslEnabled = getRoleConfigValue(roleConfig, SSL_ENABLED);
String scheme = Boolean.parseBoolean(sslEnabled) ? "https" : "http";
String port = getRoleConfigValue(roleConfig, WEBSERVER_PORT);
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s/", scheme, hostname, port));
model.addRoleProperty(getRoleType(), SSL_ENABLED, sslEnabled);
model.addRoleProperty(getRoleType(), WEBSERVER_PORT, port);
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class SolrServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) {
String hostname = role.getHostRef().getHostname();
String scheme;
String port;
String sslEnabled = getServiceConfigValue(serviceConfig, USE_SSL);
if (Boolean.parseBoolean(sslEnabled)) {
scheme = "https";
port = getRoleConfigValue(roleConfig, HTTPS_PORT);
} else {
scheme = "http";
port = getRoleConfigValue(roleConfig, HTTP_PORT);
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s/solr/", scheme, hostname, port));
model.addServiceProperty(USE_SSL, sslEnabled);
model.addRoleProperty(getRoleType(), HTTP_PORT, getRoleConfigValue(roleConfig, HTTP_PORT));
model.addRoleProperty(getRoleType(), HTTPS_PORT, getRoleConfigValue(roleConfig, HTTPS_PORT));
// Add some service details for qualifying the discovery process for this service
model.addQualifyingServiceParam(DISCOVERY_SERVICE_NAME, service.getName());
model.addQualifyingServiceParam(DISCOVERY_SERVICE_DISPLAY_NAME, service.getDisplayName());
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class JobHistoryUIServiceModelGenerator 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;
if (isSSLEnabled(service, serviceConfig)) {
scheme = "https";
port = getRoleConfigValue(roleConfig, HTTPS_PORT);
} else {
scheme = "http";
port = getRoleConfigValue(roleConfig, HTTP_PORT);
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addRoleProperty(getRoleType(), HTTP_PORT, getRoleConfigValue(roleConfig, HTTP_PORT));
model.addRoleProperty(getRoleType(), HTTPS_PORT, getRoleConfigValue(roleConfig, HTTPS_PORT));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class SparkHistoryUIServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) {
String hostname = role.getHostRef().getHostname();
String scheme;
String port;
String sslEnabled = getRoleConfigValue(roleConfig, SSL_ENABLED);
if (Boolean.parseBoolean(sslEnabled)) {
scheme = "https";
port = getRoleConfigValue(roleConfig, SSL_SERVER_PORT);
} else {
scheme = "http";
port = getRoleConfigValue(roleConfig, HISTORY_SERVER_PORT);
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addRoleProperty(getRoleType(), SSL_ENABLED, sslEnabled);
model.addRoleProperty(getRoleType(), SSL_SERVER_PORT, getRoleConfigValue(roleConfig, SSL_SERVER_PORT));
model.addRoleProperty(getRoleType(), HISTORY_SERVER_PORT, getRoleConfigValue(roleConfig, HISTORY_SERVER_PORT));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class ClouderaManagerClusterConfigurationMonitor method addServiceConfiguration.
/**
* Add the specified cluster service configurations to the monitor.
*
* @param cluster The cluster to be added.
* @param discoveryConfig The discovery configuration associated with the cluster.
*/
public void addServiceConfiguration(final ClouderaManagerCluster cluster, final ServiceDiscoveryConfig discoveryConfig) {
String address = discoveryConfig.getAddress();
String clusterName = cluster.getName();
// Because this is the result of a discovery, disregard restart events which
// occurred before "now" in future polling
internalMonitor.setEventQueryTimestamp(address, clusterName, Instant.now());
// Persist the discovery configuration
discoveryConfigStore.store(discoveryConfig);
// Add the discovery configuration to the cache
configCache.addDiscoveryConfig(discoveryConfig);
Map<String, List<ServiceModel>> serviceModels = cluster.getServiceModels();
// Process the service models
Map<String, ServiceConfigurationModel> scpMap = new HashMap<>();
for (String service : serviceModels.keySet()) {
for (ServiceModel model : serviceModels.get(service)) {
ServiceConfigurationModel scp = scpMap.computeIfAbsent(model.getServiceType(), p -> new ServiceConfigurationModel());
Map<String, String> serviceProps = model.getServiceProperties();
for (Map.Entry<String, String> entry : serviceProps.entrySet()) {
scp.addServiceProperty(entry.getKey(), entry.getValue());
}
Map<String, Map<String, String>> roleProps = model.getRoleProperties();
for (String roleName : roleProps.keySet()) {
Map<String, String> rp = roleProps.get(roleName);
for (Map.Entry<String, String> entry : rp.entrySet()) {
scp.addRoleProperty(roleName, entry.getKey(), entry.getValue());
}
}
}
}
// Persist the service configurations
serviceConfigStore.store(address, clusterName, scpMap);
// Add the service configurations to the cache
configCache.addServiceConfiguration(address, clusterName, scpMap);
}
Aggregations